From 2b246d533496d50c8fba1a42882668484e5984ac Mon Sep 17 00:00:00 2001 From: Albert ARIBAUD Date: Tue, 11 Jun 2013 14:17:30 +0200 Subject: [PATCH] arm: ensure u-boot only uses relative relocations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a Makefile target ('checkarmreloc') which fails if the ELF binary contains relocation records of types other than R_ARM_RELATIVE. Signed-off-by: Albert ARIBAUD Tested-by: Lubomir Popov Tested-by: Jeroen Hofstee Reviewed-by: Benoît Thébaudeau --- Makefile | 7 +++++++ arch/arm/config.mk | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/Makefile b/Makefile index 8dd09a55ca..dcb70ffa98 100644 --- a/Makefile +++ b/Makefile @@ -728,6 +728,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 $< | cut -d ' ' -f 4 | grep R_ARM | sort -u`"; \ + then echo "$< 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 c43ebdd6f4..6479390b11 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -108,3 +108,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 -- 2.39.2