Skip to content

Commit fa24875

Browse files
committed
llvm-objdump --adjust-vma: Don't adjust VMA in inline reloc addresses
--adjust-vma adjusts the current section address. The address printed for inline relocs is relative to the current section address instead of the section that the referenced symbol resides in. Fix #75444
1 parent 89273e9 commit fa24875

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

llvm/test/tools/llvm-objdump/BPF/core-relo-formatting.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@
7878
# VMA: 3: r1 = 0x1
7979
# VMA-NEXT: 0000000000000018: CO-RE <type_exists> [3] struct foo
8080
# VMA-NEXT: 4: call -0x1
81-
# VMA-NEXT: 0000000000000010: R_BPF_64_32 consume
81+
# VMA-NEXT: 0000000000000020: R_BPF_64_32 consume
8282
# VMA-NEXT: 5: r1 = 0x0
8383
# VMA-NEXT: 0000000000000028: CO-RE <byte_off> [3] struct foo::a (0:0)
8484
# VMA-NEXT: 6: call -0x1
85-
# VMA-NEXT: 0000000000000020: R_BPF_64_32 consume
85+
# VMA-NEXT: 0000000000000030: R_BPF_64_32 consume
8686
# VMA-NEXT: 7: r1 = 0x1 ll
8787
# VMA-NEXT: 0000000000000038: CO-RE <enumval_exists> [8] enum bar::U = 0
8888
# VMA-NEXT: 9: call -0x1
89-
# VMA-NEXT: 0000000000000038: R_BPF_64_32 consume
89+
# VMA-NEXT: 0000000000000048: R_BPF_64_32 consume
9090
# VMA-NEXT: 10: exit
9191

9292
.text

llvm/test/tools/llvm-objdump/X86/adjust-vma.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
# ADJUST: 0000000000000000 <debug_str_sym>:
6060
# ADJUST-NEXT: 0: {{.*}} %al, (%rax)
61-
# ADJUST-NEXT: 0000000000123001: R_X86_64_32 .text
61+
# ADJUST-NEXT: 0000000000000001: R_X86_64_32 .text
6262
# ADJUST-NEXT: 2: {{.*}} addb %al, (%rax)
6363

6464
# COMMON: 0000000000000000 <.rela.debug_str>:

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,16 +2533,8 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
25332533
if (InlineRelocs && Obj.getArch() != Triple::hexagon) {
25342534
while (findRel()) {
25352535
// When --adjust-vma is used, update the address printed.
2536-
if (RelCur->getSymbol() != Obj.symbol_end()) {
2537-
Expected<section_iterator> SymSI =
2538-
RelCur->getSymbol()->getSection();
2539-
if (SymSI && *SymSI != Obj.section_end() &&
2540-
shouldAdjustVA(**SymSI))
2541-
RelOffset += AdjustVMA;
2542-
}
2543-
25442536
printRelocation(FOS, Obj.getFileName(), *RelCur,
2545-
SectionAddr + RelOffset, Is64Bits);
2537+
SectionAddr + RelOffset + VMAAdjustment, Is64Bits);
25462538
LVP.printAfterOtherLine(FOS, true);
25472539
++RelCur;
25482540
}

0 commit comments

Comments
 (0)