Skip to contentSkip to conversation

ARM: do not specify -static and -pie at the same time

PATCH Applied Lucas Stach 2 participants 2 messages Mar 1, 2015 – Mar 2, 2015 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: do not specify -static and -pie at the same time

PIE is a form of dynamic linking and thus inherently incompatible with -static. It worked ok as the current behavior of ld.bfd is to not respect -static if -pie has been specified.

ld.gold and future versions of ld.bfd will fail to link if both of those incompatible switches are specified at the same time.

---
 arch/arm/Makefile     | 4 +++-
 arch/arm/pbl/Makefile | 5 +++--
 images/Makefile       | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)
arch/arm/Makefile +3 -1
index f0133d4..b3abcae 100644
@@ -105,10 +105,12 @@ CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
-LDFLAGS_barebox += -static --gc-sections
+LDFLAGS_barebox += --gc-sections
 
 ifdef CONFIG_RELOCATABLE
 LDFLAGS_barebox += -pie
+else
+LDFLAGS_barebox += -static
 endif
 
 ifdef CONFIG_IMAGE_COMPRESSION
arch/arm/pbl/Makefile +3 -2
index 1b90b37..4c1788d 100644
@@ -31,10 +31,11 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE
 	$(call if_changed,disasm)
 
 PBL_CPPFLAGS		+= -fdata-sections -ffunction-sections
-LDFLAGS_zbarebox	:= -Map $(obj)/zbarebox.map
-LDFLAGS_zbarebox	+= -static --gc-sections
+LDFLAGS_zbarebox	:= -Map $(obj)/zbarebox.map --gc-sections
 ifdef CONFIG_PBL_RELOCATABLE
 LDFLAGS_zbarebox += -pie
+else
+LDFLAGS_zbarebox += -static
 endif
 zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o)
 zbarebox-lds := $(obj)/zbarebox.lds
images/Makefile +1 -1
index 7c3aaf7..f7e978c 100644
@@ -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) -static --gc-sections -pie		\
+      cmd_elf__ ?= $(LD) $(LDFLAGS) --gc-sections -pie			\
 		-e $(2) -Map [email protected] $(LDFLAGS_$(@F)) -o $@		\
 		-T $(pbl-lds)						\
 		--start-group $(barebox-pbl-common) --end-group
Signature · 7 lines
2.1.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 8 lines · Lucas Stach

PIE is a form of dynamic linking and thus inherently incompatible with -static. It worked ok as the current behavior of ld.bfd is to not respect -static if -pie has been specified.

ld.gold and future versions of ld.bfd will fail to link if both of those incompatible switches are specified at the same time.

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox