Skip to content

Commit a8d15ea

Browse files
committed
Reland "[llvm][dsymutil] Add DW_TAG_imported_declaration to accelerator table"
This relands the commit previously reverted in `8570bee53a8ce0c5d04bc11f288e19a457474c4c` due to failures on linux. The problem was that the test executable was built with absolute OSO prefix paths. This re-commit adds a modified version of the executable that strips the absolute OSO prefix paths and makes sure the test appends the OSO prefix appropriately (via the appropriate dsymutil flags). Differential Revision: https://reviews.llvm.org/D143458 (cherry picked from commit b8ef007)
1 parent 25b0b6b commit a8d15ea

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

llvm/lib/DWARFLinker/DWARFLinker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,8 @@ DIE *DWARFLinker::DIECloner::cloneDIE(const DWARFDie &InputDIE,
15681568
if (!AttrInfo.Name)
15691569
AttrInfo.Name = StringPool.getEntry("(anonymous namespace)");
15701570
Unit.addNamespaceAccelerator(Die, AttrInfo.Name);
1571+
} else if (Tag == dwarf::DW_TAG_imported_declaration && AttrInfo.Name) {
1572+
Unit.addNamespaceAccelerator(Die, AttrInfo.Name);
15711573
} else if (isTypeTag(Tag) && !AttrInfo.IsDeclaration &&
15721574
getDIENames(InputDIE, AttrInfo, StringPool) && AttrInfo.Name &&
15731575
AttrInfo.Name.getString()[0]) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
RUN: dsymutil -accelerator=Dwarf -oso-prepend-path=%p/../Inputs %p/../Inputs/accel-imported-declaration.macho-arm64 -o %t.dwarf.dSYM
2+
RUN: dsymutil -accelerator=Apple -oso-prepend-path=%p/../Inputs %p/../Inputs/accel-imported-declaration.macho-arm64 -o %t.apple.dSYM
3+
4+
RUN: llvm-dwarfdump -v %t.dwarf.dSYM | FileCheck %s -check-prefixes=DWARF,COMMON
5+
RUN: llvm-dwarfdump -v %t.apple.dSYM | FileCheck %s -check-prefixes=APPLE,COMMON
6+
7+
COMMON: .debug_info contents
8+
COMMON: {{.*}}DW_TAG_namespace
9+
COMMON: DW_AT_name{{.*}}"A"
10+
COMMON: {{.*}}DW_TAG_namespace
11+
COMMON: DW_AT_name{{.*}}"B"
12+
COMMON: [[NAMESPACE:0x[0-9a-f]*]]:{{.*}}DW_TAG_namespace
13+
COMMON: DW_AT_name{{.*}}"C"
14+
COMMON: [[IMPORTED:0x[0-9a-f]*]]:{{.*}}DW_TAG_imported_declaration
15+
COMMON: DW_AT_name{{.*}}"C"
16+
17+
DWARF: .debug_names contents:
18+
DWARF: Bucket 0 [
19+
DWARF-NEXT: Name {{.*}} {
20+
DWARF-NEXT: Hash: {{.*}}
21+
DWARF-NEXT: String: {{.*}} "C"
22+
DWARF-NEXT: Entry {{.*}} {
23+
DWARF-NEXT: Abbrev: {{.*}}
24+
DWARF-NEXT: Tag: DW_TAG_namespace
25+
DWARF-NEXT: DW_IDX_die_offset: [[NAMESPACE]]
26+
DWARF-NEXT: }
27+
DWARF-NEXT: Entry {{.*}} {
28+
DWARF-NEXT: Abbrev: {{.*}}
29+
DWARF-NEXT: Tag: DW_TAG_imported_declaration
30+
DWARF-NEXT: DW_IDX_die_offset: [[IMPORTED]]
31+
DWARF-NEXT: }
32+
DWARF-NEXT: }
33+
34+
APPLE: .apple_namespaces contents:
35+
APPLE: Bucket 1 [
36+
APPLE-NEXT: Hash {{.*}} [
37+
APPLE-NEXT: Name@{{.*}} {
38+
APPLE-NEXT: String: {{.*}} "C"
39+
APPLE-NEXT: Data 0 [
40+
APPLE-NEXT: Atom[0]: [[NAMESPACE]]
41+
APPLE-NEXT: ]
42+
APPLE-NEXT: Data 1 [
43+
APPLE-NEXT: Atom[0]: [[IMPORTED]]
44+
APPLE-NEXT: ]
45+
APPLE-NEXT: }
46+
APPLE-NEXT: ]
47+
APPLE-NEXT: ]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Compiled on macOS using:
2+
// 1. clang++ -c -std=c++2a -gdwarf-4 -O0 -o accel-imported-declaration.macho-arm64.o
3+
// 2. clang++ -Wl,-oso_prefix=$PWD accel-imported-declaration.macho-arm64.o -o accel-imported-declaration.macho-arm64
4+
//
5+
// In step 2 it's important to strip the absolute object file paths
6+
//
7+
// Verify that the OSO path isn't absolute using `nm -ap accel-imported-declaration.macho-arm64`
8+
9+
namespace A {
10+
namespace B {
11+
namespace C {
12+
int a = -1;
13+
} // namespace C
14+
} // namespace B
15+
16+
namespace C = B::C;
17+
18+
using namespace B::C;
19+
using B::C::a;
20+
} // namespace A
21+
22+
int main() { return A::a; }
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)