Skip to content

Commit 9276df8

Browse files
authored
Merge pull request #49 from gmbr3/v4_0
Fixes for segment mapping error
2 parents 70b1421 + aa58dc8 commit 9276df8

19 files changed

Lines changed: 165 additions & 164 deletions

gnuefi/crt0-efi-aarch64-local.S

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ section_table:
108108
.2byte 0 // NumberOfLineNumbers (0 for executables)
109109
.4byte 0x60000020 // Characteristics (section flags)
110110

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+
111122
/*
112123
* The EFI application loader requires a relocation section
113124
* because EFI applications must be relocatable. This is a
@@ -124,17 +135,6 @@ section_table:
124135
.2byte 0 // NumberOfLineNumbers
125136
.4byte 0x42000040 // Characteristics (section flags)
126137

127-
.ascii ".data\0\0\0"
128-
.4byte _data_vsize - ImageBase // VirtualSize
129-
.4byte _data - ImageBase // VirtualAddress
130-
.4byte _data_size - ImageBase // SizeOfRawData
131-
.4byte _data - ImageBase // PointerToRawData
132-
.4byte 0 // PointerToRelocations
133-
.4byte 0 // PointerToLineNumbers
134-
.2byte 0 // NumberOfRelocations
135-
.2byte 0 // NumberOfLineNumbers
136-
.4byte 0xC0000040 // Characteristics (section flags)
137-
138138
.ascii ".rodata\0"
139139
.4byte _rodata_vsize - ImageBase // VirtualSize
140140
.4byte _rodata - ImageBase // VirtualAddress
@@ -172,12 +172,12 @@ _start:
172172
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
173173
174174
.data
175-
dummy: .4byte 0
175+
dummy0: .4byte 0
176+
dummy1: .4byte 0
176177

177178
#define IMAGE_REL_ABSOLUTE 0
178-
.section .reloc, "a"
179-
label1:
180-
.4byte dummy-label1 // Page RVA
179+
.section .reloc, "a", %progbits
180+
.4byte dummy1 - dummy0 // Page RVA
181181
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
182182
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
183183
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-aarch64.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ _start:
4343
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
4444
4545
.data
46-
dummy: .4byte 0
46+
dummy0: .4byte 0
47+
dummy1: .4byte 0
4748

4849
#define IMAGE_REL_ABSOLUTE 0
49-
.section .reloc, "a"
50-
label1:
51-
.4byte dummy-label1 // Page RVA
50+
.section .reloc, "a", %progbits
51+
.4byte dummy1 - dummy0 // Page RVA
5252
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
5353
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
5454
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-arm.S

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ optional_header:
5050
.4byte 0 // SizeOfUninitializedData
5151
.4byte _text - ImageBase // AddressOfEntryPoint
5252
.4byte _text - ImageBase // BaseOfCode
53-
.4byte _reloc - ImageBase // BaseOfData
53+
.4byte _data - ImageBase // BaseOfData
5454

5555
extra_header_fields:
5656
.4byte 0 // ImageBase
@@ -110,6 +110,17 @@ section_table:
110110
.2byte 0 // NumberOfLineNumbers (0 for executables)
111111
.4byte 0x60000020 // Characteristics (section flags)
112112

113+
.ascii ".data\0\0\0"
114+
.4byte _data_vsize - ImageBase // VirtualSize
115+
.4byte _data - ImageBase // VirtualAddress
116+
.4byte _data_size - ImageBase // SizeOfRawData
117+
.4byte _data - ImageBase // PointerToRawData
118+
.4byte 0 // PointerToRelocations
119+
.4byte 0 // PointerToLineNumbers
120+
.2byte 0 // NumberOfRelocations
121+
.2byte 0 // NumberOfLineNumbers
122+
.4byte 0xC0000040 // Characteristics (section flags)
123+
113124
/*
114125
* The EFI application loader requires a relocation section
115126
* because EFI applications must be relocatable. This is a
@@ -126,17 +137,6 @@ section_table:
126137
.2byte 0 // NumberOfLineNumbers
127138
.4byte 0x42000040 // Characteristics (section flags)
128139

129-
.ascii ".data\0\0\0"
130-
.4byte _data_vsize - ImageBase // VirtualSize
131-
.4byte _data - ImageBase // VirtualAddress
132-
.4byte _data_size - ImageBase // SizeOfRawData
133-
.4byte _data - ImageBase // PointerToRawData
134-
.4byte 0 // PointerToRelocations
135-
.4byte 0 // PointerToLineNumbers
136-
.2byte 0 // NumberOfRelocations
137-
.2byte 0 // NumberOfLineNumbers
138-
.4byte 0xC0000040 // Characteristics (section flags)
139-
140140
.ascii ".rodata\0"
141141
.4byte _rodata_vsize - ImageBase // VirtualSize
142142
.4byte _rodata - ImageBase // VirtualAddress
@@ -177,11 +177,12 @@ _start:
177177
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
178178
179179
.data
180-
dummy: .4byte 0
180+
dummy0: .4byte 0
181+
dummy1: .4byte 0
181182

182183
#define IMAGE_REL_ABSOLUTE 0
183-
.section .areloc
184-
.4byte dummy // Page RVA
184+
.section .areloc, "a", %progbits
185+
.4byte dummy1 - dummy0 // Page RVA
185186
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
186187
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
187188
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-ia32-local.S

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3737
extra_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

gnuefi/crt0-efi-ia32.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ _start:
6868
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
6969

7070
.data
71-
dummy: .4byte 0
71+
dummy0: .4byte 0
72+
dummy1: .4byte 0
7273

7374
#define IMAGE_REL_ABSOLUTE 0
7475
.section .reloc
75-
.4byte dummy // Page RVA
76+
.4byte dummy1 - dummy0 // Page RVA
7677
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
7778
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
7879
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-ia64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ _start_plabel:
8080

8181
#define IMAGE_REL_BASED_DIR64 10
8282

83-
.section .reloc, "a"
83+
.section .reloc, "a", %progbits
8484
data4 _start_plabel // Page RVA
8585
data4 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
8686
data2 (IMAGE_REL_BASED_DIR64<<12) + 0 // reloc for plabel's entry point

gnuefi/crt0-efi-loongarch64.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ _start:
4545
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
4646

4747
.data
48-
dummy: .4byte 0
48+
dummy0: .4byte 0
49+
dummy1: .4byte 0
4950

5051
#define IMAGE_REL_ABSOLUTE 0
51-
.section .reloc, "a"
52-
label1:
53-
.4byte dummy-label1 // Page RVA
52+
.section .reloc, "a", %progbits
53+
.4byte dummy1 - dummy0 // Page RVA
5454
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
5555
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
5656
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-riscv64-local.S

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ section_table:
110110
.2byte 0 // NumberOfLineNumbers (0 for executables)
111111
.4byte 0x60000020 // Characteristics (section flags)
112112

113+
.ascii ".data\0\0\0"
114+
.4byte _data_vsize - ImageBase // VirtualSize
115+
.4byte _data - ImageBase // VirtualAddress
116+
.4byte _data_size - ImageBase // SizeOfRawData
117+
.4byte _data - ImageBase // PointerToRawData
118+
.4byte 0 // PointerToRelocations
119+
.4byte 0 // PointerToLineNumbers
120+
.2byte 0 // NumberOfRelocations
121+
.2byte 0 // NumberOfLineNumbers
122+
.4byte 0xC0000040 // Characteristics (section flags)
123+
113124
/*
114125
* The EFI application loader requires a relocation section
115126
* because EFI applications must be relocatable. This is a
@@ -126,17 +137,6 @@ section_table:
126137
.2byte 0 // NumberOfLineNumbers
127138
.4byte 0x42000040 // Characteristics (section flags)
128139

129-
.ascii ".data\0\0\0"
130-
.4byte _data_vsize - ImageBase // VirtualSize
131-
.4byte _data - ImageBase // VirtualAddress
132-
.4byte _data_size - ImageBase // SizeOfRawData
133-
.4byte _data - ImageBase // PointerToRawData
134-
.4byte 0 // PointerToRelocations
135-
.4byte 0 // PointerToLineNumbers
136-
.2byte 0 // NumberOfRelocations
137-
.2byte 0 // NumberOfLineNumbers
138-
.4byte 0xC0000040 // Characteristics (section flags)
139-
140140
.ascii ".rodata\0"
141141
.4byte _rodata_vsize - ImageBase // VirtualSize
142142
.4byte _rodata - ImageBase // VirtualAddress
@@ -170,12 +170,12 @@ _start:
170170
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
171171

172172
.data
173-
dummy: .4byte 0
173+
dummy0: .4byte 0
174+
dummy1: .4byte 0
174175

175176
#define IMAGE_REL_ABSOLUTE 0
176-
.section .reloc, "a"
177-
label1:
178-
.4byte dummy-label1 // Page RVA
177+
.section .reloc, "a", %progbits
178+
.4byte dummy1 - dummy0 // Page RVA
179179
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
180180
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
181181
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-riscv64.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ _start:
3838
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
3939

4040
.data
41-
dummy: .4byte 0
41+
dummy0: .4byte 0
42+
dummy1: .4byte 0
4243

4344
#define IMAGE_REL_ABSOLUTE 0
44-
.section .reloc, "a"
45-
label1:
46-
.4byte dummy-label1 // Page RVA
45+
.section .reloc, "a", %progbits
46+
.4byte dummy1 - dummy0 // Page RVA
4747
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
4848
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
4949
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

gnuefi/crt0-efi-x86_64.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ _start:
6666
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
6767

6868
.data
69-
dummy: .4byte 0
69+
dummy0: .4byte 0
70+
dummy1: .4byte 0
7071

7172
#define IMAGE_REL_ABSOLUTE 0
72-
.section .reloc, "a"
73-
label1:
74-
.4byte dummy-label1 // Page RVA
73+
.section .reloc, "a", %progbits
74+
.4byte dummy1 - dummy0 // Page RVA
7575
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
7676
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
7777
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

0 commit comments

Comments
 (0)