|
|
|
|
|
by minipci1321
3461 days ago
|
|
For the completeness sake, the size of an array can also be computed via linker symbols, see for example: http://stackoverflow.com/questions/29901788/finding-the-last.... Same constraints apply (pointer arith). I am not sure why this method, applied to ordinary arrays, would be preferred to sizeof (), but since we're shedding light here... EDIT: pointer arith constraints only apply if we compute the difference (end - beg) in the C code. We could also do that in the linker script itself, and I don't recall whether or not C semantics of ptrdiff_t would be preserved in that case. Such preservation doesn't seem very probable to me, so potentially this method might allow to avoid overflows (or to move them much higher) -- to be checked in the 'ld' doc! |
|