summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/scripts/efi.lds
blob: b6255a68d424d8648f0912db1c7ed679d4e0d244 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/* -*- sh -*- */

/*
 * Linker script for EFI images
 *
 */

EXTERN ( efi_entry )

SECTIONS {

    /* The file starts at a virtual address of zero, and sections are
     * contiguous.  Each section is aligned to at least _max_align,
     * which defaults to 32.  Load addresses are equal to virtual
     * addresses.
     */

    . = 0;
    PROVIDE ( _max_align = 32 );

    /*
     * The prefix
     *
     */

    .prefix : {
	_prefix = .;
	*(.prefix)
	*(.prefix.*)
	_mprefix = .;
    } .bss.prefix (NOLOAD) : {
	_eprefix = .;
    }
    _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
    _prefix_memsz	= ABSOLUTE ( _eprefix - _prefix );

    /*
     * The text section
     *
     */

    . = ALIGN ( _max_align );
    .text : {
	_text = .;
	*(.text)
	*(.text.*)
	_mtext = .;
    } .bss.text (NOLOAD) : {
	_etext = .;
    }
    _text_filesz	= ABSOLUTE ( _mtext - _text );
    _text_memsz		= ABSOLUTE ( _etext - _text );

    /*
     * The rodata section
     *
     */

    . = ALIGN ( _max_align );
    .rodata : {
	_rodata = .;
	*(.rodata)
	*(.rodata.*)
	_mrodata = .;
    } .bss.rodata (NOLOAD) : {
	_erodata = .;
    }
    _rodata_filesz	= ABSOLUTE ( _mrodata - _rodata );
    _rodata_memsz	= ABSOLUTE ( _erodata - _rodata );

    /*
     * The data section
     *
     */

    . = ALIGN ( _max_align );
    .data : {
	_data = .;
	*(.data)
	*(.data.*)
	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
	/* EFI seems to not support proper bss sections */
	*(.bss)
	*(.bss.*)
	*(COMMON)
	*(.stack)
	*(.stack.*)
	_mdata = .;
    } .bss.data (NOLOAD) : {
	_edata = .;
    }
    _data_filesz	= ABSOLUTE ( _mdata - _data );
    _data_memsz		= ABSOLUTE ( _edata - _data );

    /*
     * The bss section
     *
     */

    . = ALIGN ( _max_align );
    .bss : { 
	_bss = .;
	/* EFI seems to not support proper bss sections */
	_mbss = .;
    } .bss.bss (NOLOAD) : {
	_ebss = .;
    }
    _bss_filesz		= ABSOLUTE ( _mbss - _bss );
    _bss_memsz		= ABSOLUTE ( _ebss - _bss );

    /*
     * The reloc section
     *
     */

    . = ALIGN ( _max_align );
    .reloc : {
	_reloc = .;
	/* Provide some dummy contents to force ld to include this
	 * section.  It will be created by the efilink utility.
	 */
	. += 1;
	_mreloc = .;
    } .bss.reloc (NOLOAD) : {
	_ereloc = .;
    }
    _reloc_filesz	= ABSOLUTE ( _mreloc - _reloc );
    _reloc_memsz	= ABSOLUTE ( _ereloc - _reloc );

    _filesz		= ABSOLUTE ( . );

    /*
     * Weak symbols that need zero values if not otherwise defined
     *
     */

    .weak 0x0 : {
	_weak = .;
	*(.weak)
	_eweak = .;
    }
    _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );

    /*
     * Dispose of the comment and note sections to make the link map
     * easier to read
     *
     */

    /DISCARD/ : {
	*(.comment)
	*(.comment.*)
	*(.note)
	*(.note.*)
	*(.eh_frame)
	*(.eh_frame.*)
	*(.rel)
	*(.rel.*)
    }

    /*
     * Load address calculations.
     *
     */

    _prefix_lma		= ABSOLUTE ( _prefix );
    _text_lma		= ABSOLUTE ( _text );
    _rodata_lma		= ABSOLUTE ( _rodata );
    _data_lma		= ABSOLUTE ( _data );
    _bss_lma		= ABSOLUTE ( _bss );
    _reloc_lma		= ABSOLUTE ( _reloc );

    /*
     * Load addresses required by the prefix
     *
     */
    efi_entry_lma	= ABSOLUTE ( efi_entry );
    debugdir_lma	= ABSOLUTE ( debugdir );
    codeview_rsds_lma	= ABSOLUTE ( codeview_rsds );
}