[U-Boot] [PATCH 4/5] arm: ensure u-boot only uses relative relocations

Albert ARIBAUD albert.u.boot at aribaud.net
Tue May 14 22:02:59 CEST 2013


Add a Makefile target ('checkarmreloc') which
fails of the ELF binary contains relocation records
of types other than R_ARM_RELATIVE.

Signed-off-by: Albert ARIBAUD <albert.u.boot at aribaud.net>
---
 Makefile           |    7 +++++++
 arch/arm/config.mk |    5 +++++
 2 files changed, 12 insertions(+)

diff --git a/Makefile b/Makefile
index c52f0f1..9aa5755 100644
--- a/Makefile
+++ b/Makefile
@@ -746,6 +746,13 @@ tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
 	$(MAKE) -C $@ all
 endif	# config.mk
 
+# ARM relocations should all be R_ARM_RELATIVE.
+checkarmreloc: $(obj)u-boot
+	@if test "R_ARM_RELATIVE" != \
+		"`readelf -r $(obj)u-boot | cut -d ' ' -f 4 | grep R_ARM | sort -u`"; \
+		then echo "$(obj)u-boot contains relocations other than \
+		R_ARM_RELATIVE"; false; fi
+
 $(VERSION_FILE):
 		@mkdir -p $(dir $(VERSION_FILE))
 		@( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 461899e..5b7a602 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -106,3 +106,8 @@ ifeq ($(GAS_BUG_12532),y)
 PLATFORM_RELFLAGS += -fno-optimize-sibling-calls
 endif
 endif
+
+# check that only R_ARM_RELATIVE relocations are generated
+ifneq ($(CONFIG_SPL_BUILD),y)
+ALL-y	+= checkarmreloc
+endif
-- 
1.7.10.4



More information about the U-Boot mailing list