Make our dummy .reloc sections not depend on section order.
Currently on x64 we manually build a dummy .reloc table entry by using a symbol in .text and subtracting its address from another symbol that's inside the .reloc section. On ia32 we just use its location. In either case, if the linker puts either section in a location we're not expecting, the .reloc table winds up having invalid values, and the PE loader will fail to load the binary. This changes it to be two symbols that are both in .text, making the result unrelated to the section order or location. It's not clear to me that these .reloc entries are actually necessary at all, but I'm going to leave them in place for now, in case they are. Ref: rhboot/gnu-efi@9fb55dee2b Co-authored-by: Peter Jones <pjones@redhat.com> Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
This commit is contained in:
parent
57e8966b5d
commit
ae94e383a3
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 .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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -45,12 +45,13 @@ _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"
|
||||
.section .reloc, "a", %progbits
|
||||
label1:
|
||||
.4byte dummy-label1 // 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
|
||||
|
@ -170,12 +170,13 @@ _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"
|
||||
.section .reloc, "a", %progbits
|
||||
label1:
|
||||
.4byte dummy-label1 // 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
|
||||
|
@ -38,12 +38,13 @@ _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"
|
||||
.section .reloc, "a", %progbits
|
||||
label1:
|
||||
.4byte dummy-label1 // 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
|
||||
|
@ -66,12 +66,13 @@ _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"
|
||||
.section .reloc, "a", %progbits
|
||||
label1:
|
||||
.4byte dummy-label1 // 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
|
||||
|
Loading…
Reference in New Issue
Block a user