[llvm] e0577b3 - [dsymutil] Relocate DW_TAG_label
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 29 15:53:30 PDT 2021
Author: Jonas Devlieghere
Date: 2021-03-29T15:45:48-07:00
New Revision: e0577b3130a646b0ee090c04a40400483031c7a9
URL: https://github.com/llvm/llvm-project/commit/e0577b3130a646b0ee090c04a40400483031c7a9
DIFF: https://github.com/llvm/llvm-project/commit/e0577b3130a646b0ee090c04a40400483031c7a9.diff
LOG: [dsymutil] Relocate DW_TAG_label
dsymutil is not relocating the DW_AT_low_pc for a DW_TAG_label. This
patch fixes that and adds a test.
Differential revision: https://reviews.llvm.org/D99534
Added:
llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.o
llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.out
llvm/test/tools/dsymutil/X86/label2.test
Modified:
llvm/lib/DWARFLinker/DWARFLinker.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 4846b5c10084..453b74694990 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -1088,7 +1088,8 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
if (AttrSpec.Attr == dwarf::DW_AT_low_pc) {
if (Die.getTag() == dwarf::DW_TAG_inlined_subroutine ||
- Die.getTag() == dwarf::DW_TAG_lexical_block)
+ Die.getTag() == dwarf::DW_TAG_lexical_block ||
+ Die.getTag() == dwarf::DW_TAG_label) {
// The low_pc of a block or inline subroutine might get
// relocated because it happens to match the low_pc of the
// enclosing subprogram. To prevent issues with that, always use
@@ -1097,7 +1098,7 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
? Info.OrigLowPc
: Addr) +
Info.PCOffset;
- else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
+ } else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
Addr = Unit.getLowPc();
if (Addr == std::numeric_limits<uint64_t>::max())
return 0;
diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.o
new file mode 100644
index 000000000000..e999a42f7933
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.o
diff er
diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.out b/llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.out
new file mode 100755
index 000000000000..21e92d56a260
Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/label/label.out
diff er
diff --git a/llvm/test/tools/dsymutil/X86/label2.test b/llvm/test/tools/dsymutil/X86/label2.test
new file mode 100644
index 000000000000..fa31cdc29744
--- /dev/null
+++ b/llvm/test/tools/dsymutil/X86/label2.test
@@ -0,0 +1,21 @@
+$ cat label.c
+int main(int argc, char **argv) {
+ if (argc) {
+ goto foobar;
+ }
+ return 1;
+foobar:
+ return 0;
+}
+
+$ clang -g label.c -c -o label.o
+$ clang label.o -o label.out
+
+RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/label/label.out -o %t.dSYM
+RUN: dwarfdump %t.dSYM | FileCheck %s
+
+CHECK: DW_TAG_label
+CHECK-NEXT: DW_AT_name ("foobar")
+CHECK-NEXT: DW_AT_decl_file ("/tmp/label/label.c")
+CHECK-NEXT: DW_AT_decl_line (6)
+CHECK-NEXT: DW_AT_low_pc (0x0000000100003f9d)
More information about the llvm-commits
mailing list