//===--- Dwarf Emission Directives -----------------------------------===//
- /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
- /// offsets for debug information.
- bool AbsoluteDebugSectionOffsets; // Defaults to false.
-
/// HasLEB128 - True if target asm supports leb128 directives.
bool HasLEB128; // Defaults to false.
MCSymbolAttr getProtectedVisibilityAttr() const {
return ProtectedVisibilityAttr;
}
- bool isAbsoluteDebugSectionOffsets() const {
- return AbsoluteDebugSectionOffsets;
- }
bool hasLEB128() const {
return HasLEB128;
}
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
raw_ostream &OS) const = 0;
+
+ /// isBaseAddressKnownZero - Return true if we know that this section will
+ /// get a base address of zero. In cases where we know that this is true we
+ /// can emit section offsets as direct references to avoid a subtraction
+ /// from the base of the section, saving a relocation.
+ virtual bool isBaseAddressKnownZero() const {
+ return false;
+ }
};
class MCSectionCOFF : public MCSection {
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
raw_ostream &OS) const;
+ /// isBaseAddressKnownZero - We know that non-allocatable sections (like
+ /// debug info) have a base of zero.
+ virtual bool isBaseAddressKnownZero() const {
+ return (getFlags() & SHF_ALLOC) == 0;
+ }
/// PrintTargetSpecificSectionFlags - Targets that define their own
/// MCSectionELF subclasses with target specific section flags should
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Target/TargetData.h"
// If Label has already been emitted, verify that it is in the same section as
// section label for sanity.
assert((!Label->isInSection() || &Label->getSection() == &Section) &&
- "Section offset using wrong section base for label"); (void)Section;
+ "Section offset using wrong section base for label");
// If the section in question will end up with an address of 0 anyway, we can
// just emit an absolute reference to save a relocation.
- if (MAI->isAbsoluteDebugSectionOffsets()) {
+ if (Section.isBaseAddressKnownZero()) {
Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
return;
}
+ // Otherwise, emit it as a label difference from the start of the section.
Asm->EmitLabelDifference(Label, SectionLabel, 4);
}
LinkOnceDirective = 0;
HiddenVisibilityAttr = MCSA_Hidden;
ProtectedVisibilityAttr = MCSA_Protected;
- AbsoluteDebugSectionOffsets = false;
HasLEB128 = false;
HasDotLocAndDotFile = false;
SupportsDebugInformation = false;
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
- AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true;
DwarfSectionOffsetDirective = "\t.secrel32\t";
HasMicrosoftFastStdCallMangling = true;
CommentString = "@";
HasLEB128 = true;
- AbsoluteDebugSectionOffsets = true;
PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t";
HasLCOMMDirective = true;
UsesELFSectionDirectiveForBSS = true;
// Debug Information
- AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true;
PCSymbol = ".";
ZeroDirective = "\t.skip\t";
CommentString = "!";
HasLEB128 = true;
- AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true;
SunStyleELFSectionSwitchSyntax = true;
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
// Debug Information
- AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true;
// Exceptions handling
// Debug
HasLEB128 = true;
- AbsoluteDebugSectionOffsets = true;
}