Bug 28203 - aarch64: elf_machine_{load_address,dynamic} should drop _GLOBAL_OFFSET_TABLE_[0] in favor of __ehdr_start for robustness
Summary: aarch64: elf_machine_{load_address,dynamic} should drop _GLOBAL_OFFSET_TABLE_...
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.35
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2021-08-06 18:27 UTC by Fangrui Song
Modified: 2021-08-12 07:37 UTC (History)
1 user (show)

See Also:
Target: aarch64-*
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-08-06 18:27:04 UTC
The AArch64 ABI is largely platform agnostic and does not specify
_GLOBAL_OFFSET_TABLE_[0] ([1]). glibc ld.so turns out to be probably the
only user of _GLOBAL_OFFSET_TABLE_[0] and GNU ld defines the value
to the link-time address _DYNAMIC. [2]

In 2012, __ehdr_start was implemented in GNU ld and gold.
Using adrp+addr to access __ehdr_start/_DYNAMIC gives us a robust way to get the
load address and the link-time address of _DYNAMIC.

With _GLOBAL_OFFSET_TABLE_[0] removed, my LLD linked glibc does not have more `make check` failures than GNU ld linked glibc.

[1]: From a psABI maintainer, https://bugs.llvm.org/show_bug.cgi?id=49672#c2
[2]: LLD's aarch64 port does not set _GLOBAL_OFFSET_TABLE_[0] to the
link-time address _DYNAMIC.
LLD is widely used on aarch64 Android and ChromeOS devices.  Software
just works without the need for _GLOBAL_OFFSET_TABLE_[0].
Comment 1 Fangrui Song 2021-08-06 18:50:55 UTC
[PATCH] aarch64: Make elf_machine_{load_address, dynamic} robust [BZ #28203]