forked from OSchip/llvm-project
Handle types CU list in updateGdbIndexSection
Summary: Handle types CU list in `updateGdbIndexSection`. It looks like the types part of `.gdb_index` isn't empty when `-fdebug-types-section` is used. So instead of aborting, we copy the part to new `.gdb_index` section. (cherry picked from FBD6770460)
This commit is contained in:
parent
d114ef1fa5
commit
2b8194fa50
|
@ -508,6 +508,9 @@ void RewriteInstance::updateGdbIndexSection() {
|
|||
if (!GdbIndexSection)
|
||||
return;
|
||||
|
||||
// See https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html for
|
||||
// .gdb_index section format.
|
||||
|
||||
StringRef GdbIndexContents = GdbIndexSection->getContents();
|
||||
|
||||
const auto *Data = GdbIndexContents.data();
|
||||
|
@ -529,9 +532,6 @@ void RewriteInstance::updateGdbIndexSection() {
|
|||
const auto ConstantPoolOffset = read32le(Data + 20);
|
||||
Data += 24;
|
||||
|
||||
assert(CUTypesOffset == AddressTableOffset &&
|
||||
"CU types in .gdb_index should be empty");
|
||||
|
||||
// Map CUs offsets to indices and verify existing index table.
|
||||
std::map<uint32_t, uint32_t> OffsetToIndexMap;
|
||||
const auto CUListSize = CUTypesOffset - CUListOffset;
|
||||
|
@ -553,7 +553,8 @@ void RewriteInstance::updateGdbIndexSection() {
|
|||
|
||||
// Ignore old address table.
|
||||
const auto OldAddressTableSize = SymbolTableOffset - AddressTableOffset;
|
||||
Data += OldAddressTableSize;
|
||||
// Move Data to the beginning of symbol table.
|
||||
Data += SymbolTableOffset - CUTypesOffset;
|
||||
|
||||
// Calculate the size of the new address table.
|
||||
uint32_t NewAddressTableSize = 0;
|
||||
|
@ -580,9 +581,10 @@ void RewriteInstance::updateGdbIndexSection() {
|
|||
write32le(Buffer + 20, ConstantPoolOffset + Delta);
|
||||
Buffer += 24;
|
||||
|
||||
// Copy over CU list.
|
||||
memcpy(Buffer, GdbIndexContents.data() + 24, CUListSize);
|
||||
Buffer += CUListSize;
|
||||
// Copy over CU list and types CU list.
|
||||
memcpy(Buffer, GdbIndexContents.data() + 24,
|
||||
AddressTableOffset - CUListOffset);
|
||||
Buffer += AddressTableOffset - CUListOffset;
|
||||
|
||||
// Generate new address table.
|
||||
for (const auto &CURangesPair : RangesSectionsWriter->getCUAddressRanges()) {
|
||||
|
|
Loading…
Reference in New Issue