Push .reloc after .data

Seems GNU ld is a bit stupid in this regard
Apply to all archs incase this is repeated so far
only seen on ARM64

Fixes ncroxon/gnu-efi#47

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
This commit is contained in:
Callum Farmer 2024-10-24 12:43:10 +01:00
parent 882df4e732
commit 03bfe2f5ce
No known key found for this signature in database
GPG Key ID: 9A5B19E18CD0013C
13 changed files with 118 additions and 120 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

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

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

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

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 = .;
.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

@ -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);