diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 2c66941bc41..05c0947d69b 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -2270,7 +2270,16 @@ error_code ELFObjectFile::getRelocationValueString( res = "Unknown"; } break; - case ELF::EM_AARCH64: + case ELF::EM_AARCH64: { + std::string fmtbuf; + raw_string_ostream fmt(fmtbuf); + fmt << symname; + if (addend != 0) + fmt << (addend < 0 ? "" : "+") << addend; + fmt.flush(); + Result.append(fmtbuf.begin(), fmtbuf.end()); + break; + } case ELF::EM_ARM: case ELF::EM_HEXAGON: res = symname; diff --git a/test/MC/AArch64/elf-reloc-addend.s b/test/MC/AArch64/elf-reloc-addend.s new file mode 100644 index 00000000000..0e7e2cafb72 --- /dev/null +++ b/test/MC/AArch64/elf-reloc-addend.s @@ -0,0 +1,8 @@ +// RUN: llvm-mc -triple=aarch64-linux-gnu -filetype=obj -o - %s | llvm-objdump -triple=aarch64-linux-gnu -r - | FileCheck %s + + add x0, x4, #:lo12:sym +// CHECK: 0 R_AARCH64_ADD_ABS_LO12_NC sym + add x3, x5, #:lo12:sym+1 +// CHECK: 4 R_AARCH64_ADD_ABS_LO12_NC sym+1 + add x3, x5, #:lo12:sym-1 +// CHECK: 8 R_AARCH64_ADD_ABS_LO12_NC sym-1