From: Christian Eggers <ceggers@arri.de>
To: barebox@lists.infradead.org
Cc: Christian Eggers <ceggers@arri.de>, ceggers@gmx.de
Subject: [PATCH] images: Use separate LDFLAGS for PBL
Date: Mon, 27 Jan 2020 14:30:43 +0100 [thread overview]
Message-ID: <20200127133043.8012-1-ceggers@arri.de> (raw)
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
next reply other threads:[~2020-01-27 13:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-27 13:30 Christian Eggers [this message]
2020-02-03 7:51 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200127133043.8012-1-ceggers@arri.de \
--to=ceggers@arri.de \
--cc=barebox@lists.infradead.org \
--cc=ceggers@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox