Skip to content

Commit e0577b3

Browse files
committed
[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
1 parent 984e2f4 commit e0577b3

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
@@ -1088,7 +1088,8 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
10881088

10891089
if (AttrSpec.Attr == dwarf::DW_AT_low_pc) {
10901090
if (Die.getTag() == dwarf::DW_TAG_inlined_subroutine ||
1091-
Die.getTag() == dwarf::DW_TAG_lexical_block)
1091+
Die.getTag() == dwarf::DW_TAG_lexical_block ||
1092+
Die.getTag() == dwarf::DW_TAG_label) {
10921093
// The low_pc of a block or inline subroutine might get
10931094
// relocated because it happens to match the low_pc of the
10941095
// enclosing subprogram. To prevent issues with that, always use
@@ -1097,7 +1098,7 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute(
10971098
? Info.OrigLowPc
10981099
: Addr) +
10991100
Info.PCOffset;
1100-
else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
1101+
} else if (Die.getTag() == dwarf::DW_TAG_compile_unit) {
11011102
Addr = Unit.getLowPc();
11021103
if (Addr == std::numeric_limits<uint64_t>::max())
11031104
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: 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)