diff options
| author | Michael Brown | 2011-02-22 20:36:24 +0100 |
|---|---|---|
| committer | Michael Brown | 2011-02-22 22:02:00 +0100 |
| commit | 623469de5d307ee6d762ad30988ffbfbc53741b6 (patch) | |
| tree | c30f937ccd76d6b1f824a126afd331590dda7e32 /src/arch | |
| parent | [int13] Add missing "static" modifier (diff) | |
| download | ipxe-623469de5d307ee6d762ad30988ffbfbc53741b6.tar.gz ipxe-623469de5d307ee6d762ad30988ffbfbc53741b6.tar.xz ipxe-623469de5d307ee6d762ad30988ffbfbc53741b6.zip | |
[build] Eliminate unused sections at link-time
Use -ffunction-sections, -fdata-sections, and --gc-sections to
automatically prune out any unreferenced sections.
This saves around 744 bytes (uncompressed) from the rtl8139.rom build.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/i386/scripts/i386-kir.lds | 8 | ||||
| -rw-r--r-- | src/arch/i386/scripts/i386.lds | 14 | ||||
| -rw-r--r-- | src/arch/i386/scripts/linux.lds | 4 | ||||
| -rw-r--r-- | src/arch/x86/scripts/efi.lds | 4 | ||||
| -rw-r--r-- | src/arch/x86_64/scripts/linux.lds | 4 |
5 files changed, 24 insertions, 10 deletions
diff --git a/src/arch/i386/scripts/i386-kir.lds b/src/arch/i386/scripts/i386-kir.lds index c19480f03..620bc2fe3 100644 --- a/src/arch/i386/scripts/i386-kir.lds +++ b/src/arch/i386/scripts/i386-kir.lds @@ -68,7 +68,8 @@ SECTIONS { .text16 : AT ( _text16_load_offset + __text16 ) { __text16 = .; - *(.text.null_trap) + KEEP(*(.text.null_trap)) + KEEP(*(.text.null_trap.*)) *(.text16) *(.text16.*) *(.text) @@ -97,7 +98,7 @@ SECTIONS { *(.data16.*) *(.data) *(.data.*) - *(SORT(.tbl.*)) /* Various tables. See include/tables.h */ + KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */ _edata16_progbits = .; } .bss16 : AT ( _data16_load_offset + __bss16 ) { @@ -129,8 +130,11 @@ SECTIONS { /DISCARD/ : { *(.comment) + *(.comment.*) *(.note) + *(.note.*) *(.discard) + *(.discard.*) } /* diff --git a/src/arch/i386/scripts/i386.lds b/src/arch/i386/scripts/i386.lds index 610bfa16b..c5bc631fa 100644 --- a/src/arch/i386/scripts/i386.lds +++ b/src/arch/i386/scripts/i386.lds @@ -49,7 +49,8 @@ SECTIONS { .text16.early 0x0 : AT ( _text16_early_lma ) { _text16 = .; - *(.text16.null) + KEEP(*(.text16.null)) + KEEP(*(.text16.null.*)) . += 1; /* Prevent NULL being valid */ *(.text16.early) *(.text16.early.*) @@ -98,7 +99,8 @@ SECTIONS { .textdata 0x0 : AT ( _textdata_lma ) { _textdata = .; - *(.text.null_trap) + KEEP(*(.text.null_trap)) + KEEP(*(.text.null_trap.*)) . += 1; /* Prevent NULL being valid */ *(.text) *(.text.*) @@ -106,7 +108,7 @@ SECTIONS { *(.rodata.*) *(.data) *(.data.*) - *(SORT(.tbl.*)) /* Various tables. See include/tables.h */ + KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */ _mtextdata = .; } .bss.textdata (NOLOAD) : AT ( _end_lma ) { *(.bss) @@ -126,8 +128,8 @@ SECTIONS { .zinfo 0x0 : AT ( _zinfo_lma ) { _zinfo = .; - *(.zinfo) - *(.zinfo.*) + KEEP(*(.zinfo)) + KEEP(*(.zinfo.*)) _mzinfo = .; } .bss.zinfo (NOLOAD) : AT ( _end_lma ) { _ezinfo = .; @@ -143,6 +145,7 @@ SECTIONS { .weak 0x0 : AT ( _end_lma ) { _weak = .; *(.weak) + *(.weak.*) _eweak = .; } _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" ); @@ -165,6 +168,7 @@ SECTIONS { *(.einfo) *(.einfo.*) *(.discard) + *(.discard.*) } /* diff --git a/src/arch/i386/scripts/linux.lds b/src/arch/i386/scripts/linux.lds index 94b7b900e..654f68e30 100644 --- a/src/arch/i386/scripts/linux.lds +++ b/src/arch/i386/scripts/linux.lds @@ -51,7 +51,7 @@ SECTIONS { _data = .; *(.data) *(.data.*) - *(SORT(.tbl.*)) /* Various tables. See include/tables.h */ + KEEP(*(SORT(.tbl.*))) _edata = .; } @@ -77,6 +77,7 @@ SECTIONS { .weak 0x0 : { _weak = .; *(.weak) + *(.weak.*) _eweak = .; } _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" ); @@ -97,5 +98,6 @@ SECTIONS { *(.rel) *(.rel.*) *(.discard) + *(.discard.*) } } diff --git a/src/arch/x86/scripts/efi.lds b/src/arch/x86/scripts/efi.lds index d9963ef3b..1a16c29bd 100644 --- a/src/arch/x86/scripts/efi.lds +++ b/src/arch/x86/scripts/efi.lds @@ -54,7 +54,7 @@ SECTIONS { _data = .; *(.data) *(.data.*) - *(SORT(.tbl.*)) /* Various tables. See include/tables.h */ + KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */ _edata = .; } @@ -80,6 +80,7 @@ SECTIONS { .weak 0x0 : { _weak = .; *(.weak) + *(.weak.*) _eweak = .; } _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" ); @@ -102,5 +103,6 @@ SECTIONS { *(.einfo) *(.einfo.*) *(.discard) + *(.discard.*) } } diff --git a/src/arch/x86_64/scripts/linux.lds b/src/arch/x86_64/scripts/linux.lds index 34eb3561b..3bcd7aa1b 100644 --- a/src/arch/x86_64/scripts/linux.lds +++ b/src/arch/x86_64/scripts/linux.lds @@ -51,7 +51,7 @@ SECTIONS { _data = .; *(.data) *(.data.*) - *(SORT(.tbl.*)) /* Various tables. See include/tables.h */ + KEEP(*(SORT(.tbl.*))) _edata = .; } @@ -77,6 +77,7 @@ SECTIONS { .weak 0x0 : { _weak = .; *(.weak) + *(.weak.*) _eweak = .; } _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" ); @@ -97,5 +98,6 @@ SECTIONS { *(.rel) *(.rel.*) *(.discard) + *(.discard.*) } } |
