diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index a28f5943c320d..8cf748aa5681c 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -888,7 +888,8 @@ uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, return Elf64BEObj->getRelSection(R.getRawDataRefImpl())->sh_type; }; - if (GetRelSectionType() == ELF::SHT_RELA) { + if (GetRelSectionType() == ELF::SHT_RELA || + GetRelSectionType() == ELF::SHT_CREL) { Addend = getELFAddend(R); // LoongArch and RISCV relocations use both LocData and Addend. if (Obj->getArch() != Triple::loongarch32 && diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.test new file mode 100644 index 0000000000000..f1a4dbc699166 --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_crel.test @@ -0,0 +1,5 @@ +# Test llvm-dwarfdump handles CREL relocation sections correctly. +RUN: echo "void foo(){}" | clang++ --target=x86_64-pc-linux -Wa,--crel,--allow-experimental-crel -g -c -x c++ - -o %t +RUN: llvm-dwarfdump --debug-info %t | FileCheck %s + +CHECK: DW_AT_producer ("clang version