[klibc] [klibc:master] arm64, x86_64: Fix address collision when using LLD

klibc-bot for Ben Hutchings ben at decadent.org.uk
Wed Dec 29 12:33:07 PST 2021


Commit-ID:  84d60fb75c0d8eaebc76da029130657f6c683ff3
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=84d60fb75c0d8eaebc76da029130657f6c683ff3
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Wed, 29 Dec 2021 18:32:30 +0100
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Wed, 29 Dec 2021 21:30:39 +0100

[klibc] arm64,x86_64: Fix address collision when using LLD

LLD 13 is using a default base address of 2 MB for executables on
these architectures, and since we set the base address of klibc.so to
2 MB they are now colliding with each other.

Explicitly set the base address to 4 MB, matching GNU ld's default.

Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/klibc/arch/arm64/MCONFIG  | 1 +
 usr/klibc/arch/x86_64/MCONFIG | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/usr/klibc/arch/arm64/MCONFIG b/usr/klibc/arch/arm64/MCONFIG
index f8741ff2..b90568ec 100644
--- a/usr/klibc/arch/arm64/MCONFIG
+++ b/usr/klibc/arch/arm64/MCONFIG
@@ -13,6 +13,7 @@ CPU_TUNE ?= generic
 KLIBCOPTFLAGS += -g -Os -march=$(CPU_ARCH) -mtune=$(CPU_TUNE)
 KLIBCBITSIZE  = 64
 KLIBCREQFLAGS += -fno-exceptions -mgeneral-regs-only
+KLIBCLDFLAGS  = $(LD_IMAGE_BASE_OPT) 0x00400000
 
 # Extra linkflags when building the shared version of the library
 # This address needs to be reachable using normal inter-module
diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG
index 307b48fb..70d690e3 100644
--- a/usr/klibc/arch/x86_64/MCONFIG
+++ b/usr/klibc/arch/x86_64/MCONFIG
@@ -25,7 +25,7 @@ else
 KLIBCOPTFLAGS     += -fno-asynchronous-unwind-tables
 endif
 KLIBCBITSIZE      = 64
-KLIBCLDFLAGS      = -m elf_x86_64
+KLIBCLDFLAGS      = -m elf_x86_64 $(LD_IMAGE_BASE_OPT) 0x00400000
 
 # Extra linkflags when building the shared version of the library
 # This address needs to be reachable using normal inter-module


More information about the klibc mailing list