[klibc] [klibc:master] Kbuild: support clang's lld
klibc-bot for Bill Wendling
morbo at google.com
Sat Jul 25 13:57:04 PDT 2020
Commit-ID: eaca2447991709cddfd8c42f3fa4a2e890d2cce8
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=eaca2447991709cddfd8c42f3fa4a2e890d2cce8
Author: Bill Wendling <morbo at google.com>
AuthorDate: Sun, 29 Mar 2020 04:38:31 -0700
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 25 Jul 2020 20:45:34 +0100
[klibc] Kbuild: support clang's lld
Clang's lld prefers the use of "-image-base" instead of
"-Ttext-segment".
Signed-off-by: Stanislav Fomichev <sdf at google.com>
Signed-off-by: Bill Wendling <morbo at google.com>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
Makefile | 3 +++
usr/klibc/arch/i386/MCONFIG | 2 +-
usr/klibc/arch/mips64/MCONFIG | 5 +++--
usr/klibc/arch/ppc/MCONFIG | 2 +-
usr/klibc/arch/ppc64/MCONFIG | 2 +-
usr/klibc/arch/riscv64/MCONFIG | 2 +-
usr/klibc/arch/sparc64/MCONFIG | 2 +-
usr/klibc/arch/x86_64/MCONFIG | 2 +-
8 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index c99b962f..c8325154 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,9 @@ export NM := $(KLIBCROSS)nm
export OBJCOPY := $(KLIBCROSS)objcopy
export OBJDUMP := $(KLIBCROSS)objdump
+LLD := $(shell $(LD) --version 2>&1 | grep LLD)
+export LD_IMAGE_BASE_OPT=$(if $(LLD),--image-base,-Ttext-segment)
+
NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include)
ARCH := $(shell uname -m | sed -e s/i.86/i386/ \
diff --git a/usr/klibc/arch/i386/MCONFIG b/usr/klibc/arch/i386/MCONFIG
index c7d3fccd..e6f50dde 100644
--- a/usr/klibc/arch/i386/MCONFIG
+++ b/usr/klibc/arch/i386/MCONFIG
@@ -30,7 +30,7 @@ KLIBCBITSIZE = 32
# This address needs to be reachable using normal inter-module
# calls, and work on the memory models for this architecture
# 96 MB - normal binaries start at 128 MB
-KLIBCSHAREDFLAGS = -Ttext-segment 0x06000000
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x06000000
# Kernel uses dedicated page or vDSO for signal return since 2.5.55
KLIBCEXECSTACK := n
diff --git a/usr/klibc/arch/mips64/MCONFIG b/usr/klibc/arch/mips64/MCONFIG
index 94b825a6..6dcb143e 100644
--- a/usr/klibc/arch/mips64/MCONFIG
+++ b/usr/klibc/arch/mips64/MCONFIG
@@ -19,8 +19,9 @@ KLIBCBITSIZE = 64
# 256M aligned region. Since we can't put ourselves below the normal
# load address, use the very top of the 256M region (minus 2MB)
#
-# Use -Ttext-segment so that the special .MIPS* sections are moved as well.
-KLIBCSHAREDFLAGS = -Ttext-segment 0x12FE00000
+# Use -Ttext-segment/--image_base so that the special .MIPS* sections
+# are moved as well.
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x12FE00000
# Kernel uses vDSO for signal return since 2.6.34
KLIBCEXECSTACK := n
diff --git a/usr/klibc/arch/ppc/MCONFIG b/usr/klibc/arch/ppc/MCONFIG
index d8a0c108..db4806ab 100644
--- a/usr/klibc/arch/ppc/MCONFIG
+++ b/usr/klibc/arch/ppc/MCONFIG
@@ -20,7 +20,7 @@ KLIBCBITSIZE = 32
# calls, and work on the memory models for this architecture
# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
# to +/- 16 MB
-KLIBCSHAREDFLAGS = -Ttext-segment 0x0f800000
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x0f800000
# The asm include files live in asm-powerpc
KLIBCASMARCH = powerpc
diff --git a/usr/klibc/arch/ppc64/MCONFIG b/usr/klibc/arch/ppc64/MCONFIG
index 530a07a0..43265601 100644
--- a/usr/klibc/arch/ppc64/MCONFIG
+++ b/usr/klibc/arch/ppc64/MCONFIG
@@ -18,7 +18,7 @@ KLIBCBITSIZE = 64
# calls, and work on the memory models for this architecture
# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
# to +/- 16 MB
-KLIBCSHAREDFLAGS = -Ttext-segment 0x0f000000
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x0f000000
# The asm include files live in asm-powerpc
KLIBCASMARCH = powerpc
diff --git a/usr/klibc/arch/riscv64/MCONFIG b/usr/klibc/arch/riscv64/MCONFIG
index 35df1f5f..9bc7bd24 100644
--- a/usr/klibc/arch/riscv64/MCONFIG
+++ b/usr/klibc/arch/riscv64/MCONFIG
@@ -17,7 +17,7 @@ endif
KLIBCBITSIZE = 64
# Normal binaries start at 64 KB, so start the libary at 2 MB.
-KLIBCSHAREDFLAGS =-Ttext-segment 0x00200000
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x00200000
# Kernel has never used stack trampolines
KLIBCEXECSTACK := n
diff --git a/usr/klibc/arch/sparc64/MCONFIG b/usr/klibc/arch/sparc64/MCONFIG
index 6f5dfbe9..81ad959e 100644
--- a/usr/klibc/arch/sparc64/MCONFIG
+++ b/usr/klibc/arch/sparc64/MCONFIG
@@ -18,7 +18,7 @@ KLIBCLDFLAGS = -m elf64_sparc
# calls, and work on the memory models for this architecture
# Normal binaries start at 1 MB; the linker wants 1 MB alignment,
# and call instructions have a 30-bit signed offset, << 2.
-KLIBCSHAREDFLAGS = -Ttext-segment 0x80000000
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x80000000
# Kernel has never used stack trampolines
KLIBCEXECSTACK := n
diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG
index c2947c6a..307b48fb 100644
--- a/usr/klibc/arch/x86_64/MCONFIG
+++ b/usr/klibc/arch/x86_64/MCONFIG
@@ -37,7 +37,7 @@ KLIBCLDFLAGS = -m elf_x86_64
# The old default was max-page-size=0x100000, but that also results
# in a broken layout with binutils 2.30. Since there's no
# architectural page size betwen 4 KB and 2MB, set it to 4 KB.
-KLIBCSHAREDFLAGS = -Ttext-segment 0x00200000 -z max-page-size=0x1000
+KLIBCSHAREDFLAGS = $(LD_IMAGE_BASE_OPT) 0x00200000 -z max-page-size=0x1000
# Kernel has never used stack trampolines
KLIBCEXECSTACK := n
More information about the klibc
mailing list