Skip to content

Commit

Permalink
Merge pull request #49 from gmbr3/v4_0
Browse files Browse the repository at this point in the history
Fixes for segment mapping error
  • Loading branch information
ncroxon authored Oct 31, 2024
2 parents 70b1421 + aa58dc8 commit 9276df8
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 164 deletions.
30 changes: 15 additions & 15 deletions gnuefi/crt0-efi-aarch64-local.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions gnuefi/crt0-efi-aarch64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 16 additions & 15 deletions gnuefi/crt0-efi-arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
31 changes: 16 additions & 15 deletions gnuefi/crt0-efi-ia32-local.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions gnuefi/crt0-efi-ia32.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gnuefi/crt0-efi-ia64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions gnuefi/crt0-efi-loongarch64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions gnuefi/crt0-efi-riscv64-local.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions gnuefi/crt0-efi-riscv64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions gnuefi/crt0-efi-x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions gnuefi/elf_aarch64_efi.lds
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ SECTIONS
_etext = .;
_text_size = _etext - _text;
. = ALIGN(65536);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);
.data :
{
_data = .;
Expand Down Expand Up @@ -83,7 +75,14 @@ SECTIONS

_bss_end = .;
}

. = ALIGN(4096);
.reloc :
{
KEEP (*(.reloc))
}
. = ALIGN(4096);
_DYNAMIC = .;
.dynamic : { *(.dynamic) }
. = ALIGN(4096);
.rela :
{
Expand Down
23 changes: 11 additions & 12 deletions gnuefi/elf_aarch64_efi_local.lds
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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 :
Expand Down Expand Up @@ -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) }
Expand Down
Loading

0 comments on commit 9276df8

Please sign in to comment.