summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexey Sheplyakov2024-02-21 10:07:21 +0100
committerMichael Brown2024-02-22 15:40:53 +0100
commitee6185dcf5ad7b0d5e486e66c424341764fc221d (patch)
tree3353a5c8cc2530db1f2dcd38f49d7705ae0fdaa0 /src
parent[drivers] Sort PCI_ROM() entries numerically (diff)
downloadipxe-ee6185dcf5ad7b0d5e486e66c424341764fc221d.tar.gz
ipxe-ee6185dcf5ad7b0d5e486e66c424341764fc221d.tar.xz
ipxe-ee6185dcf5ad7b0d5e486e66c424341764fc221d.zip
[efi] Ignore new LoongArch PC-relative relocations and relaxations
Several new relocations types have been added in LoongArch ABI version 2.10. In particular: - R_LARCH_B16 (18-bit PC-relative jump) - R_LARCH_B21 (23-bit PC-relative jump) - R_LARCH_PCREL20_S2 (22-bit PC-relative offset) Also relocation relaxations have been introduced. Recent GCC (13.2) and binutils 2.41+ use these types of relocations, which confuses elf2efi tool. As a result, iPXE EFI images for LoongArch fail to build with the following error: Unrecognised relocation type 103 Fix by ignoring R_LARCH_B{16,21} and R_LARCH_PCREL20_S2 (as with other PC-relative relocations), and by ignoring relaxations (R_LARCH_RELAX). Relocation relaxations are basically optimizations: ignoring them results in a correct binary (although it might be suboptimal). Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/util/elf2efi.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c
index 88713b66..4af587d8 100644
--- a/src/util/elf2efi.c
+++ b/src/util/elf2efi.c
@@ -140,6 +140,12 @@
#ifndef R_LARCH_64
#define R_LARCH_64 2
#endif
+#ifndef R_LARCH_B16
+#define R_LARCH_B16 64
+#endif
+#ifndef R_LARCH_B21
+#define R_LARCH_B21 65
+#endif
#ifndef R_LARCH_B26
#define R_LARCH_B26 66
#endif
@@ -155,6 +161,12 @@
#ifndef R_LARCH_GOT_PC_LO12
#define R_LARCH_GOT_PC_LO12 76
#endif
+#ifndef R_LARCH_RELAX
+#define R_LARCH_RELAX 100
+#endif
+#ifndef R_LARCH_PCREL20_S2
+#define R_LARCH_PCREL20_S2 103
+#endif
#ifndef R_X86_64_GOTPCRELX
#define R_X86_64_GOTPCRELX 41
#endif
@@ -849,16 +861,24 @@ static void process_reloc ( struct elf_file *elf, const Elf_Shdr *shdr,
case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST32_ABS_LO12_NC ) :
case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST64_ABS_LO12_NC ) :
case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST128_ABS_LO12_NC ) :
+ case ELF_MREL ( EM_LOONGARCH, R_LARCH_B16):
+ case ELF_MREL ( EM_LOONGARCH, R_LARCH_B21):
case ELF_MREL ( EM_LOONGARCH, R_LARCH_B26):
case ELF_MREL ( EM_LOONGARCH, R_LARCH_PCALA_HI20 ):
case ELF_MREL ( EM_LOONGARCH, R_LARCH_PCALA_LO12 ):
case ELF_MREL ( EM_LOONGARCH, R_LARCH_GOT_PC_HI20 ):
case ELF_MREL ( EM_LOONGARCH, R_LARCH_GOT_PC_LO12 ):
+ case ELF_MREL ( EM_LOONGARCH, R_LARCH_PCREL20_S2 ):
/* Skip PC-relative relocations; all relative
* offsets remain unaltered when the object is
* loaded.
*/
break;
+ case ELF_MREL ( EM_LOONGARCH, R_LARCH_RELAX ):
+ /* Relocation can be relaxed (optimized out).
+ * Ignore it for now.
+ */
+ break;
case ELF_MREL ( EM_X86_64, R_X86_64_32 ) :
/* Ignore 32-bit relocations in a hybrid
* 32-bit BIOS and 64-bit UEFI binary,