From 7982e79d3cc29489cfb3dbbf574ba23e9d5500c7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 17 Oct 2008 03:12:11 +0100 Subject: [PATCH] [build] Use ".bss.*" names for uninitialised-data sections The section name seems to have significance for some versions of binutils. There is no way to instruct gcc that sections such as .bss16 contain uninitialised data; it will emit them with contents explicitly set to zero. We therefore have to rely on the linker script to force these sections to become uninitialised-data sections. We do this by marking them as NOLOAD; this seems to be the closest semantic equivalent in the linker script language. However, this gets ignored by some versions of ld (including 2.17 as shipped with Debian Etch), which mark the resulting sections with (CONTENTS,ALLOC,LOAD,DATA). Combined with the fact that this version of ld seems to ignore the specified LMA for these sections, this means that they end up overlapping other sections, and so parts of .prefix (for example) get obliterated by .data16's bss section. Rename the .bss sections from .section_bss to .bss.section; this seems to cause these versions of ld to treat them as uninitialised data. --- src/arch/i386/scripts/efi.lds | 12 ++++++------ src/arch/i386/scripts/i386.lds | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/arch/i386/scripts/efi.lds b/src/arch/i386/scripts/efi.lds index 7d3281cc..357769e0 100644 --- a/src/arch/i386/scripts/efi.lds +++ b/src/arch/i386/scripts/efi.lds @@ -28,7 +28,7 @@ SECTIONS { *(.prefix) *(.prefix.*) _mprefix = .; - } .prefix_bss (NOLOAD) : { + } .bss.prefix (NOLOAD) : { _eprefix = .; } _prefix_filesz = ABSOLUTE ( _mprefix - _prefix ); @@ -45,7 +45,7 @@ SECTIONS { *(.text) *(.text.*) _mtext = .; - } .text_bss (NOLOAD) : { + } .bss.text (NOLOAD) : { _etext = .; } _text_filesz = ABSOLUTE ( _mtext - _text ); @@ -62,7 +62,7 @@ SECTIONS { *(.rodata) *(.rodata.*) _mrodata = .; - } .rodata_bss (NOLOAD) : { + } .bss.rodata (NOLOAD) : { _erodata = .; } _rodata_filesz = ABSOLUTE ( _mrodata - _rodata ); @@ -86,7 +86,7 @@ SECTIONS { *(.stack) *(.stack.*) _mdata = .; - } .data_bss (NOLOAD) : { + } .bss.data (NOLOAD) : { _edata = .; } _data_filesz = ABSOLUTE ( _mdata - _data ); @@ -102,7 +102,7 @@ SECTIONS { _bss = .; /* EFI seems to not support proper bss sections */ _mbss = .; - } .bss_bss (NOLOAD) : { + } .bss.bss (NOLOAD) : { _ebss = .; } _bss_filesz = ABSOLUTE ( _mbss - _bss ); @@ -121,7 +121,7 @@ SECTIONS { */ . += 1; _mreloc = .; - } .reloc_bss (NOLOAD) : { + } .bss.reloc (NOLOAD) : { _ereloc = .; } _reloc_filesz = ABSOLUTE ( _mreloc - _reloc ); diff --git a/src/arch/i386/scripts/i386.lds b/src/arch/i386/scripts/i386.lds index 575cb881..985a9b00 100644 --- a/src/arch/i386/scripts/i386.lds +++ b/src/arch/i386/scripts/i386.lds @@ -34,7 +34,7 @@ SECTIONS { *(.prefix) *(.prefix.*) _mprefix = .; - } .prefix_bss (NOLOAD) : AT ( _end_lma ) { + } .bss.prefix (NOLOAD) : AT ( _end_lma ) { _eprefix = .; } _prefix_filesz = ABSOLUTE ( _mprefix - _prefix ); @@ -52,7 +52,7 @@ SECTIONS { *(.text16) *(.text16.*) _mtext16 = .; - } .text16_bss (NOLOAD) : AT ( _end_lma ) { + } .bss.text16 (NOLOAD) : AT ( _end_lma ) { _etext16 = .; } _text16_filesz = ABSOLUTE ( _mtext16 - _text16 ); @@ -71,7 +71,7 @@ SECTIONS { *(.data16) *(.data16.*) _mdata16 = .; - } .data16_bss (NOLOAD) : AT ( _end_lma ) { + } .bss.data16 (NOLOAD) : AT ( _end_lma ) { *(.bss16) *(.bss16.*) *(.stack16) @@ -98,7 +98,7 @@ SECTIONS { *(.data.*) *(SORT(.tbl.*)) /* Various tables. See include/tables.h */ _mtextdata = .; - } .textdata_bss (NOLOAD) : AT ( _end_lma ) { + } .bss.textdata (NOLOAD) : AT ( _end_lma ) { *(.bss) *(.bss.*) *(COMMON) @@ -119,7 +119,7 @@ SECTIONS { *(.zinfo) *(.zinfo.*) _mzinfo = .; - } .zinfo_bss (NOLOAD) : AT ( _end_lma ) { + } .bss.zinfo (NOLOAD) : AT ( _end_lma ) { _ezinfo = .; } _zinfo_filesz = ABSOLUTE ( _mzinfo - _zinfo );