> that's weird. Actually I checked after each patch if the *_end symbols
> match the U-Boot binary size. Now I checked again with different
> toolchains (gcc-4.[5,6,7], binutils-2.[21.53,22] and I have again that
> binutils issue.
> 
> But all toolchains have one in common (tested with qemu_mips):
> __rel_dyn_end - __rel_dyn_start = 0x1770
> size from readelf = 0x15f8
> 
> Another problem is that your .deadcode workaround does not work
> anymore for me. It does not matter how I arrange or drop the unneeded
> sections, the size of .rel.dyn remains at 0x1770. I'll try to find
> another solution.

Erm, the presence of the .deadcode section does not change the size of the
.rel.dyn section.

The ELF headers shows that there is a gap between the .rel.dyn and the .deadcode
section:

  [ 6] .rel.dyn          REL             bfc30804 030864 0015f8 08   A  8   0  4
  [ 7] .deadcode         PROGBITS        bfc31f74 031fd4 000004 00  WA  0   0  1

However objcopy will copy the .deadcode section into the final binary because it
is placed after the .rel.dyn section, and the gap will be filled with 0xff 
bytes.

As a result, the size of u-boot.bin will equal to (__rel_dyn_end - __start + 4),
and this ensures that it will contain the full .rel.dyn section.

$ ls -l u-boot.bin
-rw-r--r-- 1 juhosg root 204664 Feb 11 14:46 u-boot.bin

This is with the attached patch applied on top of the mips/reloc branch.

-Gabor

>From 07bbc17f35a78bbace7d91477643497f8b51cc0c Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juh...@openwrt.org>
Date: Mon, 11 Feb 2013 15:06:17 +0100
Subject: [PATCH] MIPS: u-boot.lds: add back the .deadcode section

---
 arch/mips/cpu/u-boot.lds |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/mips/cpu/u-boot.lds b/arch/mips/cpu/u-boot.lds
index cea9533..10513ab 100644
--- a/arch/mips/cpu/u-boot.lds
+++ b/arch/mips/cpu/u-boot.lds
@@ -76,6 +76,24 @@ SECTIONS
 		__rel_dyn_end = .;
 	}
 
+	.deadcode : {
+		/*
+		 * Workaround for a binutils feature (or bug?).
+		 *
+		 * The GNU ld from binutils puts the dynamic relocation
+		 * entries into the .rel.dyn section. Sometimes it
+		 * allocates more dynamic relocation entries than it needs
+		 * and the unused slots are set to R_MIPS_NONE entries.
+		 *
+		 * However the size of the .rel.dyn section in the ELF
+		 * section header does not cover the unused entries, so
+		 * objcopy removes those during stripping.
+		 *
+		 * Create a small section here to avoid that.
+		 */
+		LONG(0xffffffff);
+	}
+
 	.dynsym : {
 		*(.dynsym)
 	}
-- 
1.7.10

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to