[RFC] Hide autogenerated symbols when linking shared libraries

Nick Clifton nickc@redhat.com
Tue May 1 16:00:00 GMT 2018


Hi Yuri,

> Currently default linker script 

For which target(s) ?

> generates several temporary symbols
> which globally visible and unnecessarily increase size of dynamic
> symtable:
>   $ gcc -shared -fPIC -O2 tmp.c -o tmp.so
>   $ readelf --dyn-syms -W tmp.so
>   ...
>      7: 0000000000201020     0 NOTYPE  GLOBAL DEFAULT   21 _edata
>      9: 0000000000201028     0 NOTYPE  GLOBAL DEFAULT   22 _end
>     10: 0000000000201020     0 NOTYPE  GLOBAL DEFAULT   22 __bss_start
> 
> Is this intentional?

Yes.  Sometime these symbols are used by the crt initialization code.
For example, on bare metal systems the sbrk() function often uses the
_end symbol as the starting address for the heap.

Also tools like the dynamic loader, profilers, gdb and so on, sometimes
make use of these symbols too.  So unless you are really short on space
I would recommend leaving them in.

Cheers
  Nick

PS.  You can always create your own linker script which does not define
these symbols...



More information about the Binutils mailing list