This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

COMMON symbols get overridden by PROVIDE commands?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]