Merge pull request #49 from gmbr3/v4_0

Fixes for segment mapping error
This commit is contained in:
Nigel Croxon 2024-10-31 08:30:54 -04:00 committed by GitHub
commit 9276df8219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 165 additions and 164 deletions

View File

@ -108,6 +108,17 @@ section_table:
.2byte 0 // NumberOfLineNumbers (0 for executables)
.4byte 0x60000020 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
/*
* The EFI application loader requires a relocation section
* because EFI applications must be relocatable. This is a
@ -124,17 +135,6 @@ section_table:
.2byte 0 // NumberOfLineNumbers
.4byte 0x42000040 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
.ascii ".rodata\0"
.4byte _rodata_vsize - ImageBase // VirtualSize
.4byte _rodata - ImageBase // VirtualAddress
@ -172,12 +172,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
label1:
.4byte dummy-label1 // Page RVA
.section .reloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -43,12 +43,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
label1:
.4byte dummy-label1 // Page RVA
.section .reloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -50,7 +50,7 @@ optional_header:
.4byte 0 // SizeOfUninitializedData
.4byte _text - ImageBase // AddressOfEntryPoint
.4byte _text - ImageBase // BaseOfCode
.4byte _reloc - ImageBase // BaseOfData
.4byte _data - ImageBase // BaseOfData
extra_header_fields:
.4byte 0 // ImageBase
@ -110,6 +110,17 @@ section_table:
.2byte 0 // NumberOfLineNumbers (0 for executables)
.4byte 0x60000020 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
/*
* The EFI application loader requires a relocation section
* because EFI applications must be relocatable. This is a
@ -126,17 +137,6 @@ section_table:
.2byte 0 // NumberOfLineNumbers
.4byte 0x42000040 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
.ascii ".rodata\0"
.4byte _rodata_vsize - ImageBase // VirtualSize
.4byte _rodata - ImageBase // VirtualAddress
@ -177,11 +177,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .areloc
.4byte dummy // Page RVA
.section .areloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -32,7 +32,7 @@ optional_header:
.4byte 0 // SizeOfUninitializedData
.4byte _start - ImageBase // AddressOfEntryPoint
.4byte _start - ImageBase // BaseOfCode
.4byte _reloc - ImageBase // BaseOfData
.4byte _data - ImageBase // BaseOfData
extra_header_fields:
.4byte 0 // ImageBase
@ -92,6 +92,17 @@ section_table:
.2byte 0 // NumberOfLineNumbers (0 for executables)
.4byte 0x60000020 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
/*
* The EFI application loader requires a relocation section
* because EFI applications must be relocatable. This is a
@ -108,17 +119,6 @@ section_table:
.2byte 0 // NumberOfLineNumbers
.4byte 0x42000040 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
.ascii ".rodata\0"
.4byte _rodata_vsize - ImageBase // VirtualSize
.4byte _rodata - ImageBase // VirtualAddress
@ -163,11 +163,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc
.4byte dummy // Page RVA
.section .areloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -68,11 +68,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc
.4byte dummy // Page RVA
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -80,7 +80,7 @@ _start_plabel:
#define IMAGE_REL_BASED_DIR64 10
.section .reloc, "a"
.section .reloc, "a", %progbits
data4 _start_plabel // Page RVA
data4 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
data2 (IMAGE_REL_BASED_DIR64<<12) + 0 // reloc for plabel's entry point

View File

@ -45,12 +45,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
label1:
.4byte dummy-label1 // Page RVA
.section .reloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -110,6 +110,17 @@ section_table:
.2byte 0 // NumberOfLineNumbers (0 for executables)
.4byte 0x60000020 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
/*
* The EFI application loader requires a relocation section
* because EFI applications must be relocatable. This is a
@ -126,17 +137,6 @@ section_table:
.2byte 0 // NumberOfLineNumbers
.4byte 0x42000040 // Characteristics (section flags)
.ascii ".data\0\0\0"
.4byte _data_vsize - ImageBase // VirtualSize
.4byte _data - ImageBase // VirtualAddress
.4byte _data_size - ImageBase // SizeOfRawData
.4byte _data - ImageBase // PointerToRawData
.4byte 0 // PointerToRelocations
.4byte 0 // PointerToLineNumbers
.2byte 0 // NumberOfRelocations
.2byte 0 // NumberOfLineNumbers
.4byte 0xC0000040 // Characteristics (section flags)
.ascii ".rodata\0"
.4byte _rodata_vsize - ImageBase // VirtualSize
.4byte _rodata - ImageBase // VirtualAddress
@ -170,12 +170,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
label1:
.4byte dummy-label1 // Page RVA
.section .reloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -38,12 +38,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
label1:
.4byte dummy-label1 // Page RVA
.section .reloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -66,12 +66,12 @@ _start:
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
dummy: .4byte 0
dummy0: .4byte 0
dummy1: .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
label1:
.4byte dummy-label1 // Page RVA
.section .reloc, "a", %progbits
.4byte dummy1 - dummy0 // Page RVA
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy

View File

@ -24,14 +24,6 @@ SECTIONS
_etext = .;
_text_size = _etext - _text;
. = ALIGN(65536);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);
.data :
{
_data = .;
@ -83,7 +75,14 @@ SECTIONS
_bss_end = .;
}
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);
.rela :
{

View File

@ -19,16 +19,6 @@ SECTIONS
_text_vsize = _evtext - _text;
_text_size = _etext - _text;
. = ALIGN(65536);
_reloc = .;
.reloc : {
*(.reloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_data = .;
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
@ -87,7 +77,16 @@ SECTIONS
} =0
_data_vsize = _evdata - _data;
_data_size = _edata - _data;
. = ALIGN(4096);
_reloc = .;
.reloc : {
*(.reloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_rodata = .;
.rela :
@ -115,7 +114,7 @@ SECTIONS
_rodata_vsize = _evrodata - _rodata;
_rodata_size = _erodata - _rodata;
_image_end = .;
_alldata_size = _image_end - _reloc;
_alldata_size = _image_end - _data;
. = ALIGN(4096);
.dynsym : { *(.dynsym) }

View File

@ -19,16 +19,6 @@ SECTIONS
_text_vsize = _evtext - _text;
_text_size = _etext - _text;
. = ALIGN(4096);
_reloc = .;
.areloc : {
*(.areloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_data = .;
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
@ -87,6 +77,16 @@ SECTIONS
} =0
_data_vsize = _evdata - _data;
_data_size = _edata - _data;
. = ALIGN(4096);
_reloc = .;
.areloc : {
*(.areloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_rodata = .;
@ -115,7 +115,7 @@ SECTIONS
_rodata_vsize = _evrodata - _rodata;
_rodata_size = _erodata - _rodata;
_image_end = .;
_alldata_size = _image_end - _reloc;
_alldata_size = _image_end - _data;
. = ALIGN(4096);
.dynsym : { *(.dynsym) }

View File

@ -19,16 +19,6 @@ SECTIONS
_text_vsize = _evtext - _text;
_text_size = _etext - _text;
. = ALIGN(4096);
_reloc = .;
.reloc : {
*(.reloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_data = .;
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
@ -87,24 +77,34 @@ SECTIONS
} =0
_data_vsize = _evdata - _data;
_data_size = _edata - _data;
. = ALIGN(4096);
_reloc = .;
.areloc : {
*(.areloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_rodata = .;
.rela :
.rel :
{
*(.rela.text*)
*(.rela.data*)
*(.rela.got)
*(.rela.dyn)
*(.rela.stab)
*(.rela.init_array*)
*(.rela.fini_array*)
*(.rela.ctors*)
*(.rela.dtors*)
*(.rel.text*)
*(.rel.data*)
*(.rel.got)
*(.rel.dyn)
*(.rel.stab)
*(.rel.init_array*)
*(.rel.fini_array*)
*(.rel.ctors*)
*(.rel.dtors*)
}
. = ALIGN(4096);
.rela.plt : { *(.rela.plt) }
.rel.plt : { *(.rel.plt) }
. = ALIGN(4096);
.rodata : {
*(.rodata*)
@ -115,7 +115,7 @@ SECTIONS
_rodata_vsize = _evrodata - _rodata;
_rodata_size = _erodata - _rodata;
_image_end = .;
_alldata_size = _image_end - _reloc;
_alldata_size = _image_end - _data;
. = ALIGN(4096);
.dynsym : { *(.dynsym) }

View File

@ -23,11 +23,6 @@ SECTIONS
}
_etext = .;
_text_size = _etext - _text;
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(65536);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
@ -83,6 +78,11 @@ SECTIONS
_bss_end = .;
}
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
.rela :

View File

@ -26,11 +26,6 @@ SECTIONS
_etext = .;
_text_size = _etext - _text;
. = ALIGN(65536);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);
@ -85,6 +80,11 @@ SECTIONS
_bss_end = .;
}
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
.rela :

View File

@ -21,16 +21,6 @@ SECTIONS
_text_vsize = _evtext - _text;
_text_size = _etext - _text;
. = ALIGN(4096);
_reloc = .;
.reloc : {
*(.reloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_data = .;
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
@ -89,6 +79,16 @@ SECTIONS
} =0
_data_vsize = _evdata - _data;
_data_size = _edata - _data;
. = ALIGN(4096);
_reloc = .;
.reloc : {
*(.reloc)
_evreloc = .;
. = ALIGN(4096);
_ereloc = .;
} =0
_reloc_vsize = _evreloc - _reloc;
_reloc_size = _ereloc - _reloc;
. = ALIGN(4096);
_rodata = .;
@ -117,7 +117,7 @@ SECTIONS
_rodata_vsize = _evrodata - _rodata;
_rodata_size = _erodata - _rodata;
_image_end = .;
_alldata_size = _image_end - _reloc;
_alldata_size = _image_end - _data;
. = ALIGN(4096);
.dynsym : { *(.dynsym) }

View File

@ -25,11 +25,6 @@ SECTIONS
}
_etext = .;
_text_size = _etext - _text;
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
.data :
@ -81,6 +76,11 @@ SECTIONS
_edata = .;
_data_size = _edata - _etext;
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);

View File

@ -24,11 +24,6 @@ SECTIONS
}
_etext = .;
_text_size = _etext - _text;
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
.data :
@ -80,6 +75,11 @@ SECTIONS
_edata = .;
_data_size = _edata - _etext;
. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);