[PATCH] D99385: [lld-macho] Add addition debug info
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 25 15:10:09 PDT 2021
oontvoo created this revision.
Herald added a reviewer: int3.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99385
Files:
lld/MachO/Dwarf.cpp
lld/MachO/Dwarf.h
Index: lld/MachO/Dwarf.h
===================================================================
--- lld/MachO/Dwarf.h
+++ lld/MachO/Dwarf.h
@@ -22,7 +22,8 @@
class ObjFile;
class MachODWARFSection final : public llvm::DWARFSection {
- InputSection *isec = nullptr;
+public:
+ const InputSection *isec = nullptr;
};
// Implements the interface between LLVM's DWARF-parsing utilities and LLD's
@@ -48,7 +49,7 @@
}
llvm::StringRef getAbbrevSection() const override { return abbrevSection; }
- StringRef getLineStrSection() const override { return lineStrSection; }
+ llvm::StringRef getLineStrSection() const override { return lineStrSection; }
llvm::StringRef getStrSection() const override { return strSection; }
// Returns an instance of DwarfObject if the given object file has the
Index: lld/MachO/Dwarf.cpp
===================================================================
--- lld/MachO/Dwarf.cpp
+++ lld/MachO/Dwarf.cpp
@@ -10,6 +10,7 @@
#include "InputFiles.h"
#include "InputSection.h"
#include "OutputSegment.h"
+#include "Symbols.h"
#include <memory>
@@ -36,7 +37,7 @@
continue;
}
- if (MachODWARFSection *m = StringSwitch<StringRef *>(isec->name)
+ if (MachODWARFSection *m = StringSwitch<MachODWARFSection *>(isec->name)
.Case("__debug_addr", &dObj->addrSection)
.Case("__debug_info", &dObj->infoSection)
.Case("__debug_line", &dObj->lineSection)
@@ -53,15 +54,20 @@
return nullptr;
}
-Optional<RelocAddrEntry> DwarfObject::find(const llvm::DWARFSection &sec,
- uint64_t pos) {
- const auto &sec = dynamic_cast<const MachODWARFSection &>(sec);
- if (sec.isec == nullptr)
+static uint64_t resolver(uint64_t Type, uint64_t Offset, uint64_t S,
+ uint64_t LocData, int64_t Addend) {
+ return S + Addend;
+}
+
+llvm::Optional<RelocAddrEntry> DwarfObject::find(const llvm::DWARFSection &sec,
+ uint64_t pos) const {
+ auto &msec = static_cast<const MachODWARFSection &>(sec);
+ if (msec.isec == nullptr)
return llvm::None;
const Reloc *found = nullptr;
// FIXME: relocs might be sorted already? (in which case, better to bisct?)
- for (const auto &reloc : sec.isec->relocs) {
+ for (const auto &reloc : msec.isec->relocs) {
if (reloc.offset == pos) {
found = &reloc;
break;
@@ -70,7 +76,7 @@
if (!found)
return llvm::None;
- const auto *sym = found->referent.dyn_cast<Symbol>();
+ const Symbol *sym = found->referent.dyn_cast<Symbol *>();
if (!sym)
return llvm::None;
@@ -80,10 +86,10 @@
val = def->value;
}
- DataRefImpl d;
+ object::DataRefImpl d;
d.p = found->addend;
- return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),
- val, Optional<object::RelocationRef>(),
- 0, LLDRelocationResolver<RelTy>::resolve};
+ return RelocAddrEntry{secIndex, object::RelocationRef(d, nullptr),
+ val, llvm::Optional<object::RelocationRef>(),
+ 0, resolver};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99385.333434.patch
Type: text/x-patch
Size: 3238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210325/ce7a1bfd/attachment.bin>
More information about the llvm-commits
mailing list