From 6cbc9dda8a563d030d025f48797f9b2c4c36cdc4 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Fri, 29 Jul 2022 14:15:20 +0800 Subject: [PATCH] read/elf: support some LoongArch ELF relative relocations --- src/read/elf/relocation.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/read/elf/relocation.rs b/src/read/elf/relocation.rs index 557b80e..3d7f68e 100644 --- a/src/read/elf/relocation.rs +++ b/src/read/elf/relocation.rs @@ -304,6 +304,19 @@ fn parse_relocation( elf::EM_LOONGARCH => match reloc.r_type(endian, false) { elf::R_LARCH_32 => (RelocationKind::Absolute, 32), elf::R_LARCH_64 => (RelocationKind::Absolute, 64), + elf::R_LARCH_32_PCREL => (RelocationKind::Relative, 32), + elf::R_LARCH_B16 => { + encoding = RelocationEncoding::LoongArchBranch; + (RelocationKind::Relative, 16) + } + elf::R_LARCH_B21 => { + encoding = RelocationEncoding::LoongArchBranch; + (RelocationKind::Relative, 21) + } + elf::R_LARCH_B26 => { + encoding = RelocationEncoding::LoongArchBranch; + (RelocationKind::Relative, 26) + } r_type => (RelocationKind::Elf(r_type), 0), }, elf::EM_MIPS => match reloc.r_type(endian, is_mips64el) {