* [U-Boot] [PATCH] MIPS: keep all sections in u-boot ELF binary.
@ 2014-02-14 16:03 Daniel Schwierzeck
0 siblings, 0 replies; only message in thread
From: Daniel Schwierzeck @ 2014-02-14 16:03 UTC (permalink / raw)
To: u-boot
The current MIPS linker script discards all unneeded sections in the
link stage. For diagnostic tools like readelf it is better to keep all sections
in the ELF binary and only remove them when creating the final binary.
Move all unneeded sections after _end to avoid allocating space in the final
binary. Also remove .deadcode section which is now obsolete.
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
---
This patch is inspired by a similar one for ARM [1]. This patch is queued at
u-boot-mips/testing together with a test patch. This test patch adds a script
for testing for the "wrong __rel_dyn_end offset" bug, which could occur without
the .deadcode section.
[1] http://patchwork.ozlabs.org/patch/289329/
---
arch/mips/config.mk | 3 ++-
arch/mips/cpu/u-boot.lds | 56 ++++++++++++++++++++++++++----------------------
2 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index c3f81b5..ce438c2 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -50,4 +50,5 @@ PLATFORM_CPPFLAGS += -msoft-float
PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib $(ENDIANNESS)
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
LDFLAGS_FINAL += --gc-sections -pie
-OBJCFLAGS += --remove-section=.dynsym
+OBJCFLAGS += -j .text -j .rodata -j .data -j .got
+OBJCFLAGS += -j .u_boot_list -j .rel.dyn
diff --git a/arch/mips/cpu/u-boot.lds b/arch/mips/cpu/u-boot.lds
index 16a9d6a..4c9edf8 100644
--- a/arch/mips/cpu/u-boot.lds
+++ b/arch/mips/cpu/u-boot.lds
@@ -60,27 +60,7 @@ 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)
- }
+ _end = .;
.bss __rel_dyn_start (OVERLAY) : {
__bss_start = .;
@@ -91,15 +71,39 @@ SECTIONS
__bss_end = .;
}
- /DISCARD/ : {
+ .dynsym _end : {
+ *(.dynsym)
+ }
+
+ .dynbss : {
*(.dynbss)
+ }
+
+ .dynstr : {
*(.dynstr)
+ }
+
+ .dynamic : {
*(.dynamic)
+ }
+
+ .plt : {
+ *(.plt)
+ }
+
+ .interp : {
*(.interp)
+ }
+
+ .gnu : {
+ *(.gnu*)
+ }
+
+ .MIPS.stubs : {
+ *(.MIPS.stubs)
+ }
+
+ .hash : {
*(.hash)
- *(.gnu.*)
- *(.plt)
- *(.got.plt)
- *(.rel.plt)
}
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-14 16:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 16:03 [U-Boot] [PATCH] MIPS: keep all sections in u-boot ELF binary Daniel Schwierzeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.