瀏覽代碼

[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 15 年之前
父節點
當前提交
7982e79d3c
共有 2 個檔案被更改,包括 11 行新增11 行删除
  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 查看文件

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

+ 5
- 5
src/arch/i386/scripts/i386.lds 查看文件

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

Loading…
取消
儲存