From d4b7d64b8186b2444b7b36c46501621cbe88362f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 27 Jul 2020 03:01:11 +0200 Subject: [PATCH] m68k: force fold segments into text, [ro]data & shave 100kB of ELF stuff For some reason the kernel ended up with a bunch of .text.foo or .data.rel.bar sections, each with their own ELF section headers and other metadata. Forcing them into the base sections drops the binary size by about 100kB, even for the stripped one. I suspect it should work on other archs as well. Change-Id: I7a8f46480d71267c07b75325423a0f5bfd2d12fb Reviewed-on: https://review.haiku-os.org/c/haiku/+/3101 Reviewed-by: Alex von Gluck IV --- src/system/ldscripts/m68k/kernel.ld | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/system/ldscripts/m68k/kernel.ld b/src/system/ldscripts/m68k/kernel.ld index 35cbc5a113..f172691932 100644 --- a/src/system/ldscripts/m68k/kernel.ld +++ b/src/system/ldscripts/m68k/kernel.ld @@ -43,28 +43,27 @@ SECTIONS .plt : { *(.plt) } /* text/read-only data */ - .text : { *(.text .gnu.linkonce.t.*) } :text =0x9090 - - .rodata : { *(.rodata) } + .text : { + *(.text .text.* .gnu.linkonce.t.*) *(.rodata .rodata.*) + } :text =0x9090 /* writable data */ . = ALIGN(0x1000); __data_start = .; - .data : { *(.data .gnu.linkonce.d.*) } :data + .data : { + . = ALIGN(0x4); + __ctor_list = .; + *(.ctors) + __ctor_end = .; + *(.data .data.* .gnu.linkonce.d.*) + *(.got.plt) *(.got) + } :data - . = ALIGN(0x4); - __ctor_list = .; - .ctors : { *(.ctors) } - __ctor_end = .; - __dtor_list = .; - .dtors : { *(.dtors) } - __dtor_end = .; - .got : { *(.got.plt) *(.got) } .dynamic : { *(.dynamic) } :dynamic :data /* uninitialized data (in same segment as writable data) */ __bss_start = .; - .bss : { *(.bss) } :data + .bss : { *(.bss .bss.*) } :data . = ALIGN(0x1000); _end = . ;