Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
Michael Brown committed Oct 17, 2008
1 parent 04f3206 commit 7982e79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/arch/i386/scripts/efi.lds
Expand Up @@ -28,7 +28,7 @@ SECTIONS {
*(.prefix)
*(.prefix.*)
_mprefix = .;
} .prefix_bss (NOLOAD) : {
} .bss.prefix (NOLOAD) : {
_eprefix = .;
}
_prefix_filesz = ABSOLUTE ( _mprefix - _prefix );
Expand All @@ -45,7 +45,7 @@ SECTIONS {
*(.text)
*(.text.*)
_mtext = .;
} .text_bss (NOLOAD) : {
} .bss.text (NOLOAD) : {
_etext = .;
}
_text_filesz = ABSOLUTE ( _mtext - _text );
Expand All @@ -62,7 +62,7 @@ SECTIONS {
*(.rodata)
*(.rodata.*)
_mrodata = .;
} .rodata_bss (NOLOAD) : {
} .bss.rodata (NOLOAD) : {
_erodata = .;
}
_rodata_filesz = ABSOLUTE ( _mrodata - _rodata );
Expand All @@ -86,7 +86,7 @@ SECTIONS {
*(.stack)
*(.stack.*)
_mdata = .;
} .data_bss (NOLOAD) : {
} .bss.data (NOLOAD) : {
_edata = .;
}
_data_filesz = ABSOLUTE ( _mdata - _data );
Expand All @@ -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 );
Expand All @@ -121,7 +121,7 @@ SECTIONS {
*/
. += 1;
_mreloc = .;
} .reloc_bss (NOLOAD) : {
} .bss.reloc (NOLOAD) : {
_ereloc = .;
}
_reloc_filesz = ABSOLUTE ( _mreloc - _reloc );
Expand Down
10 changes: 5 additions & 5 deletions src/arch/i386/scripts/i386.lds
Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -71,7 +71,7 @@ SECTIONS {
*(.data16)
*(.data16.*)
_mdata16 = .;
} .data16_bss (NOLOAD) : AT ( _end_lma ) {
} .bss.data16 (NOLOAD) : AT ( _end_lma ) {
*(.bss16)
*(.bss16.*)
*(.stack16)
Expand All @@ -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)
Expand All @@ -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 );
Expand Down

0 comments on commit 7982e79

Please sign in to comment.