Skip to content

Commit

Permalink
readobj: add loongarch64 support (gimli-rs#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaixiaojuan authored Apr 22, 2022
1 parent f5c84e2 commit 03acc00
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions crates/examples/src/readobj/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fn print_file_header<Elf: FileHeader>(p: &mut Printer<'_>, endian: Elf::Endian,
p.flags(flags, 0, &FLAGS_EF_RISCV);
p.flags(flags, EF_RISCV_FLOAT_ABI, &FLAGS_EF_RISCV_FLOAT_ABI);
}
EM_LOONGARCH => p.flags(flags, 0, &FLAGS_EF_LOONGARCH),
_ => {}
};
p.field_hex("HeaderSize", elf.e_ehsize(endian));
Expand Down Expand Up @@ -461,6 +462,7 @@ fn rel_flag_type<Elf: FileHeader>(endian: Elf::Endian, elf: &Elf) -> &'static [F
EM_TILEGX => FLAGS_R_TILEGX,
EM_RISCV => FLAGS_R_RISCV,
EM_BPF => FLAGS_R_BPF,
EM_LOONGARCH => FLAGS_R_LOONGARCH,
EM_METAG => FLAGS_R_METAG,
EM_NDS32 => FLAGS_R_NDS32,
_ => &[],
Expand Down Expand Up @@ -982,6 +984,7 @@ static FLAGS_EM: &[Flag<u16>] = &flags!(
EM_BPF,
EM_CSKY,
EM_ALPHA,
EM_LOONGARCH,
);
static FLAGS_EF_SPARC: &[Flag<u32>] = &flags!(
EF_SPARC_LEDATA,
Expand Down Expand Up @@ -1088,6 +1091,14 @@ static FLAGS_EF_RISCV_FLOAT_ABI: &[Flag<u32>] = &flags!(
EF_RISCV_FLOAT_ABI_DOUBLE,
EF_RISCV_FLOAT_ABI_QUAD,
);
static FLAGS_EF_LOONGARCH: &[Flag<u32>] = &flags!(
EF_LARCH_ABI_LP64S,
EF_LARCH_ABI_LP64F,
EF_LARCH_ABI_LP64D,
EF_LARCH_ABI_ILP32S,
EF_LARCH_ABI_ILP32F,
EF_LARCH_ABI_ILP32D,
);
static FLAGS_PT: &[Flag<u32>] = &flags!(
PT_NULL,
PT_LOAD,
Expand Down Expand Up @@ -2940,6 +2951,60 @@ static FLAGS_R_NDS32: &[Flag<u32>] = &flags!(
R_NDS32_TLS_TPOFF,
R_NDS32_TLS_DESC,
);
static FLAGS_R_LOONGARCH: &[Flag<u32>] = &flags!(
R_LARCH_NONE,
R_LARCH_32,
R_LARCH_64,
R_LARCH_RELATIVE,
R_LARCH_COPY,
R_LARCH_JUMP_SLOT,
R_LARCH_TLS_DTPMOD32,
R_LARCH_TLS_DTPMOD64,
R_LARCH_TLS_DTPREL32,
R_LARCH_TLS_DTPREL64,
R_LARCH_TLS_TPREL32,
R_LARCH_TLS_TPREL64,
R_LARCH_IRELATIVE,
R_LARCH_MARK_LA,
R_LARCH_MARK_PCREL,
R_LARCH_SOP_PUSH_PCREL,
R_LARCH_SOP_PUSH_ABSOLUTE,
R_LARCH_SOP_PUSH_DUP,
R_LARCH_SOP_PUSH_GPREL,
R_LARCH_SOP_PUSH_TLS_TPREL,
R_LARCH_SOP_PUSH_TLS_GOT,
R_LARCH_SOP_PUSH_TLS_GD,
R_LARCH_SOP_PUSH_PLT_PCREL,
R_LARCH_SOP_ASSERT,
R_LARCH_SOP_NOT,
R_LARCH_SOP_SUB,
R_LARCH_SOP_SL,
R_LARCH_SOP_SR,
R_LARCH_SOP_ADD,
R_LARCH_SOP_AND,
R_LARCH_SOP_IF_ELSE,
R_LARCH_SOP_POP_32_S_10_5,
R_LARCH_SOP_POP_32_U_10_12,
R_LARCH_SOP_POP_32_S_10_12,
R_LARCH_SOP_POP_32_S_10_16,
R_LARCH_SOP_POP_32_S_10_16_S2,
R_LARCH_SOP_POP_32_S_5_20,
R_LARCH_SOP_POP_32_S_0_5_10_16_S2,
R_LARCH_SOP_POP_32_S_0_10_10_16_S2,
R_LARCH_SOP_POP_32_U,
R_LARCH_ADD8,
R_LARCH_ADD16,
R_LARCH_ADD24,
R_LARCH_ADD32,
R_LARCH_ADD64,
R_LARCH_SUB8,
R_LARCH_SUB16,
R_LARCH_SUB24,
R_LARCH_SUB32,
R_LARCH_SUB64,
R_LARCH_GNU_VTINHERIT,
R_LARCH_GNU_VTENTRY,
);
static FLAGS_NT_CORE: &[Flag<u32>] = &flags!(
NT_PRSTATUS,
NT_PRFPREG,
Expand Down

0 comments on commit 03acc00

Please sign in to comment.