Blame SOURCES/0032-Make-our-dummy-.reloc-sections-not-depend-on-section.patch

4c0d37
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4c0d37
From: Peter Jones <pjones@redhat.com>
4c0d37
Date: Mon, 30 Sep 2019 14:29:45 -0400
4c0d37
Subject: [PATCH] Make our dummy .reloc sections not depend on section order.
4c0d37
4c0d37
Currently on x64 we manually build a dummy .reloc table entry by using a
4c0d37
symbol in .text and subtracting its address from another symbol that's
4c0d37
inside the .reloc section.  On ia32 we just use its location.  In either
4c0d37
case, if the linker puts either section in a location we're not
4c0d37
expecting, the .reloc table winds up having invalid values, and the PE
4c0d37
loader will fail to load the binary.
4c0d37
4c0d37
This changes it to be two symbols that are both in .text, making the
4c0d37
result unrelated to the section order or location.
4c0d37
4c0d37
It's not clear to me that these .reloc entries are actually necessary at
4c0d37
all, but I'm going to leave them in place for now, in case they are.
4c0d37
4c0d37
Signed-off-by: Peter Jones <pjones@redhat.com>
4c0d37
---
4c0d37
 gnuefi/crt0-efi-ia32.S | 17 +++++++++--------
4c0d37
 gnuefi/crt0-efi-x64.S  | 16 ++++++++--------
4c0d37
 2 files changed, 17 insertions(+), 16 deletions(-)
4c0d37
4c0d37
diff --git a/gnuefi/crt0-efi-ia32.S b/gnuefi/crt0-efi-ia32.S
4c0d37
index 8e8e372f551..031a592ab35 100644
4c0d37
--- a/gnuefi/crt0-efi-ia32.S
4c0d37
+++ b/gnuefi/crt0-efi-ia32.S
4c0d37
@@ -64,13 +64,14 @@ _start:
4c0d37
 .exit:	leave
4c0d37
 	ret
4c0d37
  
4c0d37
- 	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
4c0d37
- 
4c0d37
- 	.data
4c0d37
-dummy:	.long	0
4c0d37
+	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
4c0d37
+	.data
4c0d37
+.dummy0:
4c0d37
+.dummy1:
4c0d37
+	.long	0
4c0d37
 
4c0d37
 #define IMAGE_REL_ABSOLUTE	0
4c0d37
- 	.section .reloc
4c0d37
- 	.long	dummy					// Page RVA
4c0d37
- 	.long	10					// Block Size (2*4+2)
4c0d37
- 	.word	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
4c0d37
+	.section .reloc, "a"
4c0d37
+	.long	.dummy1-.dummy0				// Page RVA
4c0d37
+	.long	10					// Block Size (2*4+2)
4c0d37
+	.word	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
4c0d37
diff --git a/gnuefi/crt0-efi-x64.S b/gnuefi/crt0-efi-x64.S
4c0d37
index 3fe361b7ffd..5c86cde12e8 100644
4c0d37
--- a/gnuefi/crt0-efi-x64.S
4c0d37
+++ b/gnuefi/crt0-efi-x64.S
4c0d37
@@ -62,15 +62,15 @@ _start:
4c0d37
 .exit:	
4c0d37
   	ret
4c0d37
 
4c0d37
- 	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
4c0d37
- 
4c0d37
- 	.data
4c0d37
-dummy:	.long	0
4c0d37
+	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
4c0d37
+	.data
4c0d37
+.dummy0:
4c0d37
+.dummy1:
4c0d37
+	.long	0
4c0d37
 
4c0d37
 #define IMAGE_REL_ABSOLUTE	0
4c0d37
- 	.section .reloc, "a"
4c0d37
-label1:
4c0d37
-	.long	dummy-label1				// Page RVA
4c0d37
- 	.long	10					// Block Size (2*4+2)
4c0d37
+	.section .reloc, "a"
4c0d37
+	.long	.dummy1-.dummy0				// Page RVA
4c0d37
+	.long	10					// Block Size (2*4+2)
4c0d37
 	.word	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
4c0d37