@@ -32,7 +32,7 @@ optional_header:
3232 .4byte 0 // SizeOfUninitializedData
3333 .4byte _start - ImageBase // AddressOfEntryPoint
3434 .4byte _start - ImageBase // BaseOfCode
35- .4byte _reloc - ImageBase // BaseOfData
35+ .4byte _data - ImageBase // BaseOfData
3636
3737extra_header_fields:
3838 .4byte 0 // ImageBase
@@ -92,6 +92,17 @@ section_table:
9292 .2byte 0 // NumberOfLineNumbers (0 for executables)
9393 .4byte 0x60000020 // Characteristics (section flags)
9494
95+ .ascii ".data\0\0\0"
96+ .4byte _data_vsize - ImageBase // VirtualSize
97+ .4byte _data - ImageBase // VirtualAddress
98+ .4byte _data_size - ImageBase // SizeOfRawData
99+ .4byte _data - ImageBase // PointerToRawData
100+ .4byte 0 // PointerToRelocations
101+ .4byte 0 // PointerToLineNumbers
102+ .2byte 0 // NumberOfRelocations
103+ .2byte 0 // NumberOfLineNumbers
104+ .4byte 0xC0000040 // Characteristics (section flags)
105+
95106 /*
96107 * The EFI application loader requires a relocation section
97108 * because EFI applications must be relocatable. This is a
@@ -108,17 +119,6 @@ section_table:
108119 .2byte 0 // NumberOfLineNumbers
109120 .4byte 0x42000040 // Characteristics (section flags)
110121
111- .ascii ".data\0\0\0"
112- .4byte _data_vsize - ImageBase // VirtualSize
113- .4byte _data - ImageBase // VirtualAddress
114- .4byte _data_size - ImageBase // SizeOfRawData
115- .4byte _data - ImageBase // PointerToRawData
116- .4byte 0 // PointerToRelocations
117- .4byte 0 // PointerToLineNumbers
118- .2byte 0 // NumberOfRelocations
119- .2byte 0 // NumberOfLineNumbers
120- .4byte 0xC0000040 // Characteristics (section flags)
121-
122122 .ascii ".rodata\0"
123123 .4byte _rodata_vsize - ImageBase // VirtualSize
124124 .4byte _rodata - ImageBase // VirtualAddress
@@ -163,11 +163,12 @@ _start:
163163// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
164164
165165 .data
166- dummy: .4byte 0
166+ dummy0: .4byte 0
167+ dummy1: .4byte 0
167168
168169#define IMAGE_REL_ABSOLUTE 0
169- .section .reloc
170- .4byte dummy // Page RVA
170+ .section .areloc, "a" , %progbits
171+ .4byte dummy1 - dummy0 // Page RVA
171172 .4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
172173 .2byte (IMAGE_REL_ABSOLUTE<<12 ) + 0 // reloc for dummy
173174 .2byte (IMAGE_REL_ABSOLUTE<<12 ) + 0 // reloc for dummy
0 commit comments