forked from OSchip/llvm-project
Fix behavior with multiple functions with same address.
Summary: We were updating only one DIE per function, but because the Linker Script may map multiple functions to the same address this would cause us to generate invalid debug info (as some DIEs weren't updated but their abbreviations were changed). (cherry picked from FBD3157263)
This commit is contained in:
parent
784f6a8773
commit
665b03a464
|
@ -145,7 +145,7 @@ void BinaryContext::preprocessFunctionDebugInfo(
|
|||
if (ChildDIE->getLowAndHighPC(CU.get(), LowPC, HighPC)) {
|
||||
auto It = BinaryFunctions.find(LowPC);
|
||||
if (It != BinaryFunctions.end()) {
|
||||
It->second.setSubprocedureDIE(CU.get(), ChildDIE);
|
||||
It->second.addSubprocedureDIE(CU.get(), ChildDIE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm::object;
|
||||
|
||||
|
@ -159,11 +160,11 @@ private:
|
|||
/// Landing pads for the function.
|
||||
std::set<MCSymbol *> LandingPads;
|
||||
|
||||
/// Associated DIE in the .debug_info section.
|
||||
const DWARFDebugInfoEntryMinimal *SubprocedureDIE{nullptr};
|
||||
|
||||
/// DWARF Unit that contains the DIE of this function.
|
||||
const DWARFCompileUnit *DIECompileUnit{nullptr};
|
||||
/// Associated DIEs in the .debug_info section with their respective CUs.
|
||||
/// There can be multiple because of identical code folding performed by
|
||||
/// the Linker Script.
|
||||
std::vector<std::pair<const DWARFDebugInfoEntryMinimal *,
|
||||
const DWARFCompileUnit *>> SubprocedureDIEs;
|
||||
|
||||
/// Offset of this function's address ranges in the .debug_ranges section of
|
||||
/// the output binary.
|
||||
|
@ -757,18 +758,13 @@ public:
|
|||
void emitLSDA(MCStreamer *Streamer);
|
||||
|
||||
/// Sets the associated .debug_info entry.
|
||||
void setSubprocedureDIE(const DWARFCompileUnit *Unit,
|
||||
void addSubprocedureDIE(const DWARFCompileUnit *Unit,
|
||||
const DWARFDebugInfoEntryMinimal *DIE) {
|
||||
DIECompileUnit = Unit;
|
||||
SubprocedureDIE = DIE;
|
||||
SubprocedureDIEs.emplace_back(DIE, Unit);
|
||||
}
|
||||
|
||||
const DWARFDebugInfoEntryMinimal *getSubprocedureDIE() const {
|
||||
return SubprocedureDIE;
|
||||
}
|
||||
|
||||
const DWARFCompileUnit *getSubprocedureDIECompileUnit() const {
|
||||
return DIECompileUnit;
|
||||
const decltype(SubprocedureDIEs) &getSubprocedureDIEs() const {
|
||||
return SubprocedureDIEs;
|
||||
}
|
||||
|
||||
/// Returns the size of the basic block in the original binary.
|
||||
|
|
|
@ -2174,10 +2174,12 @@ void RewriteInstance::updateDWARFAddressRanges() {
|
|||
// Update address ranges of functions.
|
||||
for (const auto &BFI : BinaryFunctions) {
|
||||
const auto &Function = BFI.second;
|
||||
updateDWARFObjectAddressRanges(
|
||||
Function.getAddressRangesOffset() + DebugRangesSize,
|
||||
Function.getSubprocedureDIECompileUnit(),
|
||||
Function.getSubprocedureDIE());
|
||||
for (const auto DIECompileUnitPair : Function.getSubprocedureDIEs()) {
|
||||
updateDWARFObjectAddressRanges(
|
||||
Function.getAddressRangesOffset() + DebugRangesSize,
|
||||
DIECompileUnitPair.second,
|
||||
DIECompileUnitPair.first);
|
||||
}
|
||||
}
|
||||
|
||||
// Update address ranges of lexical blocks.
|
||||
|
|
Loading…
Reference in New Issue