Browse Source

[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.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
7982e79d3c
2 changed files with 11 additions and 11 deletions
  1. 6
    6
      src/arch/i386/scripts/efi.lds
  2. 5
    5
      src/arch/i386/scripts/i386.lds

+ 6
- 6
src/arch/i386/scripts/efi.lds View File

28
 	*(.prefix)
28
 	*(.prefix)
29
 	*(.prefix.*)
29
 	*(.prefix.*)
30
 	_mprefix = .;
30
 	_mprefix = .;
31
-    } .prefix_bss (NOLOAD) : {
31
+    } .bss.prefix (NOLOAD) : {
32
 	_eprefix = .;
32
 	_eprefix = .;
33
     }
33
     }
34
     _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
34
     _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
45
 	*(.text)
45
 	*(.text)
46
 	*(.text.*)
46
 	*(.text.*)
47
 	_mtext = .;
47
 	_mtext = .;
48
-    } .text_bss (NOLOAD) : {
48
+    } .bss.text (NOLOAD) : {
49
 	_etext = .;
49
 	_etext = .;
50
     }
50
     }
51
     _text_filesz	= ABSOLUTE ( _mtext - _text );
51
     _text_filesz	= ABSOLUTE ( _mtext - _text );
62
 	*(.rodata)
62
 	*(.rodata)
63
 	*(.rodata.*)
63
 	*(.rodata.*)
64
 	_mrodata = .;
64
 	_mrodata = .;
65
-    } .rodata_bss (NOLOAD) : {
65
+    } .bss.rodata (NOLOAD) : {
66
 	_erodata = .;
66
 	_erodata = .;
67
     }
67
     }
68
     _rodata_filesz	= ABSOLUTE ( _mrodata - _rodata );
68
     _rodata_filesz	= ABSOLUTE ( _mrodata - _rodata );
86
 	*(.stack)
86
 	*(.stack)
87
 	*(.stack.*)
87
 	*(.stack.*)
88
 	_mdata = .;
88
 	_mdata = .;
89
-    } .data_bss (NOLOAD) : {
89
+    } .bss.data (NOLOAD) : {
90
 	_edata = .;
90
 	_edata = .;
91
     }
91
     }
92
     _data_filesz	= ABSOLUTE ( _mdata - _data );
92
     _data_filesz	= ABSOLUTE ( _mdata - _data );
102
 	_bss = .;
102
 	_bss = .;
103
 	/* EFI seems to not support proper bss sections */
103
 	/* EFI seems to not support proper bss sections */
104
 	_mbss = .;
104
 	_mbss = .;
105
-    } .bss_bss (NOLOAD) : {
105
+    } .bss.bss (NOLOAD) : {
106
 	_ebss = .;
106
 	_ebss = .;
107
     }
107
     }
108
     _bss_filesz		= ABSOLUTE ( _mbss - _bss );
108
     _bss_filesz		= ABSOLUTE ( _mbss - _bss );
121
 	 */
121
 	 */
122
 	. += 1;
122
 	. += 1;
123
 	_mreloc = .;
123
 	_mreloc = .;
124
-    } .reloc_bss (NOLOAD) : {
124
+    } .bss.reloc (NOLOAD) : {
125
 	_ereloc = .;
125
 	_ereloc = .;
126
     }
126
     }
127
     _reloc_filesz	= ABSOLUTE ( _mreloc - _reloc );
127
     _reloc_filesz	= ABSOLUTE ( _mreloc - _reloc );

+ 5
- 5
src/arch/i386/scripts/i386.lds View File

34
 	*(.prefix)
34
 	*(.prefix)
35
 	*(.prefix.*)
35
 	*(.prefix.*)
36
 	_mprefix = .;
36
 	_mprefix = .;
37
-    } .prefix_bss (NOLOAD) : AT ( _end_lma ) {
37
+    } .bss.prefix (NOLOAD) : AT ( _end_lma ) {
38
 	_eprefix = .;
38
 	_eprefix = .;
39
     }
39
     }
40
     _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
40
     _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
52
 	*(.text16)
52
 	*(.text16)
53
 	*(.text16.*)
53
 	*(.text16.*)
54
 	_mtext16 = .;
54
 	_mtext16 = .;
55
-    } .text16_bss (NOLOAD) : AT ( _end_lma ) {
55
+    } .bss.text16 (NOLOAD) : AT ( _end_lma ) {
56
 	_etext16 = .;
56
 	_etext16 = .;
57
     }
57
     }
58
     _text16_filesz	= ABSOLUTE ( _mtext16 - _text16 );
58
     _text16_filesz	= ABSOLUTE ( _mtext16 - _text16 );
71
 	*(.data16)
71
 	*(.data16)
72
 	*(.data16.*)
72
 	*(.data16.*)
73
 	_mdata16 = .;
73
 	_mdata16 = .;
74
-    } .data16_bss (NOLOAD) : AT ( _end_lma ) {
74
+    } .bss.data16 (NOLOAD) : AT ( _end_lma ) {
75
 	*(.bss16)
75
 	*(.bss16)
76
 	*(.bss16.*)
76
 	*(.bss16.*)
77
 	*(.stack16)
77
 	*(.stack16)
98
 	*(.data.*)
98
 	*(.data.*)
99
 	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
99
 	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
100
 	_mtextdata = .;
100
 	_mtextdata = .;
101
-    } .textdata_bss (NOLOAD) : AT ( _end_lma ) {
101
+    } .bss.textdata (NOLOAD) : AT ( _end_lma ) {
102
 	*(.bss)
102
 	*(.bss)
103
 	*(.bss.*)
103
 	*(.bss.*)
104
 	*(COMMON)
104
 	*(COMMON)
119
 	*(.zinfo)
119
 	*(.zinfo)
120
 	*(.zinfo.*)
120
 	*(.zinfo.*)
121
 	_mzinfo = .;
121
 	_mzinfo = .;
122
-    } .zinfo_bss (NOLOAD) : AT ( _end_lma ) {
122
+    } .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
123
 	_ezinfo = .;
123
 	_ezinfo = .;
124
     }
124
     }
125
     _zinfo_filesz	= ABSOLUTE ( _mzinfo - _zinfo );
125
     _zinfo_filesz	= ABSOLUTE ( _mzinfo - _zinfo );

Loading…
Cancel
Save