File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,8 @@ struct VersionEntry {
7272};
7373
7474LLVM_ABI StringRef getELFRelocationTypeName (uint32_t Machine, uint32_t Type);
75+ LLVM_ABI StringRef getRISCVVendorRelocationTypeName (uint32_t Type,
76+ StringRef Vendor);
7577LLVM_ABI uint32_t getELFRelativeRelocationType (uint32_t Machine);
7678LLVM_ABI StringRef getELFSectionTypeName (uint32_t Machine, uint32_t Type);
7779
Original file line number Diff line number Diff line change @@ -191,6 +191,18 @@ StringRef llvm::object::getELFRelocationTypeName(uint32_t Machine,
191191
192192#undef ELF_RELOC
193193
194+ #define ELF_RISCV_NONSTANDARD_RELOC (vendor, name, number ) \
195+ if (Vendor == #vendor && Type == number) \
196+ return #name;
197+
198+ StringRef llvm::object::getRISCVVendorRelocationTypeName (uint32_t Type,
199+ StringRef Vendor) {
200+ #include " llvm/BinaryFormat/ELFRelocs/RISCV_nonstandard.def"
201+ return " Unknown" ;
202+ }
203+
204+ #undef ELF_RISCV_NONSTANDARD_RELOC
205+
194206uint32_t llvm::object::getELFRelativeRelocationType (uint32_t Machine) {
195207 switch (Machine) {
196208 case ELF::EM_X86_64:
Original file line number Diff line number Diff line change @@ -255,6 +255,20 @@ TEST(ELFTest, getELFRelocationTypeNameForLoongArch) {
255255 getELFRelocationTypeName (EM_LOONGARCH, R_LARCH_CALL36));
256256}
257257
258+ TEST (ELFTest, getRISCVVendorRelocationTypeName) {
259+ EXPECT_EQ (" R_RISCV_QC_ABS20_U" ,
260+ getRISCVVendorRelocationTypeName (R_RISCV_CUSTOM192, " QUALCOMM" ));
261+ EXPECT_EQ (" R_RISCV_QC_E_BRANCH" ,
262+ getRISCVVendorRelocationTypeName (R_RISCV_CUSTOM193, " QUALCOMM" ));
263+ EXPECT_EQ (" R_RISCV_QC_E_32" ,
264+ getRISCVVendorRelocationTypeName (R_RISCV_CUSTOM194, " QUALCOMM" ));
265+ EXPECT_EQ (" R_RISCV_QC_E_CALL_PLT" ,
266+ getRISCVVendorRelocationTypeName (R_RISCV_CUSTOM195, " QUALCOMM" ));
267+
268+ EXPECT_EQ (" R_RISCV_NDS_BRANCH_10" ,
269+ getRISCVVendorRelocationTypeName (R_RISCV_CUSTOM241, " ANDES" ));
270+ }
271+
258272TEST (ELFTest, getELFRelativeRelocationType) {
259273 EXPECT_EQ (ELF::R_VE_RELATIVE, getELFRelativeRelocationType (EM_VE));
260274 EXPECT_EQ (ELF::R_LARCH_RELATIVE, getELFRelativeRelocationType (EM_LOONGARCH));
You can’t perform that action at this time.
0 commit comments