mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
[DWARF parser] Fix broken address ranges construction.
Previous algorithm for constructing [Address ranges]->[Compile Units] mapping was wrong. It somewhat relied on the assumption that address ranges for different compile units may not overlap. It is not so. For example, two compile units may contain the definition of the same linkonce_odr function. These definitions will be merged at link-time, resulting in equivalent .debug_ranges entries for both these units Instead of sorting and merging original address ranges (from .debug_ranges and .debug_aranges), implement a different approach: save endpoints of all ranges, and then use a sweep-line approach to construct the desired mapping. If we find that certain address maps to several compilation units, we just pick any of them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210860 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -27,9 +27,9 @@ private:
|
||||
void clear();
|
||||
void extract(DataExtractor DebugArangesData);
|
||||
|
||||
// Use appendRange multiple times and then call sortAndMinimize.
|
||||
// Call appendRange multiple times and then call construct.
|
||||
void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
|
||||
void sortAndMinimize();
|
||||
void construct();
|
||||
|
||||
struct Range {
|
||||
explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
|
||||
@@ -47,31 +47,39 @@ private:
|
||||
return LowPC + Length;
|
||||
return -1ULL;
|
||||
}
|
||||
|
||||
bool containsAddress(uint64_t Address) const {
|
||||
return LowPC <= Address && Address < HighPC();
|
||||
}
|
||||
|
||||
bool operator <(const Range &other) const {
|
||||
bool operator<(const Range &other) const {
|
||||
return LowPC < other.LowPC;
|
||||
}
|
||||
|
||||
static bool SortedOverlapCheck(const Range &Left, const Range &Right) {
|
||||
if (Left.CUOffset != Right.CUOffset)
|
||||
return false;
|
||||
return Left.HighPC() >= Right.LowPC;
|
||||
}
|
||||
|
||||
uint64_t LowPC; // Start of address range.
|
||||
uint32_t Length; // End of address range (not including this address).
|
||||
uint32_t CUOffset; // Offset of the compile unit or die.
|
||||
};
|
||||
|
||||
struct RangeEndpoint {
|
||||
uint64_t Address;
|
||||
uint32_t CUOffset;
|
||||
bool IsRangeStart;
|
||||
|
||||
RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart)
|
||||
: Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
|
||||
|
||||
bool operator<(const RangeEndpoint &Other) const {
|
||||
return Address < Other.Address;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<Range> RangeColl;
|
||||
typedef RangeColl::const_iterator RangeCollIterator;
|
||||
typedef DenseSet<uint32_t> ParsedCUOffsetColl;
|
||||
|
||||
std::vector<RangeEndpoint> Endpoints;
|
||||
RangeColl Aranges;
|
||||
ParsedCUOffsetColl ParsedCUOffsets;
|
||||
DenseSet<uint32_t> ParsedCUOffsets;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user