aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2020-08-29 22:29:52 +0100
committerBen Hutchings <ben@decadent.org.uk>2020-08-29 22:53:10 +0100
commit95a3123c94abc28c65f33c9589693dde9f140fe1 (patch)
tree54c46bd2685740885711f4b7f1641b489bef0335
parentc56bb7ba64124c6e2324a52b2cd5cec79dbbb050 (diff)
downloadklibc-95a3123c94abc28c65f33c9589693dde9f140fe1.tar.gz
[klibc] Kbuild, klcc: Support multiple objects in KLIBCCRTSHARED
On some architectures (notably riscv64) we need a wrapper for the main function that is statically linked even when using a shared library. * Allow architectures to override KLIBCCRTSHARED (they should always append to it) * Change klcc to use the list of filenames in KLIBCCRTSHARED, rather than assuming it's just interp.o Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--klcc/Kbuild1
-rw-r--r--klcc/klcc.in2
-rw-r--r--scripts/Kbuild.klibc2
-rw-r--r--usr/klibc/Kbuild3
4 files changed, 6 insertions, 2 deletions
diff --git a/klcc/Kbuild b/klcc/Kbuild
index 0e625802a30450..ca46c6ce1f211b 100644
--- a/klcc/Kbuild
+++ b/klcc/Kbuild
@@ -21,6 +21,7 @@ $(obj)/$(KLIBCCROSS)klibc.config: $(src)/Kbuild \
$(Q)echo 'STRIP=$(STRIP)' >> $@
$(Q)echo 'STRIPFLAGS=$(KLIBCSTRIPFLAGS)' >> $@
$(Q)echo 'EMAIN=$(KLIBCEMAIN)' >> $@
+ $(Q)echo 'CRTSHARED=$(notdir $(KLIBCCRTSHARED))' >> $@
$(Q)echo 'BITSIZE=$(KLIBCBITSIZE)' >> $@
$(Q)echo 'VERSION=$(shell cat $(srctree)/usr/klibc/version)' >> $@
$(Q)echo 'prefix=$(INSTALLDIR)' >> $@
diff --git a/klcc/klcc.in b/klcc/klcc.in
index 7b3b8f3b7d6b75..fab32391443a85 100644
--- a/klcc/klcc.in
+++ b/klcc/klcc.in
@@ -17,7 +17,7 @@ use IPC::Open3;
# Options and libraries to pass to ld; shared versus static
@staticopt = ("${prefix}/${KCROSS}lib/crt0.o");
@staticlib = ("${prefix}/${KCROSS}lib/libc.a");
-@sharedopt = (@EMAIN, "${prefix}/${KCROSS}lib/interp.o");
+@sharedopt = (@EMAIN, map { "${prefix}/${KCROSS}lib/$_" } @CRTSHARED);
@sharedlib = ('-R', "${prefix}/${KCROSS}lib/libc.so");
# Returns the language (-x option string) for a specific extension.
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index bfe6edb3aa0157..28b5e85629a764 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -82,6 +82,7 @@ KLIBCCFLAGS :=
# Defaults for arch to override
KLIBCARCHINCFLAGS =
+KLIBCCRTSHARED := $(KLIBCOBJ)/interp.o
# Arch specific definitions for klibc
include $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG
@@ -141,7 +142,6 @@ KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) $(if $(filter gcc,$(cc-nam
KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF)
KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
KLIBCLIBC := $(KLIBCOBJ)/libc.a
-KLIBCCRTSHARED := $(KLIBCOBJ)/interp.o
KLIBCLIBCSHARED := $(KLIBCOBJ)/libc.so
# How to tell the linker main() is the entrypoint
KLIBCEMAIN ?= -e main
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 0a1933e6d6406a..dea94d06218d8a 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -208,3 +208,6 @@ ifdef KLIBCSHAREDFLAGS
$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
$(INSTALLROOT)$(SHLIBDIR)
endif
+
+# Directories to visit during clean and install
+subdir- := arch/$(KLIBCARCHDIR)/