[U-Boot] [PATCH 17/19] x86: Rearrange linker script

Graeme Russ graeme.russ at gmail.com
Mon Oct 4 05:38:01 CEST 2010


Tidy up the linker script and discard some sections to save space

Signed-off-by: Graeme Russ <graeme.russ at gmail.com>
---
 arch/i386/lib/board.c |    5 +++--
 board/eNET/u-boot.lds |   39 ++++++++++++++++++---------------------
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/arch/i386/lib/board.c b/arch/i386/lib/board.c
index e7a363d..3e89ef4 100644
--- a/arch/i386/lib/board.c
+++ b/arch/i386/lib/board.c
@@ -49,6 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* Exports from the Linker Script */
 extern ulong __text_start;
+extern ulong __data_end;
 extern ulong __rel_dyn_start;
 extern ulong __rel_dyn_end;
 extern ulong __bss_start;
@@ -170,7 +171,7 @@ gd_t *gd;
 void board_init_f (ulong gdp)
 {
 	void *text_start = &__text_start;
-	void *u_boot_cmd_end = &__u_boot_cmd_end;
+	void *data_end = &__data_end;
 	Elf32_Rel *rel_dyn_start = (Elf32_Rel *)&__rel_dyn_start;
 	Elf32_Rel *rel_dyn_end = (Elf32_Rel *)&__rel_dyn_end;
 	void *bss_start = &__bss_start;
@@ -181,7 +182,7 @@ void board_init_f (ulong gdp)
 	ulong rel_offset;
 	Elf32_Rel *re;
 
-	uboot_size = (ulong)u_boot_cmd_end - (ulong)text_start;
+	uboot_size = (ulong)data_end - (ulong)text_start;
 	dest_addr  = (void *)gdp - (uboot_size + (ulong)bss_size);
 	rel_offset = text_start - dest_addr;
 
diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds
index ef5d941..3c52010 100644
--- a/board/eNET/u-boot.lds
+++ b/board/eNET/u-boot.lds
@@ -29,50 +29,47 @@ SECTIONS
 {
 	. = TEXT_BASE;		/* Location of bootcode in flash */
 	__text_start = .;
-	.text  : { *(.text); }
+	.text  : { *(.text*); }
 
 	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
-	. = ALIGN(4);
-
-	.data : { *(.data) }
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
 	. = ALIGN(4);
+	__u_boot_cmd_end = .;
 
-	.interp : { *(.interp) }
 	. = ALIGN(4);
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
-	.dynsym : { *(.dynsym) }
 	. = ALIGN(4);
+	.data : { *(.data*) }
 
-	.dynstr : { *(.dynstr) }
 	. = ALIGN(4);
+	.dynsym : { *(.dynsym*) }
 
-	.hash : { *(.hash) }
 	. = ALIGN(4);
+	.hash : { *(.hash*) }
 
-	.got : { *(.got) }
 	. = ALIGN(4);
+	.got : { *(.got*) }
 
-	.got.plt : { *(.got.plt) }
 	. = ALIGN(4);
+	__data_end = .;
 
-	.dynamic (NOLOAD) : { *(.dynamic) }
 	. = ALIGN(4);
+	__bss_start = ABSOLUTE(.);
+	.bss (NOLOAD) : { *(.bss) }
+	__bss_size = SIZEOF(.bss);
 
-	__u_boot_cmd_start = .;
-	.u_boot_cmd : { *(.u_boot_cmd) }
 	. = ALIGN(4);
-	__u_boot_cmd_end = .;
-
 	__rel_dyn_start = .;
 	.rel.dyn : { *(.rel.dyn) }
 	__rel_dyn_end = .;
 
-	. = ALIGN(4);
-	__bss_start = ABSOLUTE(.);
-	.bss (NOLOAD) : { *(.bss) }
-	__bss_size = SIZEOF(.bss);
+	/DISCARD/ : { *(.dynstr*) }
+	/DISCARD/ : { *(.dynamic*) }
+	/DISCARD/ : { *(.plt*) }
+	/DISCARD/ : { *(.interp*) }
+	/DISCARD/ : { *(.gnu*) }
 
 	/* 16bit realmode trampoline code */
 	.realmode 0x7c0 : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) }
-- 
1.7.1.422.g049e9



More information about the U-Boot mailing list