[PATCH] D153027: [llvm-objdump] --adjust-vma adjust symbol table
Hamidreza Sanaee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 25 08:26:36 PDT 2023
HamidrezaSK updated this revision to Diff 534331.
HamidrezaSK marked an inline comment as done.
HamidrezaSK edited the summary of this revision.
HamidrezaSK added a comment.
Adjust the indentation symbol table test ADJUST blocks to line up with the NOADJUST blocks.
Adjust the guard on top of the address update to if (SecI != O.section_end() && shouldAdjustVA(*SecI)) to protect a dereference of O.section_end().
Adjust adjust-vma test to add SHN_ABS symbol test (D153401 <https://reviews.llvm.org/D153401>).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153027/new/
https://reviews.llvm.org/D153027
Files:
llvm/test/tools/llvm-objdump/X86/adjust-vma.test
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -2400,6 +2400,9 @@
const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(&O);
uint64_t Address = unwrapOrError(Symbol.getAddress(), FileName, ArchiveName,
ArchitectureName);
+ section_iterator SecI = unwrapOrError(Symbol.getSection(), FileName);
+ if (SecI != O.section_end() && shouldAdjustVA(*SecI))
+ Address += AdjustVMA;
if ((Address < StartAddress) || (Address > StopAddress))
return;
SymbolRef::Type Type =
Index: llvm/test/tools/llvm-objdump/X86/adjust-vma.test
===================================================================
--- llvm/test/tools/llvm-objdump/X86/adjust-vma.test
+++ llvm/test/tools/llvm-objdump/X86/adjust-vma.test
@@ -11,8 +11,8 @@
# NOADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000
# NOADJUST-NEXT: 4 .data 00000004 0000000000000000 DATA
# NOADJUST-NEXT: 5 .rela.data 00000018 0000000000000000
-# NOADJUST-NEXT: 6 .symtab 00000060 0000000000000000
-# NOADJUST-NEXT: 7 .strtab 00000010 0000000000000000
+# NOADJUST-NEXT: 6 .symtab {{.*}} 0000000000000000
+# NOADJUST-NEXT: 7 .strtab {{.*}} 0000000000000000
# NOADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000
# ADJUST: Sections:
@@ -23,14 +23,23 @@
# ADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000
# ADJUST-NEXT: 4 .data 00000004 0000000000123000 DATA
# ADJUST-NEXT: 5 .rela.data 00000018 0000000000000000
-# ADJUST-NEXT: 6 .symtab 00000060 0000000000000000
-# ADJUST-NEXT: 7 .strtab 00000010 0000000000000000
+# ADJUST-NEXT: 6 .symtab {{.*}} 0000000000000000
+# ADJUST-NEXT: 7 .strtab {{.*}} 0000000000000000
# ADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000
-# COMMON: SYMBOL TABLE:
-# COMMON-NEXT: 0000000000000001 l F .text 0000000000000000 func
-# COMMON-NEXT: 0000000000000000 l .text 0000000000000000 sym
-# COMMON-NEXT: 0000000000000000 l d .text 0000000000000000 .text
+# NOADJUST: SYMBOL TABLE:
+# NOADJUST-NEXT: 0000000000000001 l F .text 0000000000000000 func
+# NOADJUST-NEXT: 0000000000000000 l .text 0000000000000000 sym
+# NOADJUST-NEXT: 0000000000000000 l d .text 0000000000000000 .text
+# NOADJUST-NEXT: 0000000000003333 l *ABS* 0000000000000000 abs
+# NOADJUST-NEXT: 0000000000000000 l .debug_str 0000000000000000 debug_str_sym
+
+# ADJUST: SYMBOL TABLE:
+# ADJUST-NEXT: 0000000000123001 l F .text 0000000000000000 func
+# ADJUST-NEXT: 0000000000123000 l .text 0000000000000000 sym
+# ADJUST-NEXT: 0000000000123000 l d .text 0000000000000000 .text
+# ADJUST-NEXT: 0000000000003333 l *ABS* 0000000000000000 abs
+# ADJUST-NEXT: 0000000000000000 l .debug_str 0000000000000000 debug_str_sym
# NOADJUST: 0000000000000000 <sym>:
# NOADJUST-NEXT: 0: {{.*}} nop
@@ -42,12 +51,12 @@
# ADJUST: 0000000000123001 <func>:
# ADJUST-NEXT: 123001: {{.*}} retq
-# NOADJUST: 0000000000000000 <.debug_str>:
+# NOADJUST: 0000000000000000 <debug_str_sym>:
# NOADJUST-NEXT: 0: {{.*}} %al, (%rax)
# NOADJUST-NEXT: 0000000000000001: R_X86_64_32 .text
# NOADJUST-NEXT: 2: {{.*}} addb %al, (%rax)
-# ADJUST: 0000000000000000 <.debug_str>:
+# ADJUST: 0000000000000000 <debug_str_sym>:
# ADJUST-NEXT: 0: {{.*}} %al, (%rax)
# ADJUST-NEXT: 0000000000123001: R_X86_64_32 .text
# ADJUST-NEXT: 2: {{.*}} addb %al, (%rax)
@@ -120,3 +129,8 @@
- Name: .text
Type: STT_SECTION
Section: .text
+ - Name: abs
+ Index: SHN_ABS
+ Value: 0x3333
+ - Name: debug_str_sym
+ Section: .debug_str
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153027.534331.patch
Type: text/x-patch
Size: 4023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230625/e3949245/attachment-0001.bin>
More information about the llvm-commits
mailing list