mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] images: Use separate LDFLAGS for PBL
@ 2020-01-27 13:30 Christian Eggers
  2020-02-03  7:51 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Eggers @ 2020-01-27 13:30 UTC (permalink / raw)
  To: barebox; +Cc: Christian Eggers, ceggers

When setting CONFIG_PBL_RELOCATABLE=y (selected by PBL_MULTI_IMAGES) and
CONFIG_RELOCATABLE=n (trying to reduce image size), the PBL is also
linked with "-static" instead of "-pie". The result is a non-working
PBL.

As a side effect, also get rid of erroneous "-Map barebox.map" when
linking the PBL.

Only changed for ARM, are any other platforms affected?

Signed-off-by: Christian Eggers <ceggers@arri.de>
---
 Makefile          | 2 ++
 arch/arm/Makefile | 7 +++++++
 images/Makefile   | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index e08849718..49861508a 100644
--- a/Makefile
+++ b/Makefile
@@ -313,6 +313,7 @@ LDFLAGS_barebox	:= -Map barebox.map
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
+LDFLAGS_pbl += $(call ld-option, --no-dynamic-linker)
 
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
@@ -328,6 +329,7 @@ export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export CFLAGS CFLAGS_KERNEL
 export AFLAGS AFLAGS_KERNEL
 export LDFLAGS_barebox
+export LDFLAGS_pbl
 
 export CFLAGS_UBSAN
 
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 740b0790e..29fd8e276 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -140,6 +140,7 @@ CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += --gc-sections
+LDFLAGS_pbl += --gc-sections
 
 # early code often runs at addresses we are not linked at
 CPPFLAGS += -fPIE
@@ -150,6 +151,12 @@ else
 LDFLAGS_barebox += -static
 endif
 
+ifdef CONFIG_PBL_RELOCATABLE
+LDFLAGS_pbl += -pie
+else
+LDFLAGS_pbl += -static
+endif
+
 KBUILD_BINARY := barebox.bin
 
 barebox.s5p: $(KBUILD_BINARY)
diff --git a/images/Makefile b/images/Makefile
index 34b7a5610..650baf170 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -54,7 +54,7 @@ $(pbl-lds): $(obj)/../arch/$(ARCH)/lib/pbl.lds.S FORCE
 	$(call if_changed_dep,cpp_lds_S)
 
 quiet_cmd_elf__ ?= LD      $@
-      cmd_elf__ ?= $(LD) $(LDFLAGS_barebox) --gc-sections		\
+      cmd_elf__ ?= $(LD) $(LDFLAGS_pbl) --gc-sections		\
 		-e $(2) -Map $@.map $(LDFLAGS_$(@F)) -o $@		\
 		-T $(pbl-lds)						\
 		--start-group $(barebox-pbl-common) $(obj)/piggy.o	\
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-03  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27 13:30 [PATCH] images: Use separate LDFLAGS for PBL Christian Eggers
2020-02-03  7:51 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox