Patchwork [U-Boot,RFC,1/3] MIPS: add .dyn.rel section to u-boot.lds

login
register
mail settings
Submitter Gabor Juhos
Date Feb. 3, 2013, 9:26 a.m.
Message ID <1359883582-1551-2-git-send-email-juhosg@openwrt.org>
Download mbox | patch
Permalink /patch/217731/
State Superseded
Delegated to: Daniel Schwierzeck
Headers show

Comments

Gabor Juhos - Feb. 3, 2013, 9:26 a.m.
This section contain the table needed for dynamic
relocation. Also provide symbols for the relocation
code to access the table.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
 arch/mips/cpu/u-boot.lds |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Patch

diff --git a/arch/mips/cpu/u-boot.lds b/arch/mips/cpu/u-boot.lds
index 58a49b2..3d9d82a 100644
--- a/arch/mips/cpu/u-boot.lds
+++ b/arch/mips/cpu/u-boot.lds
@@ -70,11 +70,36 @@  SECTIONS
 	uboot_end_data = .;
 
 	. = ALIGN(4);
+	.rel.dyn : {
+		__rel_dyn_start = .;
+		*(.rel*)
+		__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);
+	}
+
+	. = ALIGN(4);
 	.sbss : {
 		*(.sbss*)
 	}
 
-	.bss : {
+	.bss __rel_dyn_start (OVERLAY) : {
 		*(.bss*)
 		. = ALIGN(4);
 	}