Skip to content

Commit 87fb89b

Browse files
authored
Merge pull request #2761 from apple/🍒/ganymede/e0577b3130a646b0ee090c04a40400483031c7a9
[dsymutil] Relocate DW_TAG_label
2 parents 2d6495d + 90047fc commit 87fb89b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

llvm/lib/DWARFLinker/DWARFLinker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,8 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
10711071

10721072
if (AttrSpec.Attr == dwarf::DW_AT_low_pc) {
10731073
if (Die.getTag() == dwarf::DW_TAG_inlined_subroutine ||
1074-
Die.getTag() == dwarf::DW_TAG_lexical_block)
1074+
Die.getTag() == dwarf::DW_TAG_lexical_block ||
1075+
Die.getTag() == dwarf::DW_TAG_label) {
10751076
// The low_pc of a block or inline subroutine might get
10761077
// relocated because it happens to match the low_pc of the
10771078
// enclosing subprogram. To prevent issues with that, always use
@@ -1080,7 +1081,7 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
10801081
? Info.OrigLowPc
10811082
: Addr) +
10821083
Info.PCOffset;
1083-
else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
1084+
} else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
10841085
Addr = Unit.getLowPc();
10851086
if (Addr == std::numeric_limits<uint64_t>::max())
10861087
return 0;
Binary file not shown.
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$ cat label.c
2+
int main(int argc, char **argv) {
3+
if (argc) {
4+
goto foobar;
5+
}
6+
return 1;
7+
foobar:
8+
return 0;
9+
}
10+
11+
$ clang -g label.c -c -o label.o
12+
$ clang label.o -o label.out
13+
14+
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/label/label.out -o %t.dSYM
15+
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s
16+
17+
CHECK: DW_TAG_label
18+
CHECK-NEXT: DW_AT_name ("foobar")
19+
CHECK-NEXT: DW_AT_decl_file ("/tmp/label/label.c")
20+
CHECK-NEXT: DW_AT_decl_line (6)
21+
CHECK-NEXT: DW_AT_low_pc (0x0000000100003f9d)

0 commit comments

Comments
 (0)