COMMON symbols get overridden by PROVIDE commands?
Tony Beta Lambda
tonybetalambda@gmail.com
Thu Dec 18 08:31:00 GMT 2014
Hi,
The default linker script PROVIDEs the symbol end, but this replaces
the symbol defined in COMMON section and causes error. (ld version
2.24 on Linux 3.16.0 x86_64)
Example C code:
int end[100000];
int main(void) { end[99999] = 0; return 0; }
This should be completely valid, but when compiled with default options
$ gcc foo.c
(gcc version 4.9.1) and running ./a.out gives SEGV. Examination with
nm shows end gets replaced in the PROVIDE(end = .) command in the
default linker script,
and now end equals _end. If instead I let the symbol go into the
section .bss by compiling with
$ gcc foo.c -fno-common
The program then runs fine, and nm results are as expected.
I think there should at least be some sort of warnings when these
kinds of overriding occurs, otherwise mysterious errors might occur.
--
Tony Beta Lambda
More information about the Binutils
mailing list