From de25059404b630012eef050532a3f73f47c567c5 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:18 +1100 Subject: x86: Use TEXT_BASE in linker scripts Use TEXT_BASE rather than a hard-coded base address on x86 linker scripts. This will allow any board to define its base link address without having to modify the linker script --- board/eNET/u-boot.lds | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'board') diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds index 7b0ffaa..d78d75f 100644 --- a/board/eNET/u-boot.lds +++ b/board/eNET/u-boot.lds @@ -27,7 +27,7 @@ ENTRY(_start) SECTIONS { - . = 0x06000000; /* Location of bootcode in flash */ + . = TEXT_BASE; /* Location of bootcode in flash */ _i386boot_text_start = .; .text : { *(.text); } @@ -98,12 +98,12 @@ SECTIONS * The fff0 offset of resetvec is important, however. */ . = 0xfffffe00; - .start32 : AT (0x0603fe00) { *(.start32); } + .start32 : AT (TEXT_BASE + 0x3fe00) { *(.start32); } . = 0xf800; - .start16 : AT (0x0603f800) { *(.start16); } + .start16 : AT (TEXT_BASE + 0x3f800) { *(.start16); } . = 0xfff0; - .resetvec : AT (0x0603fff0) { *(.resetvec); } + .resetvec : AT (TEXT_BASE + 0x3fff0) { *(.resetvec); } _i386boot_end = (LOADADDR(.resetvec) + SIZEOF(.resetvec) ); } -- cgit v1.1 From d664adb6bb7243fc9be1cb242a18a76901bc5c3a Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:20 +1100 Subject: x86: use gc sections to reduce image size Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size. --- board/eNET/u-boot.lds | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'board') diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds index d78d75f..7b211a8 100644 --- a/board/eNET/u-boot.lds +++ b/board/eNET/u-boot.lds @@ -77,13 +77,13 @@ SECTIONS _i386boot_bss_size = SIZEOF(.bss); /* 16bit realmode trampoline code */ - .realmode 0x7c0 : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { *(.realmode) } + .realmode 0x7c0 : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) } _i386boot_realmode = LOADADDR(.realmode); _i386boot_realmode_size = SIZEOF(.realmode); /* 16bit BIOS emulation code (just enough to boot Linux) */ - .bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { *(.bios) } + .bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { KEEP(*(.bios)) } _i386boot_bios = LOADADDR(.bios); _i386boot_bios_size = SIZEOF(.bios); @@ -98,12 +98,12 @@ SECTIONS * The fff0 offset of resetvec is important, however. */ . = 0xfffffe00; - .start32 : AT (TEXT_BASE + 0x3fe00) { *(.start32); } + .start32 : AT (TEXT_BASE + 0x3fe00) { KEEP(*(.start32)); } . = 0xf800; - .start16 : AT (TEXT_BASE + 0x3f800) { *(.start16); } + .start16 : AT (TEXT_BASE + 0x3f800) { KEEP(*(.start16)); } . = 0xfff0; - .resetvec : AT (TEXT_BASE + 0x3fff0) { *(.resetvec); } + .resetvec : AT (TEXT_BASE + 0x3fff0) { KEEP(*(.resetvec)); } _i386boot_end = (LOADADDR(.resetvec) + SIZEOF(.resetvec) ); } -- cgit v1.1 From 6ae032a86aa21def97aada054bd24589fdb8e947 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:24 +1100 Subject: x86: Remove progress indication in low-level init Progress indication is not relocation friendly so remove it in preperation for full relocatability support --- board/eNET/eNET_start.S | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'board') diff --git a/board/eNET/eNET_start.S b/board/eNET/eNET_start.S index 1b07d62..6659549 100644 --- a/board/eNET/eNET_start.S +++ b/board/eNET/eNET_start.S @@ -29,18 +29,6 @@ early_board_init: /* No 32-bit board specific initialisation */ jmp *%ebp /* return to caller */ -.globl show_boot_progress_asm -show_boot_progress_asm: - - movb %al, %dl /* Create Working Copy */ - andb $0x80, %dl /* Mask in only Error bit */ - shrb $0x02, %dl /* Shift Error bit to Error LED */ - andb $0x0f, %al /* Mask out 'Error' bit */ - orb %dl, %al /* Mask in ERR LED */ - movw $LED_LATCH_ADDRESS, %dx - outb %al, %dx - jmp *%ebp /* return to caller */ - .globl cpu_halt_asm cpu_halt_asm: movb $0x0f, %al -- cgit v1.1 From 88fa0a6eb906b532cd073b6e3d8f688c47404709 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:27 +1100 Subject: x86: Remove usage of %ebp as a return pointer Using %ebp as a return pointer prevents creating 'load anywhere' images --- board/eNET/eNET_start.S | 2 +- board/eNET/eNET_start16.S | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'board') diff --git a/board/eNET/eNET_start.S b/board/eNET/eNET_start.S index 6659549..137fe41 100644 --- a/board/eNET/eNET_start.S +++ b/board/eNET/eNET_start.S @@ -27,7 +27,7 @@ .globl early_board_init early_board_init: /* No 32-bit board specific initialisation */ - jmp *%ebp /* return to caller */ + jmp early_board_init_ret .globl cpu_halt_asm cpu_halt_asm: diff --git a/board/eNET/eNET_start16.S b/board/eNET/eNET_start16.S index af2c132..06cfd55 100644 --- a/board/eNET/eNET_start16.S +++ b/board/eNET/eNET_start16.S @@ -65,8 +65,7 @@ board_init16: movl $0x000000cb, %eax outl %eax, %dx - /* the return address is stored in bp */ - jmp *%bp + jmp board_init16_ret .section .bios, "ax" .code16 -- cgit v1.1 From 067f9b10710e4edee97a9220b2ea8841c646368b Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:31 +1100 Subject: x86: Rename linker script symbols Create more generic names for the symbols exported from the linker script --- board/eNET/u-boot.lds | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'board') diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds index 7b211a8..ef5d941 100644 --- a/board/eNET/u-boot.lds +++ b/board/eNET/u-boot.lds @@ -28,13 +28,12 @@ ENTRY(_start) SECTIONS { . = TEXT_BASE; /* Location of bootcode in flash */ - _i386boot_text_start = .; + __text_start = .; .text : { *(.text); } . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } - _i386boot_text_size = SIZEOF(.text) + SIZEOF(.rodata); . = ALIGN(4); .data : { *(.data) } @@ -65,28 +64,27 @@ SECTIONS .u_boot_cmd : { *(.u_boot_cmd) } . = ALIGN(4); __u_boot_cmd_end = .; - _i386boot_cmd_start = LOADADDR(.u_boot_cmd); - _i386boot_rel_dyn_start = .; + __rel_dyn_start = .; .rel.dyn : { *(.rel.dyn) } - _i386boot_rel_dyn_end = .; + __rel_dyn_end = .; . = ALIGN(4); - _i386boot_bss_start = ABSOLUTE(.); + __bss_start = ABSOLUTE(.); .bss (NOLOAD) : { *(.bss) } - _i386boot_bss_size = SIZEOF(.bss); + __bss_size = SIZEOF(.bss); /* 16bit realmode trampoline code */ .realmode 0x7c0 : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) } - _i386boot_realmode = LOADADDR(.realmode); - _i386boot_realmode_size = SIZEOF(.realmode); + __realmode_start = LOADADDR(.realmode); + __realmode_size = SIZEOF(.realmode); /* 16bit BIOS emulation code (just enough to boot Linux) */ .bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { KEEP(*(.bios)) } - _i386boot_bios = LOADADDR(.bios); - _i386boot_bios_size = SIZEOF(.bios); + __bios_start = LOADADDR(.bios); + __bios_size = SIZEOF(.bios); /* The load addresses below assumes that the flash * will be mapped so that 0x387f0000 == 0xffff0000 @@ -105,5 +103,4 @@ SECTIONS . = 0xfff0; .resetvec : AT (TEXT_BASE + 0x3fff0) { KEEP(*(.resetvec)); } - _i386boot_end = (LOADADDR(.resetvec) + SIZEOF(.resetvec) ); } -- cgit v1.1 From 221914265860a47a0ba8bfa6956097cb045d9b39 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:32 +1100 Subject: x86: Rearrange linker script Tidy up the linker script and discard some sections to save space --- board/eNET/u-boot.lds | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'board') 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)) } -- cgit v1.1 From f2ff75c0a25eb78b4b86fd96c5f0be9dd327e2d7 Mon Sep 17 00:00:00 2001 From: Graeme Russ Date: Thu, 7 Oct 2010 20:03:33 +1100 Subject: x86: Use loops instead of memcpy/memset in board_init_f Provides a small speed increase and prepares for fully relocatable image. Downside is the TEXT_BASE, bss, load address etc must ALL be aligned on a a 4-byte boundary which is not such a terrible restriction as everything is already 4-byte aligned anyway --- board/eNET/u-boot.lds | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'board') diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds index 3c52010..b414079b 100644 --- a/board/eNET/u-boot.lds +++ b/board/eNET/u-boot.lds @@ -58,7 +58,8 @@ SECTIONS . = ALIGN(4); __bss_start = ABSOLUTE(.); .bss (NOLOAD) : { *(.bss) } - __bss_size = SIZEOF(.bss); + . = ALIGN(4); + __bss_end = ABSOLUTE(.); . = ALIGN(4); __rel_dyn_start = .; -- cgit v1.1