Skip to content

[dsymutil] Relocate DW_TAG_label #2761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/lib/DWARFLinker/DWARFLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,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
Expand All @@ -1080,7 +1081,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;
Expand Down
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions llvm/test/tools/dsymutil/X86/label2.test
Original file line number Diff line number Diff line change
@@ -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: llvm-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)