Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/include/llvm/BinaryFormat/Dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,10 @@ struct FormParams {
return getDwarfOffsetByteSize();
}

inline uint64_t getDwarfMaxOffset() const {
return (getDwarfOffsetByteSize() == 4) ? UINT32_MAX : UINT64_MAX;
}

/// The size of a reference is determined by the DWARF 32/64-bit format.
uint8_t getDwarfOffsetByteSize() const {
return dwarf::getDwarfOffsetByteSize(Format);
Expand Down
26 changes: 13 additions & 13 deletions llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DwarfEmitter {
virtual MCSymbol *emitDwarfDebugRangeListHeader(const CompileUnit &Unit) = 0;

/// Emit debug ranges (.debug_ranges, .debug_rnglists) fragment.
virtual void emitDwarfDebugRangeListFragment(
virtual Error emitDwarfDebugRangeListFragment(
const CompileUnit &Unit, const AddressRanges &LinkedRanges,
PatchLocation Patch, DebugDieValuePool &AddrPool) = 0;

Expand All @@ -97,7 +97,7 @@ class DwarfEmitter {
virtual MCSymbol *emitDwarfDebugLocListHeader(const CompileUnit &Unit) = 0;

/// Emit debug locations (.debug_loc, .debug_loclists) fragment.
virtual void emitDwarfDebugLocListFragment(
virtual Error emitDwarfDebugLocListFragment(
const CompileUnit &Unit,
const DWARFLocationExpressionsVector &LinkedLocationExpression,
PatchLocation Patch, DebugDieValuePool &AddrPool) = 0;
Expand Down Expand Up @@ -596,23 +596,23 @@ class LLVM_ABI DWARFLinker : public DWARFLinkerBase {
/// Construct the output DIE tree by cloning the DIEs we
/// chose to keep above. If there are no valid relocs, then there's
/// nothing to clone/emit.
LLVM_ABI uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext,
const DWARFFile &File,
bool IsLittleEndian);
LLVM_ABI Expected<uint64_t> cloneAllCompileUnits(DWARFContext &DwarfContext,
const DWARFFile &File,
bool IsLittleEndian);

/// Emit the .debug_addr section for the \p Unit.
LLVM_ABI void emitDebugAddrSection(CompileUnit &Unit,
const uint16_t DwarfVersion) const;
LLVM_ABI Error emitDebugAddrSection(CompileUnit &Unit,
const uint16_t DwarfVersion) const;

using ExpressionHandlerRef = function_ref<void(
SmallVectorImpl<uint8_t> &, SmallVectorImpl<uint8_t> &,
int64_t AddrRelocAdjustment)>;

/// Compute and emit debug locations (.debug_loc, .debug_loclists)
/// for \p Unit, patch the attributes referencing it.
LLVM_ABI void generateUnitLocations(CompileUnit &Unit,
const DWARFFile &File,
ExpressionHandlerRef ExprHandler);
LLVM_ABI Error generateUnitLocations(CompileUnit &Unit,
const DWARFFile &File,
ExpressionHandlerRef ExprHandler);

private:
using AttributeSpec = DWARFAbbreviationDeclaration::AttributeSpec;
Expand Down Expand Up @@ -729,16 +729,16 @@ class LLVM_ABI DWARFLinker : public DWARFLinkerBase {
/// Clone and emit the line table for the specified \p Unit.
/// Translate directories and file names if necessary.
/// Relocate address ranges.
void generateLineTableForUnit(CompileUnit &Unit);
Error generateLineTableForUnit(CompileUnit &Unit);
};

/// Assign an abbreviation number to \p Abbrev
void assignAbbrev(DIEAbbrev &Abbrev);

/// Compute and emit debug ranges(.debug_aranges, .debug_ranges,
/// .debug_rnglists) for \p Unit, patch the attributes referencing it.
void generateUnitRanges(CompileUnit &Unit, const DWARFFile &File,
DebugDieValuePool &AddrPool) const;
Error generateUnitRanges(CompileUnit &Unit, const DWARFFile &File,
DebugDieValuePool &AddrPool) const;

/// Emit the accelerator entries for \p Unit.
void emitAcceleratorEntriesForUnit(CompileUnit &Unit);
Expand Down
37 changes: 23 additions & 14 deletions llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ class LLVM_ABI DwarfStreamer : public DwarfEmitter {
MCSymbol *emitDwarfDebugRangeListHeader(const CompileUnit &Unit) override;

/// Emit debug ranges(.debug_ranges, .debug_rnglists) fragment.
void emitDwarfDebugRangeListFragment(const CompileUnit &Unit,
const AddressRanges &LinkedRanges,
PatchLocation Patch,
DebugDieValuePool &AddrPool) override;
Error emitDwarfDebugRangeListFragment(const CompileUnit &Unit,
const AddressRanges &LinkedRanges,
PatchLocation Patch,
DebugDieValuePool &AddrPool) override;

/// Emit debug ranges(.debug_ranges, .debug_rnglists) footer.
void emitDwarfDebugRangeListFooter(const CompileUnit &Unit,
Expand All @@ -130,7 +130,7 @@ class LLVM_ABI DwarfStreamer : public DwarfEmitter {
MCSymbol *EndLabel) override;

/// Emit debug ranges(.debug_loc, .debug_loclists) fragment.
void emitDwarfDebugLocListFragment(
Error emitDwarfDebugLocListFragment(
const CompileUnit &Unit,
const DWARFLocationExpressionsVector &LinkedLocationExpression,
PatchLocation Patch, DebugDieValuePool &AddrPool) override;
Expand Down Expand Up @@ -222,31 +222,40 @@ class LLVM_ABI DwarfStreamer : public DwarfEmitter {
WarningHandler(Warning, Context, nullptr);
}

Expected<uint64_t> clampSecOffset(uint64_t Offset, dwarf::FormParams FP,
StringRef Section) {
if (Offset <= FP.getDwarfMaxOffset())
return Offset;
return createStringError(Section + " section offset 0x" +
Twine::utohexstr(Offset) + " exceeds the " +
dwarf::FormatString(FP.Format) + " limit");
}

MCSection *getMCSection(DebugSectionKind SecKind);

void emitMacroTableImpl(const DWARFDebugMacro *MacroTable,
const Offset2UnitMap &UnitMacroMap,
OffsetsStringPool &StringPool, uint64_t &OutOffset);

/// Emit piece of .debug_ranges for \p LinkedRanges.
void emitDwarfDebugRangesTableFragment(const CompileUnit &Unit,
const AddressRanges &LinkedRanges,
PatchLocation Patch);
Error emitDwarfDebugRangesTableFragment(const CompileUnit &Unit,
const AddressRanges &LinkedRanges,
PatchLocation Patch);

/// Emit piece of .debug_rnglists for \p LinkedRanges.
void emitDwarfDebugRngListsTableFragment(const CompileUnit &Unit,
const AddressRanges &LinkedRanges,
PatchLocation Patch,
DebugDieValuePool &AddrPool);
Error emitDwarfDebugRngListsTableFragment(const CompileUnit &Unit,
const AddressRanges &LinkedRanges,
PatchLocation Patch,
DebugDieValuePool &AddrPool);

/// Emit piece of .debug_loc for \p LinkedRanges.
void emitDwarfDebugLocTableFragment(
Error emitDwarfDebugLocTableFragment(
const CompileUnit &Unit,
const DWARFLocationExpressionsVector &LinkedLocationExpression,
PatchLocation Patch);

/// Emit piece of .debug_loclists for \p LinkedRanges.
void emitDwarfDebugLocListsTableFragment(
Error emitDwarfDebugLocListsTableFragment(
const CompileUnit &Unit,
const DWARFLocationExpressionsVector &LinkedLocationExpression,
PatchLocation Patch, DebugDieValuePool &AddrPool);
Expand Down
Loading