Skip to content

Commit 5d07dc8

Browse files
committed
[dsymutil] Don't emit .debug_pubnames and .debug_pubtypes
Consider the .debug_pubnames and .debug_pubtypes their own kind of accelerator and stop emitting them together with the Apple-style accelerator tables. The only reason we were still emitting both was for (byte-for-byte) compatibility with dsymutil-classic. - This patch adds a new accelerator table kind "Pub" which can be specified with --accelerator=Pub. - This patch removes the ability to emit both pubnames/types and apple style accelerator tables. I don't think anyone is relying on that but it's worth pointing out. - This patch removes the --minimize option and makes this behavior the default. Specifying the flag will result in a warning but won't abort the program. Differential revision: https://reviews.llvm.org/D99907
1 parent c4c98c1 commit 5d07dc8

File tree

17 files changed

+276
-136
lines changed

17 files changed

+276
-136
lines changed

llvm/include/llvm/DWARFLinker/DWARFLinker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum class AccelTableKind {
2626
Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
2727
Dwarf, ///< DWARF v5 .debug_names.
2828
Default, ///< Dwarf for DWARF5 or later, Apple otherwise.
29+
Pub, ///< .debug_pubnames, .debug_pubtypes
2930
};
3031

3132
/// Partial address range. Besides an offset, only the
@@ -708,6 +709,7 @@ class DWARFLinker {
708709
void emitAcceleratorEntriesForUnit(CompileUnit &Unit);
709710
void emitDwarfAcceleratorEntriesForUnit(CompileUnit &Unit);
710711
void emitAppleAcceleratorEntriesForUnit(CompileUnit &Unit);
712+
void emitPubAcceleratorEntriesForUnit(CompileUnit &Unit);
711713

712714
/// Patch the frame info for an object file and emit it.
713715
void patchFrameInfoForObject(const DWARFFile &, RangesTy &Ranges,

llvm/include/llvm/DWARFLinker/DWARFStreamer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class DwarfStreamer : public DwarfEmitter {
4444
public:
4545
DwarfStreamer(OutputFileType OutFileType, raw_pwrite_stream &OutFile,
4646
std::function<StringRef(StringRef Input)> Translator,
47-
bool Minimize, messageHandler Error, messageHandler Warning)
47+
messageHandler Error, messageHandler Warning)
4848
: OutFile(OutFile), OutFileType(OutFileType), Translator(Translator),
49-
Minimize(Minimize), ErrorHandler(Error), WarningHandler(Warning) {}
49+
ErrorHandler(Error), WarningHandler(Warning) {}
5050

5151
bool init(Triple TheTriple);
5252

@@ -189,7 +189,6 @@ class DwarfStreamer : public DwarfEmitter {
189189
raw_pwrite_stream &OutFile;
190190
OutputFileType OutFileType = OutputFileType::Object;
191191
std::function<StringRef(StringRef Input)> Translator;
192-
bool Minimize = true;
193192

194193
uint64_t RangesSectionSize = 0;
195194
uint64_t LocSectionSize = 0;

llvm/lib/DWARFLinker/DWARFLinker.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,9 @@ void DWARFLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) {
17941794
case AccelTableKind::Dwarf:
17951795
emitDwarfAcceleratorEntriesForUnit(Unit);
17961796
break;
1797+
case AccelTableKind::Pub:
1798+
emitPubAcceleratorEntriesForUnit(Unit);
1799+
break;
17971800
case AccelTableKind::Default:
17981801
llvm_unreachable("The default must be updated to a concrete value.");
17991802
break;
@@ -1807,13 +1810,11 @@ void DWARFLinker::emitAppleAcceleratorEntriesForUnit(CompileUnit &Unit) {
18071810
Namespace.Die->getOffset() + Unit.getStartOffset());
18081811

18091812
/// Add names.
1810-
TheDwarfEmitter->emitPubNamesForUnit(Unit);
18111813
for (const auto &Pubname : Unit.getPubnames())
18121814
AppleNames.addName(Pubname.Name,
18131815
Pubname.Die->getOffset() + Unit.getStartOffset());
18141816

18151817
/// Add types.
1816-
TheDwarfEmitter->emitPubTypesForUnit(Unit);
18171818
for (const auto &Pubtype : Unit.getPubtypes())
18181819
AppleTypes.addName(
18191820
Pubtype.Name, Pubtype.Die->getOffset() + Unit.getStartOffset(),
@@ -1839,6 +1840,11 @@ void DWARFLinker::emitDwarfAcceleratorEntriesForUnit(CompileUnit &Unit) {
18391840
Pubtype.Die->getTag(), Unit.getUniqueID());
18401841
}
18411842

1843+
void DWARFLinker::emitPubAcceleratorEntriesForUnit(CompileUnit &Unit) {
1844+
TheDwarfEmitter->emitPubNamesForUnit(Unit);
1845+
TheDwarfEmitter->emitPubTypesForUnit(Unit);
1846+
}
1847+
18421848
/// Read the frame info stored in the object, and emit the
18431849
/// patched frame descriptions for the resulting file.
18441850
///
@@ -2545,6 +2551,9 @@ bool DWARFLinker::link() {
25452551
case AccelTableKind::Dwarf:
25462552
TheDwarfEmitter->emitDebugNames(DebugNames);
25472553
break;
2554+
case AccelTableKind::Pub:
2555+
// Already emitted by emitPubAcceleratorEntriesForUnit.
2556+
break;
25482557
case AccelTableKind::Default:
25492558
llvm_unreachable("Default should have already been resolved.");
25502559
break;

llvm/lib/DWARFLinker/DWARFStreamer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,12 @@ void DwarfStreamer::emitPubSectionForUnit(
761761

762762
/// Emit .debug_pubnames for \p Unit.
763763
void DwarfStreamer::emitPubNamesForUnit(const CompileUnit &Unit) {
764-
if (Minimize)
765-
return;
766764
emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubNamesSection(),
767765
"names", Unit, Unit.getPubnames());
768766
}
769767

770768
/// Emit .debug_pubtypes for \p Unit.
771769
void DwarfStreamer::emitPubTypesForUnit(const CompileUnit &Unit) {
772-
if (Minimize)
773-
return;
774770
emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubTypesSection(),
775771
"types", Unit, Unit.getPubtypes());
776772
}

llvm/test/tools/dsymutil/ARM/obfuscated.test

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ RUN: dsymutil --symbol-map %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.a
44
RUN: | llvm-dwarfdump -v - \
55
RUN: | FileCheck %s
66

7+
RUN: dsymutil --accelerator=Pub --symbol-map %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.arm64 -f -o - \
8+
RUN: | llvm-dwarfdump -v - \
9+
RUN: | FileCheck --check-prefix=PUB %s
10+
711
RUN: dsymutil --symbol-map %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.arm64 -f -o - \
812
RUN: | llvm-dwarfdump -v - \
913
RUN: | FileCheck --check-prefix=NOHIDDEN %s
@@ -118,21 +122,21 @@ CHECK: dir_index: 0
118122
CHECK: mod_time: 0x00000000
119123
CHECK: length: 0x00000000
120124

121-
CHECK: .debug_pubnames contents:
122-
CHECK: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000044
123-
CHECK: 0x0000002e "main"
124-
CHECK: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000044, unit_size = 0x00000044
125-
CHECK: 0x0000002e "one"
126-
CHECK: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000088, unit_size = 0x00000044
127-
CHECK: 0x0000002e "two"
128-
CHECK: length = 0x00000018, format = DWARF32, version = 0x0002, unit_offset = 0x000000cc, unit_size = 0x00000044
129-
CHECK: 0x0000002e "three"
130-
CHECK: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000110, unit_size = 0x00000044
131-
CHECK: 0x0000002e "four"
132-
CHECK: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000154, unit_size = 0x00000044
133-
CHECK: 0x0000002e "five"
134-
CHECK: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000198, unit_size = 0x00000044
135-
CHECK: 0x0000002e "six"
125+
PUB: .debug_pubnames contents:
126+
PUB: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000044
127+
PUB: 0x0000002e "main"
128+
PUB: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000044, unit_size = 0x00000044
129+
PUB: 0x0000002e "one"
130+
PUB: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000088, unit_size = 0x00000044
131+
PUB: 0x0000002e "two"
132+
PUB: length = 0x00000018, format = DWARF32, version = 0x0002, unit_offset = 0x000000cc, unit_size = 0x00000044
133+
PUB: 0x0000002e "three"
134+
PUB: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000110, unit_size = 0x00000044
135+
PUB: 0x0000002e "four"
136+
PUB: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000154, unit_size = 0x00000044
137+
PUB: 0x0000002e "five"
138+
PUB: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000198, unit_size = 0x00000044
139+
PUB: 0x0000002e "six"
136140

137141
CHECK: .apple_names contents:
138142

llvm/test/tools/dsymutil/X86/basic-linking-bundle.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ RUN: rm -rf %t
22
RUN: mkdir -p %t/dsymdest
33
RUN: cat %p/../Inputs/basic.macho.x86_64 > %t/basic.macho.x86_64
44

5-
RUN: dsymutil -oso-prepend-path=%p/.. %t/basic.macho.x86_64
5+
RUN: dsymutil -accelerator=Pub -oso-prepend-path=%p/.. %t/basic.macho.x86_64
66

77
Check that the object file in the bundle exists and is sane:
88
RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test

llvm/test/tools/dsymutil/X86/basic-linking-x86.test

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
RUN: cat %p/../Inputs/basic.macho.x86_64 > %t1
2-
RUN: dsymutil -f -oso-prepend-path=%p/.. %t1
2+
RUN: dsymutil -accelerator=Pub -f -oso-prepend-path=%p/.. %t1
33
RUN: llvm-dwarfdump -a %t1.dwarf | FileCheck %s
4-
RUN: dsymutil -f -o %t2 -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64
4+
RUN: dsymutil -accelerator=Pub -f -o %t2 -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64
55
RUN: llvm-dwarfdump -a %t2 | FileCheck %s
6-
RUN: dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC
7-
RUN: dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE
8-
RUN: dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | dsymutil -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC
9-
RUN: dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | dsymutil -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE
6+
RUN: dsymutil -accelerator=Pub -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC,PUB
7+
RUN: dsymutil -accelerator=Pub -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE,PUB
8+
RUN: dsymutil -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | dsymutil -accelerator=Pub -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC,PUB
9+
RUN: dsymutil -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | dsymutil -accelerator=Pub -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE,PUB
1010

1111
CHECK: file format Mach-O 64-bit x86-64
1212

@@ -189,30 +189,30 @@ CHECK-NEXT: 0x0000000100000f90 11 0 1 0 0 is_stmt
189189
CHECK-NEXT: 0x0000000100000f9b 12 0 1 0 0 is_stmt prologue_end
190190
CHECK-NEXT: 0x0000000100000fa9 12 0 1 0 0 is_stmt end_sequence
191191

192-
CHECK: .debug_pubnames contents:
193-
CHECK-NEXT: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000081
194-
CHECK-NEXT: Offset Name
195-
CHECK-NEXT: 0x00000026 "main"
196-
CHECK-NEXT: length = 0x00000036, format = DWARF32, version = 0x0002, unit_offset = 0x00000081, unit_size = 0x000000a5
197-
CHECK-NEXT: Offset Name
198-
CHECK-NEXT: 0x0000002d "private_int"
199-
CHECK-NEXT: 0x00000042 "baz"
200-
CHECK-NEXT: 0x00000057 "foo"
201-
CHECK-NEXT: 0x00000086 "inc"
202-
CHECK-NEXT: length = 0x00000026, format = DWARF32, version = 0x0002, unit_offset = 0x00000126, unit_size = 0x00000096
203-
CHECK-NEXT: Offset Name
204-
CHECK-NEXT: 0x00000026 "val"
205-
CHECK-NEXT: 0x00000048 "bar"
206-
CHECK-NEXT: 0x00000077 "inc"
207-
208-
CHECK: .debug_pubtypes contents:
209-
CHECK-NEXT: length = 0x0000001f, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000081
210-
CHECK-NEXT: Offset Name
211-
CHECK-NEXT: 0x00000063 "int"
212-
CHECK-NEXT: 0x00000079 "char"
213-
CHECK-NEXT: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000081, unit_size = 0x000000a5
214-
CHECK-NEXT: Offset Name
215-
CHECK-NEXT: 0x00000026 "int"
216-
CHECK-NEXT: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000126, unit_size = 0x00000096
217-
CHECK-NEXT: Offset Name
218-
CHECK-NEXT: 0x00000041 "int"
192+
PUB: .debug_pubnames contents:
193+
PUB-NEXT: length = 0x00000017, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000081
194+
PUB-NEXT: Offset Name
195+
PUB-NEXT: 0x00000026 "main"
196+
PUB-NEXT: length = 0x00000036, format = DWARF32, version = 0x0002, unit_offset = 0x00000081, unit_size = 0x000000a5
197+
PUB-NEXT: Offset Name
198+
PUB-NEXT: 0x0000002d "private_int"
199+
PUB-NEXT: 0x00000042 "baz"
200+
PUB-NEXT: 0x00000057 "foo"
201+
PUB-NEXT: 0x00000086 "inc"
202+
PUB-NEXT: length = 0x00000026, format = DWARF32, version = 0x0002, unit_offset = 0x00000126, unit_size = 0x00000096
203+
PUB-NEXT: Offset Name
204+
PUB-NEXT: 0x00000026 "val"
205+
PUB-NEXT: 0x00000048 "bar"
206+
PUB-NEXT: 0x00000077 "inc"
207+
208+
PUB: .debug_pubtypes contents:
209+
PUB-NEXT: length = 0x0000001f, format = DWARF32, version = 0x0002, unit_offset = 0x00000000, unit_size = 0x00000081
210+
PUB-NEXT: Offset Name
211+
PUB-NEXT: 0x00000063 "int"
212+
PUB-NEXT: 0x00000079 "char"
213+
PUB-NEXT: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000081, unit_size = 0x000000a5
214+
PUB-NEXT: Offset Name
215+
PUB-NEXT: 0x00000026 "int"
216+
PUB-NEXT: length = 0x00000016, format = DWARF32, version = 0x0002, unit_offset = 0x00000126, unit_size = 0x00000096
217+
PUB-NEXT: Offset Name
218+
PUB-NEXT: 0x00000041 "int"

0 commit comments

Comments
 (0)