clang -pg, libm and the _end symbol
Raphael Kubo da Costa
rakuco at FreeBSD.org
Wed Feb 24 14:06:01 UTC 2016
Konstantin Belousov <kostikbel at gmail.com> writes:
> This is probably not a clang bug, but could be. More likely it is ld problem.
> I do not want to dig into the issue, but I can provide you some points to
> look at further.
>
> The _end symbol is magic, it is defined as the address of the last byte
> + 1 of zero-initialized data section (.bss). But the symbol is not
> provided by any object file participating in the linkage of the binary,
> instead it is created by the linker after all sections are combined in
> the segments and segments are laid out.
>
> The symbol is creation requested by the linker script, look at the
> /usr/libdata/ldscripts for them, first line of the file contains
> comment explaining which final binary format is served by the each
> script.
>
> We are aware that binutils 2.25.1 ld for aarch64 has bug where _end is
> not exported from executable, I was not able to track the bug.
>
> To diagnose your issue, look up which linker script is used for -pg
> linking, look for the _end symbol there. If it is properly requested,
> then the bug is in base linker.
With and without -pg, the linker script being used is elf_x86_64_fbsd.xc
("Script for -z combreloc: combine and sort reloc sections"). It does
contain an entry for _end:
182 _end = .; PROVIDE (end = .);
lang/gcc with ld from devel/binutils also fails on HEAD:
/usr/local/bin/ld: //usr/lib/libc_p.a(sbrk.po): undefined reference to
symbol '_end'
//lib/libc.so.7: error adding symbols: DSO missing from command line
More information about the freebsd-toolchain
mailing list