From 46072b8de555eb4f4e2619c16c3db562b6094a2b Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Fri, 29 Jul 2022 14:16:26 +0800 Subject: [PATCH] readobj: add new relocs introduced by LoongArch psABI v2 --- crates/examples/src/readobj/elf.rs | 37 ++++++++++++++++++++++++++++++ src/common.rs | 5 ++++ 2 files changed, 42 insertions(+) diff --git a/crates/examples/src/readobj/elf.rs b/crates/examples/src/readobj/elf.rs index 7b8f67bc..1bd16f35 100644 --- a/crates/examples/src/readobj/elf.rs +++ b/crates/examples/src/readobj/elf.rs @@ -3020,6 +3020,43 @@ static FLAGS_R_LOONGARCH: &[Flag] = &flags!( R_LARCH_SUB64, R_LARCH_GNU_VTINHERIT, R_LARCH_GNU_VTENTRY, + R_LARCH_B16, + R_LARCH_B21, + R_LARCH_B26, + R_LARCH_ABS_HI20, + R_LARCH_ABS_LO12, + R_LARCH_ABS64_LO20, + R_LARCH_ABS64_HI12, + R_LARCH_PCALA_HI20, + R_LARCH_PCALA_LO12, + R_LARCH_PCALA64_LO20, + R_LARCH_PCALA64_HI12, + R_LARCH_GOT_PC_HI20, + R_LARCH_GOT_PC_LO12, + R_LARCH_GOT64_PC_LO20, + R_LARCH_GOT64_PC_HI12, + R_LARCH_GOT_HI20, + R_LARCH_GOT_LO12, + R_LARCH_GOT64_LO20, + R_LARCH_GOT64_HI12, + R_LARCH_TLS_LE_HI20, + R_LARCH_TLS_LE_LO12, + R_LARCH_TLS_LE64_LO20, + R_LARCH_TLS_LE64_HI12, + R_LARCH_TLS_IE_PC_HI20, + R_LARCH_TLS_IE_PC_LO12, + R_LARCH_TLS_IE64_PC_LO20, + R_LARCH_TLS_IE64_PC_HI12, + R_LARCH_TLS_IE_HI20, + R_LARCH_TLS_IE_LO12, + R_LARCH_TLS_IE64_LO20, + R_LARCH_TLS_IE64_HI12, + R_LARCH_TLS_LD_PC_HI20, + R_LARCH_TLS_LD_HI20, + R_LARCH_TLS_GD_PC_HI20, + R_LARCH_TLS_GD_HI20, + R_LARCH_32_PCREL, + R_LARCH_RELAX, ); static FLAGS_NT_CORE: &[Flag] = &flags!( NT_PRSTATUS, diff --git a/src/common.rs b/src/common.rs index 20dde991..77065ae2 100644 --- a/src/common.rs +++ b/src/common.rs @@ -343,6 +343,11 @@ pub enum RelocationEncoding { /// /// The `RelocationKind` must be PC relative. AArch64Call, + + /// LoongArch branch offset with two trailing zeros. + /// + /// The `RelocationKind` must be PC relative. + LoongArchBranch, } /// File flags that are specific to each file format.