diff mbox

[U-Boot,v2,1/6] arm: ensure u-boot only uses relative relocations

Message ID 1369724512-4047-2-git-send-email-albert.u.boot@aribaud.net
State Superseded
Delegated to: Albert ARIBAUD
Headers show

Commit Message

Albert ARIBAUD May 28, 2013, 7:01 a.m. UTC
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@aribaud.net>
---
Changes in v2:
- use $< instead of $(obj)u-boot

 Makefile           |    7 +++++++
 arch/arm/config.mk |    5 +++++
 2 files changed, 12 insertions(+)

Comments

Benoît Thébaudeau May 28, 2013, 5:04 p.m. UTC | #1
Hi Albert,

On Tuesday, May 28, 2013 9:01:46 AM, Albert ARIBAUD wrote:
> Add a Makefile target ('checkarmreloc') which
> fails of the ELF binary contains relocation records
        ^
        if

Sorry to have missed that in my review of v1.

> of types other than R_ARM_RELATIVE.

The rest of the patch is OK.

Best regards,
Benoît
Albert ARIBAUD May 28, 2013, 5:31 p.m. UTC | #2
Hi Benoît,

On Tue, 28 May 2013 19:04:23 +0200 (CEST), Benoît Thébaudeau
<benoit.thebaudeau@advansee.com> wrote:

> Hi Albert,
> 
> On Tuesday, May 28, 2013 9:01:46 AM, Albert ARIBAUD wrote:
> > Add a Makefile target ('checkarmreloc') which
> > fails of the ELF binary contains relocation records
>         ^
>         if

(and)

> > Also, __image_copy_end needs its own section; putting
> > it in relocation sections changes their flags and makes
> > relocation breaks.
>              ^
>              break

> Sorry to have missed that in my review of v1.

Never mind: I'd missed them too. :)

I'll wait a bit for other comments if any, then send out a fixed V3.

> Best regards,
> Benoît

Amicalement,
diff mbox

Patch

diff --git a/Makefile b/Makefile
index c52f0f1..70b5183 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 $< | 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 dc64160..e80e1ed 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -109,3 +109,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