1 From cb411520cb7cd5e6e25966911ca55feb5de779e0 Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <mh@glandium.org>
3 Date: Fri, 4 Nov 2022 14:51:38 +0900
4 Subject: [PATCH] Revert "[symbolizer] Parse DW_TAG_variable DIs to show line
7 This reverts commit cead4eceb01b935fae07bf4a7e91911b344d2fec for causing
8 yet unidentified problems on some webrtc tests under TSan (bug 1798613).
10 llvm/include/llvm/DebugInfo/DIContext.h | 4 -
11 .../llvm/DebugInfo/DWARF/DWARFContext.h | 2 -
12 llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h | 7 -
13 llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h | 14 -
14 llvm/include/llvm/DebugInfo/PDB/PDBContext.h | 2 -
15 llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 97 ++--
16 llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 60 ---
17 llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 97 ----
18 llvm/lib/DebugInfo/PDB/PDBContext.cpp | 7 -
19 llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp | 4 -
20 .../Symbolize/SymbolizableObjectFile.cpp | 8 -
21 .../Symbolize/ELF/data-command-symtab.yaml | 3 -
22 .../tools/llvm-symbolizer/data-location.yaml | 450 ------------------
23 llvm/test/tools/llvm-symbolizer/data.s | 3 -
24 14 files changed, 61 insertions(+), 697 deletions(-)
25 delete mode 100644 llvm/test/tools/llvm-symbolizer/data-location.yaml
27 diff --git a/llvm/include/llvm/DebugInfo/DIContext.h b/llvm/include/llvm/DebugInfo/DIContext.h
28 index 9b278b696073..a9f98588cf2d 100644
29 --- a/llvm/include/llvm/DebugInfo/DIContext.h
30 +++ b/llvm/include/llvm/DebugInfo/DIContext.h
31 @@ -114,8 +114,6 @@ struct DIGlobal {
35 - std::string DeclFile;
36 - uint64_t DeclLine = 0;
38 DIGlobal() : Name(DILineInfo::BadString) {}
40 @@ -241,8 +239,6 @@ public:
41 virtual DILineInfo getLineInfoForAddress(
42 object::SectionedAddress Address,
43 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
45 - getLineInfoForDataAddress(object::SectionedAddress Address) = 0;
46 virtual DILineInfoTable getLineInfoForAddressRange(
47 object::SectionedAddress Address, uint64_t Size,
48 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
49 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
50 index bf591ed554c6..3365ef8d8ee3 100644
51 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
52 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
53 @@ -364,8 +364,6 @@ public:
54 DILineInfo getLineInfoForAddress(
55 object::SectionedAddress Address,
56 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
58 - getLineInfoForDataAddress(object::SectionedAddress Address) override;
59 DILineInfoTable getLineInfoForAddressRange(
60 object::SectionedAddress Address, uint64_t Size,
61 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
62 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
63 index 149c5ef4e493..4a4d105a2b23 100644
64 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
65 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
66 @@ -280,13 +280,6 @@ public:
67 /// \returns an iterator range for the attributes of the current DIE.
68 iterator_range<attribute_iterator> attributes() const;
70 - /// Gets the type size (in bytes) for this DIE.
72 - /// \param PointerSize the pointer size of the containing CU.
73 - /// \returns if this is a type DIE, or this DIE contains a DW_AT_type, returns
74 - /// the size of the type.
75 - std::optional<uint64_t> getTypeSize(uint64_t PointerSize);
79 iterator begin() const;
80 diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
81 index 9188865b4d77..0341344bc7b8 100644
82 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
83 +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
85 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
86 #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
88 -#include "llvm/ADT/DenseSet.h"
89 #include "llvm/ADT/STLExtras.h"
90 #include "llvm/ADT/SmallVector.h"
91 #include "llvm/ADT/StringRef.h"
100 @@ -242,11 +240,6 @@ class DWARFUnit {
101 /// std::map::upper_bound for address range lookup.
102 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
104 - /// Map from the location (interpreted DW_AT_location) of a DW_TAG_variable,
105 - /// to the end address and the corresponding DIE.
106 - std::map<uint64_t, std::pair<uint64_t, DWARFDie>> VariableDieMap;
107 - DenseSet<uint64_t> RootsParsedForVariables;
109 using die_iterator_range =
110 iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>;
112 @@ -329,9 +322,6 @@ public:
113 /// Recursively update address to Die map.
114 void updateAddressDieMap(DWARFDie Die);
116 - /// Recursively update address to variable Die map.
117 - void updateVariableDieMap(DWARFDie Die);
119 void setRangesSection(const DWARFSection *RS, uint64_t Base) {
121 RangeSectionBase = Base;
122 @@ -446,10 +436,6 @@ public:
124 DWARFDie getSubroutineForAddress(uint64_t Address);
126 - /// Returns variable DIE for the address provided. The pointer is alive as
127 - /// long as parsed compile unit DIEs are not cleared.
128 - DWARFDie getVariableForAddress(uint64_t Address);
130 /// getInlinedChainForAddress - fetches inlined chain for a given address.
131 /// Returns empty chain if there is no subprogram containing address. The
132 /// chain is valid as long as parsed compile unit DIEs are not cleared.
133 diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBContext.h b/llvm/include/llvm/DebugInfo/PDB/PDBContext.h
134 index 3163c0a1dae0..7b6793f0a639 100644
135 --- a/llvm/include/llvm/DebugInfo/PDB/PDBContext.h
136 +++ b/llvm/include/llvm/DebugInfo/PDB/PDBContext.h
137 @@ -45,8 +45,6 @@ namespace pdb {
138 DILineInfo getLineInfoForAddress(
139 object::SectionedAddress Address,
140 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
142 - getLineInfoForDataAddress(object::SectionedAddress Address) override;
143 DILineInfoTable getLineInfoForAddressRange(
144 object::SectionedAddress Address, uint64_t Size,
145 DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override;
146 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
147 index 19d7d659a86a..1bcfdecfd588 100644
148 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
149 +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
150 @@ -1053,25 +1053,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
151 // First, get the offset of the compile unit.
152 uint64_t CUOffset = getDebugAranges()->findAddress(Address);
153 // Retrieve the compile unit.
154 - if (DWARFCompileUnit *OffsetCU = getCompileUnitForOffset(CUOffset))
157 - // Global variables are often not found by the above search, for one of two
159 - // 1. .debug_aranges may not include global variables. On clang, it seems we
160 - // put the globals in the aranges, but this isn't true for gcc.
161 - // 2. Even if the global variable is in a .debug_arange, global variables
162 - // may not be captured in the [start, end) addresses described by the
163 - // parent compile unit.
165 - // So, we walk the CU's and their child DI's manually, looking for the
166 - // specific global variable.
167 - for (std::unique_ptr<DWARFUnit> &CU : compile_units()) {
168 - if (CU->getVariableForAddress(Address)) {
169 - return static_cast<DWARFCompileUnit *>(CU.get());
173 + return getCompileUnitForOffset(CUOffset);
176 DWARFContext::DIEsForAddress DWARFContext::getDIEsForAddress(uint64_t Address,
177 @@ -1141,6 +1123,64 @@ static bool getFunctionNameAndStartLineForAddress(
181 +static std::optional<uint64_t> getTypeSize(DWARFDie Type, uint64_t PointerSize) {
182 + if (auto SizeAttr = Type.find(DW_AT_byte_size))
183 + if (std::optional<uint64_t> Size = SizeAttr->getAsUnsignedConstant())
186 + switch (Type.getTag()) {
187 + case DW_TAG_pointer_type:
188 + case DW_TAG_reference_type:
189 + case DW_TAG_rvalue_reference_type:
190 + return PointerSize;
191 + case DW_TAG_ptr_to_member_type: {
192 + if (DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type))
193 + if (BaseType.getTag() == DW_TAG_subroutine_type)
194 + return 2 * PointerSize;
195 + return PointerSize;
197 + case DW_TAG_const_type:
198 + case DW_TAG_immutable_type:
199 + case DW_TAG_volatile_type:
200 + case DW_TAG_restrict_type:
201 + case DW_TAG_typedef: {
202 + if (DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type))
203 + return getTypeSize(BaseType, PointerSize);
206 + case DW_TAG_array_type: {
207 + DWARFDie BaseType = Type.getAttributeValueAsReferencedDie(DW_AT_type);
209 + return std::optional<uint64_t>();
210 + std::optional<uint64_t> BaseSize = getTypeSize(BaseType, PointerSize);
212 + return std::optional<uint64_t>();
213 + uint64_t Size = *BaseSize;
214 + for (DWARFDie Child : Type) {
215 + if (Child.getTag() != DW_TAG_subrange_type)
218 + if (auto ElemCountAttr = Child.find(DW_AT_count))
219 + if (std::optional<uint64_t> ElemCount =
220 + ElemCountAttr->getAsUnsignedConstant())
221 + Size *= *ElemCount;
222 + if (auto UpperBoundAttr = Child.find(DW_AT_upper_bound))
223 + if (std::optional<int64_t> UpperBound =
224 + UpperBoundAttr->getAsSignedConstant()) {
225 + int64_t LowerBound = 0;
226 + if (auto LowerBoundAttr = Child.find(DW_AT_lower_bound))
227 + LowerBound = LowerBoundAttr->getAsSignedConstant().value_or(0);
228 + Size *= *UpperBound - LowerBound + 1;
236 + return std::optional<uint64_t>();
239 static std::optional<int64_t>
240 getExpressionFrameOffset(ArrayRef<uint8_t> Expr,
241 std::optional<unsigned> FrameBaseReg) {
242 @@ -1201,7 +1241,7 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
243 if (std::optional<const char *> Name = dwarf::toString(*NameAttr))
245 if (auto Type = Die.getAttributeValueAsReferencedDie(DW_AT_type))
246 - Local.Size = Type.getTypeSize(getCUAddrSize());
247 + Local.Size = getTypeSize(Type, getCUAddrSize());
248 if (auto DeclFileAttr = Die.find(DW_AT_decl_file)) {
249 if (const auto *LT = CU->getContext().getLineTableForUnit(CU))
250 LT->getFileNameByIndex(
251 @@ -1242,6 +1282,7 @@ DWARFContext::getLocalsForAddress(object::SectionedAddress Address) {
252 DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
253 DILineInfoSpecifier Spec) {
256 DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
259 @@ -1256,22 +1297,6 @@ DILineInfo DWARFContext::getLineInfoForAddress(object::SectionedAddress Address,
260 Spec.FLIKind, Result);
268 -DWARFContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
270 - DWARFCompileUnit *CU = getCompileUnitForAddress(Address.Address);
274 - if (DWARFDie Die = CU->getVariableForAddress(Address.Address)) {
275 - Result.FileName = Die.getDeclFile(FileLineInfoKind::AbsoluteFilePath);
276 - Result.Line = Die.getDeclLine();
282 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
283 index 66492f7bf804..357b172bf99b 100644
284 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
285 +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
286 @@ -556,11 +556,6 @@ getTypeSizeImpl(DWARFDie Die, uint64_t PointerSize,
290 -std::optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
291 - SmallPtrSet<const DWARFDebugInfoEntry *, 4> Visited;
292 - return getTypeSizeImpl(*this, PointerSize, Visited);
295 /// Helper to dump a DIE with all of its parents, but no siblings.
296 static unsigned dumpParentChain(DWARFDie Die, raw_ostream &OS, unsigned Indent,
297 DIDumpOptions DumpOpts, unsigned Depth = 0) {
298 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
299 index 74667fcb92bc..148711f0246f 100644
300 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
301 +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
303 #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
304 #include "llvm/ADT/SmallString.h"
305 #include "llvm/ADT/StringRef.h"
306 -#include "llvm/BinaryFormat/Dwarf.h"
307 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
308 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
309 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
311 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
312 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
313 #include "llvm/DebugInfo/DWARF/DWARFDie.h"
314 -#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
315 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
316 #include "llvm/DebugInfo/DWARF/DWARFListTable.h"
317 #include "llvm/DebugInfo/DWARF/DWARFObject.h"
318 #include "llvm/DebugInfo/DWARF/DWARFSection.h"
319 #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
320 -#include "llvm/Object/ObjectFile.h"
321 #include "llvm/Support/DataExtractor.h"
322 #include "llvm/Support/Errc.h"
323 #include "llvm/Support/Path.h"
324 @@ -752,100 +749,6 @@ DWARFDie DWARFUnit::getSubroutineForAddress(uint64_t Address) {
325 return R->second.second;
328 -void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
329 - for (DWARFDie Child : Die) {
330 - if (isType(Child.getTag()))
332 - updateVariableDieMap(Child);
335 - if (Die.getTag() != DW_TAG_variable)
338 - Expected<DWARFLocationExpressionsVector> Locations =
339 - Die.getLocations(DW_AT_location);
341 - // Missing DW_AT_location is fine here.
342 - consumeError(Locations.takeError());
346 - uint64_t Address = UINT64_MAX;
348 - for (const DWARFLocationExpression &Location : *Locations) {
349 - uint8_t AddressSize = getAddressByteSize();
350 - DataExtractor Data(Location.Expr, isLittleEndian(), AddressSize);
351 - DWARFExpression Expr(Data, AddressSize);
352 - auto It = Expr.begin();
353 - if (It == Expr.end())
356 - // Match exactly the main sequence used to describe global variables:
357 - // `DW_OP_addr[x] [+ DW_OP_plus_uconst]`. Currently, this is the sequence
358 - // that LLVM produces for DILocalVariables and DIGlobalVariables. If, in
359 - // future, the DWARF producer (`DwarfCompileUnit::addLocationAttribute()` is
360 - // a good starting point) is extended to use further expressions, this code
361 - // needs to be updated.
362 - uint64_t LocationAddr;
363 - if (It->getCode() == dwarf::DW_OP_addr) {
364 - LocationAddr = It->getRawOperand(0);
365 - } else if (It->getCode() == dwarf::DW_OP_addrx) {
366 - uint64_t DebugAddrOffset = It->getRawOperand(0);
367 - if (auto Pointer = getAddrOffsetSectionItem(DebugAddrOffset)) {
368 - LocationAddr = Pointer->Address;
374 - // Read the optional 2nd operand, a DW_OP_plus_uconst.
375 - if (++It != Expr.end()) {
376 - if (It->getCode() != dwarf::DW_OP_plus_uconst)
379 - LocationAddr += It->getRawOperand(0);
381 - // Probe for a 3rd operand, if it exists, bail.
382 - if (++It != Expr.end())
386 - Address = LocationAddr;
390 - // Get the size of the global variable. If all else fails (i.e. the global has
391 - // no type), then we use a size of one to still allow symbolization of the
393 - uint64_t GVSize = 1;
394 - if (Die.getAttributeValueAsReferencedDie(DW_AT_type))
395 - if (std::optional<uint64_t> Size = Die.getTypeSize(getAddressByteSize()))
398 - if (Address != UINT64_MAX)
399 - VariableDieMap[Address] = {Address + GVSize, Die};
402 -DWARFDie DWARFUnit::getVariableForAddress(uint64_t Address) {
403 - extractDIEsIfNeeded(false);
405 - auto RootDie = getUnitDIE();
407 - auto RootLookup = RootsParsedForVariables.insert(RootDie.getOffset());
408 - if (RootLookup.second)
409 - updateVariableDieMap(RootDie);
411 - auto R = VariableDieMap.upper_bound(Address);
412 - if (R == VariableDieMap.begin())
415 - // upper_bound's previous item contains Address.
417 - if (Address >= R->second.first)
419 - return R->second.second;
423 DWARFUnit::getInlinedChainForAddress(uint64_t Address,
424 SmallVectorImpl<DWARFDie> &InlinedChain) {
425 diff --git a/llvm/lib/DebugInfo/PDB/PDBContext.cpp b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
426 index e600fb7385f1..0444093d7622 100644
427 --- a/llvm/lib/DebugInfo/PDB/PDBContext.cpp
428 +++ b/llvm/lib/DebugInfo/PDB/PDBContext.cpp
429 @@ -64,13 +64,6 @@ DILineInfo PDBContext::getLineInfoForAddress(object::SectionedAddress Address,
434 -PDBContext::getLineInfoForDataAddress(object::SectionedAddress Address) {
435 - // Unimplemented. S_GDATA and S_LDATA in CodeView (used to describe global
436 - // variables) aren't capable of carrying line information.
437 - return DILineInfo();
441 PDBContext::getLineInfoForAddressRange(object::SectionedAddress Address,
443 diff --git a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
444 index 877380213f21..496c8149782e 100644
445 --- a/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
446 +++ b/llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
447 @@ -206,10 +206,6 @@ void PlainPrinterBase::print(const Request &Request, const DIGlobal &Global) {
448 Name = DILineInfo::Addr2LineBadString;
450 OS << Global.Start << " " << Global.Size << "\n";
451 - if (Global.DeclFile.empty())
454 - OS << Global.DeclFile << ":" << Global.DeclLine << "\n";
458 diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
459 index d8ee9264b64f..fcff531895a2 100644
460 --- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
461 +++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
462 @@ -327,14 +327,6 @@ DIGlobal SymbolizableObjectFile::symbolizeData(
463 std::string FileName;
464 getNameFromSymbolTable(ModuleOffset.Address, Res.Name, Res.Start, Res.Size,
466 - Res.DeclFile = FileName;
468 - // Try and get a better filename:lineno pair from the debuginfo, if present.
469 - DILineInfo DL = DebugInfoContext->getLineInfoForDataAddress(ModuleOffset);
470 - if (DL.Line != 0) {
471 - Res.DeclFile = DL.FileName;
472 - Res.DeclLine = DL.Line;
477 diff --git a/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml b/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
478 index 83af3111c5dd..984e444b2fda 100644
479 --- a/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
480 +++ b/llvm/test/DebugInfo/Symbolize/ELF/data-command-symtab.yaml
497 diff --git a/llvm/test/tools/llvm-symbolizer/data-location.yaml b/llvm/test/tools/llvm-symbolizer/data-location.yaml
498 deleted file mode 100644
499 index 54f7d9be44a1..000000000000
500 --- a/llvm/test/tools/llvm-symbolizer/data-location.yaml
503 -## Show that when "DATA" is used with an address, it forces the found location
504 -## to be symbolized as data, including the source information.
506 -# RUN: yaml2obj %s -o %t.so
508 -# RUN: llvm-symbolizer 'DATA 0x304d0' 'DATA 0x304d1' 'DATA 0x304d3' \
509 -# RUN: 'DATA 0x304c0' 'DATA 0x304c8' 'DATA 0x304d4' 'DATA 0x304dc' \
510 -# RUN: 'DATA 0x304d8' --obj=%t.so | FileCheck %s
513 -# CHECK-NEXT: {{[0-9]+}} 4
514 -# CHECK-NEXT: /tmp/file.cpp:1
517 -## Check that lookups in the middle of the symbol are also resolved correctly.
519 -# CHECK-NEXT: {{[0-9]+}} 4
520 -# CHECK-NEXT: /tmp/file.cpp:1
523 -# CHECK-NEXT: {{[0-9]+}} 4
524 -# CHECK-NEXT: /tmp/file.cpp:1
527 -## Now, the remainder of the symbols.
528 -# CHECK-NEXT: data_global
529 -# CHECK-NEXT: {{[0-9]+}} 4
530 -# CHECK-NEXT: /tmp/file.cpp:2
533 -# CHECK-NEXT: {{[0-9]+}} 8
534 -# CHECK-NEXT: /tmp/file.cpp:4
536 -# CHECK-NEXT: f()::function_global
537 -# CHECK-NEXT: {{[0-9]+}} 4
538 -# CHECK-NEXT: /tmp/file.cpp:8
541 -## Including the one that includes an addend.
543 -# CHECK-NEXT: {{[0-9]+}} 4
544 -# CHECK-NEXT: /tmp/file.cpp:12
547 -# CHECK-NEXT: {{[0-9]+}} 4
548 -# CHECK-NEXT: /tmp/file.cpp:13
551 -## Ensure there's still a global that's offset-based.
552 -# RUN: llvm-dwarfdump --debug-info %t.so | FileCheck %s --check-prefix=OFFSET
554 -# OFFSET: DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)
556 -################################################################################
557 -## File below was generated using:
559 -## $ clang++ -g -O3 /tmp/file.cpp -shared -fuse-ld=lld -nostdlib \
560 -## -target aarch64-linux-gnuabi -mllvm -global-merge-ignore-single-use \
563 -## With /tmp/file.cpp as:
564 -## 1: int bss_global;
565 -## 2: int data_global = 2;
567 -## 4: const char* str =
571 -## 8: static int function_global;
572 -## 9: return &function_global;
575 -## 12: static int alpha;
576 -## 13: static int beta;
577 -## 14: int *f(bool b) { return beta ? &alpha : β }
580 -## ... then, one can get the offsets using `nm`, like:
581 -## $ nm out.so | grep bss_global
582 -## 00000000000038fc B bss_global
584 -## Note the use of the aarch64 target (with -nostdlib in order to allow linkage
585 -## without libraries for cross-compilation) as well as -O3 and
586 -## -global-merge-ignore-single-use. This is a specific combination that makes
587 -## the compiler emit the `alpha` global variable with a more complex
588 -## DW_AT_location than just a DW_OP_addr/DW_OP_addrx. In this instance, it
589 -## outputs a `DW_AT_location (DW_OP_addrx 0x4, DW_OP_plus_uconst 0x4)`.
591 -## Ideally, this would be tested by invoking clang directly on a C source file,
592 -## but unfortunately there's no way to do that for LLVM tests. The other option
593 -## is to compile IR to an objfile, but llvm-symbolizer doesn't understand that
594 -## two symbols can have the same address in different sections. In the code
595 -## above, for example, we'd have bss_global at .bss+0x0, and data_global at
596 -## .data+0x0, and so the symbolizer would only print one of them. Hence, we have
597 -## the ugly dso-to-yaml blob below.
599 -## For now, constant strings don't have a debuginfo entry, and so can't be
600 -## symbolized correctly. In future (if D123534 gets merged), this can be updated
601 -## to include a check that llvm-symbolizer can also symbolize constant strings,
602 -## like `str` above (basically that &"12345678" should be symbolizable)
603 -## to the specific line. Then, you can find the address of the constant string
604 -## from the relocation:
606 -## $ nm out.so | grep str
607 -## 00000000000038c0 D str
608 -## $ llvm-objdump -R out.so | grep 38c0
609 -## 00000000000038c0 R_X86_64_RELATIVE *ABS*+0x4f8 # <-- 0x4f8
610 -################################################################################
617 - Machine: EM_AARCH64
629 - Flags: [ PF_X, PF_R ]
635 - Flags: [ PF_W, PF_R ]
641 - Flags: [ PF_W, PF_R ]
647 - Flags: [ PF_W, PF_R ]
652 - - Type: PT_GNU_RELRO
657 - - Type: PT_GNU_EH_FRAME
659 - FirstSec: .eh_frame_hdr
660 - LastSec: .eh_frame_hdr
663 - - Type: PT_GNU_STACK
664 - Flags: [ PF_W, PF_R ]
669 - Flags: [ SHF_ALLOC ]
675 - Flags: [ SHF_ALLOC ]
682 - BloomFilter: [ 0x400188002180000C ]
683 - HashBuckets: [ 0x1 ]
684 - HashValues: [ 0xEE8502A, 0xEE85016, 0xC033991C, 0x61F7372E, 0xB88AB7F ]
687 - Flags: [ SHF_ALLOC ]
691 - Bucket: [ 5, 0, 4, 0, 3, 0 ]
692 - Chain: [ 0, 0, 0, 1, 2, 0 ]
695 - Flags: [ SHF_ALLOC ]
700 - Flags: [ SHF_ALLOC ]
706 - Type: R_AARCH64_RELATIVE
710 - Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
714 - Content: '313233343536373800'
715 - - Name: .eh_frame_hdr
717 - Flags: [ SHF_ALLOC ]
720 - Content: 011B033B18000000020000006800010034000000740001004C000000
723 - Flags: [ SHF_ALLOC ]
726 - Content: 1400000000000000017A5200017C1E011B0C1F0000000000140000001C0000002C0001000C00000000000000000000001400000034000000200001001C000000000000000000000000000000
729 - Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
732 - Content: 0001009000501391C0035FD60801009008611391E90308AA2A4540B85F0100710001899AC0035FD6
735 - Flags: [ SHF_WRITE, SHF_ALLOC ]
746 - - Tag: DT_RELACOUNT
764 - Flags: [ SHF_WRITE, SHF_ALLOC ]
767 - Content: '02000000000000000000000000000000'
770 - Flags: [ SHF_WRITE, SHF_ALLOC ]
774 - - Name: .debug_abbrev
777 - Content: 011101252513050325721710171B25111B120673170000023400032549133F193A0B3B0B0218000003240003253E0B0B0B0000040F004913000005260049130000062E01111B120640187A196E2503253A0B3B0B49133F190000073400032549133A0B3B0B02180000083400032549133A0B3B0B02186E25000009050003253A0B3B0B4913000000
778 - - Name: .debug_info
781 - Content: AB0000000500010800000000010021000108000000000000000205280000000800000002032E000000000102A1000304050402052E000000000202A101020648000000000402A102044D00000005520000000307080106050C000000016F0D0E0007A500000007082E000000000802A1030008092E000000000D02A1040A080B2E000000000C04A10423040C06061C000000016F0F0E000EA50000000910000EAA00000000042E0000000311020100
782 - - Name: .debug_str_offsets
785 - Content: 4C00000005000000A2000000000000002C00000059000000280000001C00000072000000640000008C0000008700000069000000140000007B0000009C0000001A0000000E0000008500000076000000
788 - Flags: [ SHF_MERGE, SHF_STRINGS ]
791 - Content: 4C696E6B65723A204C4C442031352E302E300000636C616E672076657273696F6E2031352E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420306462616566363162353666306566306162306366333865613932666663316633356265653366662900
792 - - Name: .debug_line
795 - Content: 620000000500080037000000010101FB0E0D00010101010000000100000101011F010E00000003011F020F051E0100000000006C97BBE59F7DC6A9EA956633431DA63E0400000902E4030100000000001805030A140500BF05190A0105120608740204000101
796 - - Name: .debug_line_str
798 - Flags: [ SHF_MERGE, SHF_STRINGS ]
801 - Content: 2F746D702F66696C652E637070002F7573722F6C6F63616C2F676F6F676C652F686F6D652F6D69746368702F6C6C766D2D6275696C642F6F707400
809 - - Name: _ZZ1fvE15function_global
824 - Section: .debug_abbrev
826 - Section: .debug_info
828 - Section: .debug_str_offsets
830 - Section: .debug_str
833 - Section: .debug_addr
851 - Section: .debug_line
853 - Section: .debug_line_str
858 - Other: [ STV_HIDDEN ]
862 - Binding: STB_GLOBAL
868 - Binding: STB_GLOBAL
874 - Binding: STB_GLOBAL
877 - - Name: data_global
880 - Binding: STB_GLOBAL
886 - Binding: STB_GLOBAL
893 - Binding: STB_GLOBAL
899 - Binding: STB_GLOBAL
905 - Binding: STB_GLOBAL
908 - - Name: data_global
911 - Binding: STB_GLOBAL
917 - Binding: STB_GLOBAL
928 - - '/usr/local/google/home/mitchp/llvm-build/opt'
939 - - 'clang version 15.0.0 (https://github.com/llvm/llvm-project.git 0dbaef61b56f0ef0ab0cf38ea92ffc1f35bee3ff)'
953 diff --git a/llvm/test/tools/llvm-symbolizer/data.s b/llvm/test/tools/llvm-symbolizer/data.s
954 index cc9503c59141..e8039f146dbd 100644
955 --- a/llvm/test/tools/llvm-symbolizer/data.s
956 +++ b/llvm/test/tools/llvm-symbolizer/data.s
969 .quad 0x1122334455667788