#717032 changed behaviour of _end symbol

Package:
binutils
Source:
binutils
Description:
GNU assembler, linker and binary utilities
Submitter:
Petr Salinger
Date:
2025-09-17 13:29:03 UTC
Severity:
important
#717032#5
Date:
2013-07-16 07:57:20 UTC
From:
To:
Hi,

compared to binutils 2.22-8, there is a significant change of
_end symbol behaviour.


glibc built by binutils 2.22-8:

readelf -a 6/lib/x86_64-kfreebsd-gnu/libc.so.0.1 | grep _end
000000352fa8  03ee00000006 R_X86_64_GLOB_DAT 0000000000358e28 _end + 0
000000354ab8  03ee00000001 R_X86_64_64       0000000000358e28 _end + 0
   1006: 0000000000358e28     0 NOTYPE  GLOBAL DEFAULT  ABS _end@@GLIBC_PRIVATE


glibc built by binutils binutils_2.23.52.20130612-1
readelf -a 7/lib/x86_64-kfreebsd-gnu/libc.so.0.1 | grep _end
000000352fb8  03ee00000006 R_X86_64_GLOB_DAT 0000000000358e08 _end + 0
000000354ab8  03ee00000001 R_X86_64_64       0000000000358e08 _end + 0
   1006: 0000000000358e08     0 NOTYPE  GLOBAL DEFAULT   33 _end@@GLIBC_PRIVATE


The _end symbol used to resolve to the end of main binary.
It is used internally as initial brk value.
The FreeBSD kernel does not return new brk value,
only whether brk() syscall succeed or not.

As a result of this changed behaviour,
brk() and sbrk() fails everytime for kfreebsd-*.

I do not know, whether this binutils change is intentional
or how to workaround it.

Petr

#717032#10
Date:
2013-07-16 10:29:22 UTC
From:
To:
The value itself does not matter here, but ABS->33 change.

Try to build and run via ktrace under stable and under sid

int main()
{
   sbrk(16*1024);
};

You will see the key difference.

Petr

#717032#15
Date:
2013-07-17 20:57:22 UTC
From:
To:
2013/7/16 Petr Salinger <Petr.Salinger@seznam.cz>:
GRUB relies on this symbol to calculate the size of BSS. If the symbol
is wrong, then BSS is not appropiately zeroed.

I would expect other "special" programs using the GNU toolchain to
have similar trouble. E.g. SeaBIOS, Linux, the C runtime entry point
for glibc itself (I forgot its name, I think it was called
"crtbegin")...

How did all these solve it?

#717032#20
Date:
2025-09-17 13:26:37 UTC
From:
To:
FreeBSD ports were removed, so this can be closed.