mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
Rename and improve emitSectionOffset.
Different object formats represent references from dwarf in different ways. ELF uses a relocation to the referenced point (except for .dwo) and COFF/MachO use the offset of the referenced point inside its section. This patch renames emitSectionOffset because * It doesn't produce an offset on ELF. * It changes behavior depending on how DWARF is represented, so adding dwarf to its name is probably a good thing. The patch also adds an option to force the use of offsets.That avoids funny looking code like if (!UseOffsets) Asm->emitSectionOffset.... It was correct, but read as if the ! was inverted. llvm-svn: 239866
This commit is contained in:
parent
a672c833b7
commit
5c0ce7ad5b
@ -418,16 +418,17 @@ public:
|
||||
/// Emit reference to a ttype global with a specified encoding.
|
||||
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const;
|
||||
|
||||
/// Emit the 4-byte offset of Label from the start of its section. This can
|
||||
/// be done with a special directive if the target supports it (e.g. cygwin)
|
||||
/// or by emitting it as an offset from a label at the start of the section.
|
||||
void emitSectionOffset(const MCSymbol *Label) const;
|
||||
/// Emit a reference to a symbol for use in dwarf. Different object formats
|
||||
/// represent this in different ways. Some use a relocation others encode
|
||||
/// the label offset in its section.
|
||||
void emitDwarfSymbolReference(const MCSymbol *Label,
|
||||
bool ForceOffset = false) const;
|
||||
|
||||
/// Emit the 4-byte offset of a string from the start of its section.
|
||||
///
|
||||
/// When possible, emit a DwarfStringPool section offset without any
|
||||
/// relocations, and without using the symbol. Otherwise, defers to \a
|
||||
/// emitSectionOffset().
|
||||
/// emitDwarfSymbolReference().
|
||||
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const;
|
||||
|
||||
/// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
|
||||
|
@ -157,24 +157,20 @@ void AsmPrinter::EmitTTypeReference(const GlobalValue *GV,
|
||||
OutStreamer->EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
|
||||
}
|
||||
|
||||
/// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its
|
||||
/// section. This can be done with a special directive if the target supports
|
||||
/// it (e.g. cygwin) or by emitting it as an offset from a label at the start
|
||||
/// of the section.
|
||||
///
|
||||
/// SectionLabel is a temporary label emitted at the start of the section that
|
||||
/// Label lives in.
|
||||
void AsmPrinter::emitSectionOffset(const MCSymbol *Label) const {
|
||||
// On COFF targets, we have to emit the special .secrel32 directive.
|
||||
if (MAI->needsDwarfSectionOffsetDirective()) {
|
||||
OutStreamer->EmitCOFFSecRel32(Label);
|
||||
return;
|
||||
}
|
||||
void AsmPrinter::emitDwarfSymbolReference(const MCSymbol *Label,
|
||||
bool ForceOffset) const {
|
||||
if (!ForceOffset) {
|
||||
// On COFF targets, we have to emit the special .secrel32 directive.
|
||||
if (MAI->needsDwarfSectionOffsetDirective()) {
|
||||
OutStreamer->EmitCOFFSecRel32(Label);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the format uses relocations with dwarf, refer to the symbol directly.
|
||||
if (MAI->doesDwarfUseRelocationsAcrossSections()) {
|
||||
OutStreamer->EmitSymbolValue(Label, 4);
|
||||
return;
|
||||
// If the format uses relocations with dwarf, refer to the symbol directly.
|
||||
if (MAI->doesDwarfUseRelocationsAcrossSections()) {
|
||||
OutStreamer->EmitSymbolValue(Label, 4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, emit it as a label difference from the start of the section.
|
||||
@ -183,7 +179,7 @@ void AsmPrinter::emitSectionOffset(const MCSymbol *Label) const {
|
||||
|
||||
void AsmPrinter::emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
|
||||
if (MAI->doesDwarfUseRelocationsAcrossSections()) {
|
||||
emitSectionOffset(S.getSymbol());
|
||||
emitDwarfSymbolReference(S.getSymbol());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -618,11 +618,7 @@ unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||
void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||
DwarfDebug *DD = AP->getDwarfDebug();
|
||||
MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
|
||||
|
||||
if (AP->MAI->doesDwarfUseRelocationsAcrossSections() && !DD->useSplitDwarf())
|
||||
AP->emitSectionOffset(Label);
|
||||
else
|
||||
AP->EmitLabelDifference(Label, Label->getSection().getBeginSymbol(), 4);
|
||||
AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf());
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -1414,7 +1414,7 @@ void DwarfDebug::emitDebugPubSection(
|
||||
Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION);
|
||||
|
||||
Asm->OutStreamer->AddComment("Offset of Compilation Unit Info");
|
||||
Asm->emitSectionOffset(TheU->getLabelBegin());
|
||||
Asm->emitDwarfSymbolReference(TheU->getLabelBegin());
|
||||
|
||||
Asm->OutStreamer->AddComment("Compilation Unit Length");
|
||||
Asm->EmitInt32(TheU->getLength());
|
||||
@ -1739,7 +1739,7 @@ void DwarfDebug::emitDebugARanges() {
|
||||
Asm->OutStreamer->AddComment("DWARF Arange version number");
|
||||
Asm->EmitInt16(dwarf::DW_ARANGES_VERSION);
|
||||
Asm->OutStreamer->AddComment("Offset Into Debug Info Section");
|
||||
Asm->emitSectionOffset(CU->getLabelBegin());
|
||||
Asm->emitDwarfSymbolReference(CU->getLabelBegin());
|
||||
Asm->OutStreamer->AddComment("Address Size (in bytes)");
|
||||
Asm->EmitInt8(PtrSize);
|
||||
Asm->OutStreamer->AddComment("Segment Size (in bytes)");
|
||||
|
@ -1449,10 +1449,8 @@ void DwarfUnit::emitHeader(bool UseOffsets) {
|
||||
// start of the section. Use a relocatable offset where needed to ensure
|
||||
// linking doesn't invalidate that offset.
|
||||
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
|
||||
if (!UseOffsets)
|
||||
Asm->emitSectionOffset(TLOF.getDwarfAbbrevSection()->getBeginSymbol());
|
||||
else
|
||||
Asm->EmitInt32(0);
|
||||
Asm->emitDwarfSymbolReference(TLOF.getDwarfAbbrevSection()->getBeginSymbol(),
|
||||
UseOffsets);
|
||||
|
||||
Asm->OutStreamer->AddComment("Address Size (in bytes)");
|
||||
Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
|
||||
|
Loading…
Reference in New Issue
Block a user