mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Big change #1 for personality function references:
Eliminate the PersonalityPrefix/Suffix & NeedsIndirectEncoding fields from MAI: they aren't part of the asm syntax, they are related to the structure of the object file. To replace their functionality, add a new TLOF::getSymbolForDwarfGlobalReference method which asks targets to decide how to reference a global from EH in a pc-relative way. The default implementation just returns the symbol. The default darwin implementation references the symbol through an indirect $non_lazy_ptr stub. The bizarro x86-64 darwin specialization handles the weird "foo@GOTPCREL+4" hack. DwarfException.cpp now uses this to emit the reference to the symbol in the right way, and this also eliminates another horrible hack from DwarfException.cpp: - if (strcmp(MAI->getPersonalitySuffix(), "+4@GOTPCREL")) - O << "-" << MAI->getPCSymbol(); git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81991 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7c748661ce
commit
8c6ed05157
@ -84,17 +84,6 @@ namespace llvm {
|
|||||||
/// is "l" on Darwin, currently used for some ObjC metadata.
|
/// is "l" on Darwin, currently used for some ObjC metadata.
|
||||||
const char *LinkerPrivateGlobalPrefix; // Defaults to ""
|
const char *LinkerPrivateGlobalPrefix; // Defaults to ""
|
||||||
|
|
||||||
/// PersonalityPrefix/Suffix - If these are nonempty, these strings will
|
|
||||||
/// enclose any personality function in the common frame section.
|
|
||||||
///
|
|
||||||
const char *PersonalityPrefix; // Defaults to ""
|
|
||||||
const char *PersonalitySuffix; // Defaults to ""
|
|
||||||
|
|
||||||
/// NeedsIndirectEncoding - If set, we need to set the indirect encoding bit
|
|
||||||
/// for EH in Dwarf.
|
|
||||||
///
|
|
||||||
bool NeedsIndirectEncoding; // Defaults to false
|
|
||||||
|
|
||||||
/// InlineAsmStart/End - If these are nonempty, they contain a directive to
|
/// InlineAsmStart/End - If these are nonempty, they contain a directive to
|
||||||
/// emit before and after an inline assembly statement.
|
/// emit before and after an inline assembly statement.
|
||||||
const char *InlineAsmStart; // Defaults to "#APP\n"
|
const char *InlineAsmStart; // Defaults to "#APP\n"
|
||||||
@ -353,15 +342,6 @@ namespace llvm {
|
|||||||
const char *getLinkerPrivateGlobalPrefix() const {
|
const char *getLinkerPrivateGlobalPrefix() const {
|
||||||
return LinkerPrivateGlobalPrefix;
|
return LinkerPrivateGlobalPrefix;
|
||||||
}
|
}
|
||||||
const char *getPersonalityPrefix() const {
|
|
||||||
return PersonalityPrefix;
|
|
||||||
}
|
|
||||||
const char *getPersonalitySuffix() const {
|
|
||||||
return PersonalitySuffix;
|
|
||||||
}
|
|
||||||
bool getNeedsIndirectEncoding() const {
|
|
||||||
return NeedsIndirectEncoding;
|
|
||||||
}
|
|
||||||
const char *getInlineAsmStart() const {
|
const char *getInlineAsmStart() const {
|
||||||
return InlineAsmStart;
|
return InlineAsmStart;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ namespace llvm {
|
|||||||
class StringRef;
|
class StringRef;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class MCAsmInfo;
|
class MCAsmInfo;
|
||||||
|
class MCExpr;
|
||||||
|
|
||||||
class TargetLoweringObjectFile {
|
class TargetLoweringObjectFile {
|
||||||
MCContext *Ctx;
|
MCContext *Ctx;
|
||||||
@ -173,6 +174,22 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a
|
||||||
|
/// pc-relative reference to the specified global variable from exception
|
||||||
|
/// handling information. In addition to the symbol, this returns
|
||||||
|
/// by-reference:
|
||||||
|
///
|
||||||
|
/// IsIndirect - True if the returned symbol is actually a stub that contains
|
||||||
|
/// the address of the symbol, false if the symbol is the global itself.
|
||||||
|
///
|
||||||
|
/// IsPCRel - True if the symbol reference is already pc-relative, false if
|
||||||
|
/// the caller needs to subtract off the address of the reference from the
|
||||||
|
/// symbol.
|
||||||
|
///
|
||||||
|
virtual const MCExpr *
|
||||||
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||||
|
bool &IsIndirect, bool &IsPCRel) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const MCSection *
|
virtual const MCSection *
|
||||||
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||||
@ -298,6 +315,12 @@ public:
|
|||||||
const MCSection *getNonLazySymbolPointerSection() const {
|
const MCSection *getNonLazySymbolPointerSection() const {
|
||||||
return NonLazySymbolPointerSection;
|
return NonLazySymbolPointerSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getSymbolForDwarfGlobalReference - The mach-o version of this method
|
||||||
|
/// defaults to returning a stub reference.
|
||||||
|
virtual const MCExpr *
|
||||||
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||||
|
bool &IsIndirect, bool &IsPCRel) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,9 +17,11 @@
|
|||||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineLocation.h"
|
#include "llvm/CodeGen/MachineLocation.h"
|
||||||
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCSection.h"
|
#include "llvm/MC/MCSection.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetFrameInfo.h"
|
#include "llvm/Target/TargetFrameInfo.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
@ -75,20 +77,22 @@ unsigned DwarfException::SizeOfEncodedValue(unsigned Encoding) {
|
|||||||
/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
|
/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
|
||||||
/// is shared among many Frame Description Entries. There is at least one CIE
|
/// is shared among many Frame Description Entries. There is at least one CIE
|
||||||
/// in every non-empty .debug_frame section.
|
/// in every non-empty .debug_frame section.
|
||||||
void DwarfException::EmitCIE(const Function *Personality, unsigned Index) {
|
void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
||||||
// Size and sign of stack growth.
|
// Size and sign of stack growth.
|
||||||
int stackGrowth =
|
int stackGrowth =
|
||||||
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
|
Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
|
||||||
TargetFrameInfo::StackGrowsUp ?
|
TargetFrameInfo::StackGrowsUp ?
|
||||||
TD->getPointerSize() : -TD->getPointerSize();
|
TD->getPointerSize() : -TD->getPointerSize();
|
||||||
|
|
||||||
|
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
|
||||||
|
|
||||||
// Begin eh frame section.
|
// Begin eh frame section.
|
||||||
Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getEHFrameSection());
|
Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
|
||||||
|
|
||||||
if (MAI->is_EHSymbolPrivate())
|
if (MAI->is_EHSymbolPrivate())
|
||||||
O << MAI->getPrivateGlobalPrefix();
|
O << MAI->getPrivateGlobalPrefix();
|
||||||
|
|
||||||
O << "EH_frame" << Index << ":\n";
|
O << "EH_frame" << Index << ":\n";
|
||||||
|
|
||||||
EmitLabel("section_eh_frame", Index);
|
EmitLabel("section_eh_frame", Index);
|
||||||
|
|
||||||
// Define base labels.
|
// Define base labels.
|
||||||
@ -107,11 +111,22 @@ void DwarfException::EmitCIE(const Function *Personality, unsigned Index) {
|
|||||||
Asm->EOL("CIE Version");
|
Asm->EOL("CIE Version");
|
||||||
|
|
||||||
// The personality presence indicates that language specific information will
|
// The personality presence indicates that language specific information will
|
||||||
// show up in the eh frame.
|
// show up in the eh frame. Find out how we are supposed to lower the
|
||||||
|
// personality function reference:
|
||||||
// FIXME: Don't hardcode these encodings.
|
const MCExpr *PersonalityRef = 0;
|
||||||
|
bool IsPersonalityIndirect = false, IsPersonalityPCRel = false;
|
||||||
|
if (PersonalityFn) {
|
||||||
|
// FIXME: HANDLE STATIC CODEGEN MODEL HERE.
|
||||||
|
|
||||||
|
// In non-static mode, ask the object file how to represent this reference.
|
||||||
|
PersonalityRef =
|
||||||
|
TLOF.getSymbolForDwarfGlobalReference(PersonalityFn, Asm->Mang,
|
||||||
|
IsPersonalityIndirect,
|
||||||
|
IsPersonalityPCRel);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned PerEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
unsigned PerEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
||||||
if (Personality && MAI->getNeedsIndirectEncoding())
|
if (IsPersonalityIndirect)
|
||||||
PerEncoding |= dwarf::DW_EH_PE_indirect;
|
PerEncoding |= dwarf::DW_EH_PE_indirect;
|
||||||
unsigned LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
unsigned LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
||||||
unsigned FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
unsigned FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
||||||
@ -120,7 +135,7 @@ void DwarfException::EmitCIE(const Function *Personality, unsigned Index) {
|
|||||||
unsigned AugmentationSize = 0;
|
unsigned AugmentationSize = 0;
|
||||||
char *APtr = Augmentation + 1;
|
char *APtr = Augmentation + 1;
|
||||||
|
|
||||||
if (Personality) {
|
if (PersonalityRef) {
|
||||||
// There is a personality function.
|
// There is a personality function.
|
||||||
*APtr++ = 'P';
|
*APtr++ = 'P';
|
||||||
AugmentationSize += 1 + SizeOfEncodedValue(PerEncoding);
|
AugmentationSize += 1 + SizeOfEncodedValue(PerEncoding);
|
||||||
@ -159,15 +174,27 @@ void DwarfException::EmitCIE(const Function *Personality, unsigned Index) {
|
|||||||
Asm->EOL("Personality", PerEncoding);
|
Asm->EOL("Personality", PerEncoding);
|
||||||
|
|
||||||
// If there is a personality, we need to indicate the function's location.
|
// If there is a personality, we need to indicate the function's location.
|
||||||
if (Personality) {
|
if (PersonalityRef) {
|
||||||
|
// If the reference to the personality function symbol is not already
|
||||||
|
// pc-relative, then we need to subtract our current address from it. Do
|
||||||
|
// this by emitting a label and subtracting it from the expression we
|
||||||
|
// already have. This is equivalent to emitting "foo - .", but we have to
|
||||||
|
// emit the label for "." directly.
|
||||||
|
if (!IsPersonalityPCRel) {
|
||||||
|
SmallString<64> Name;
|
||||||
|
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
|
||||||
|
<< "personalityref_addr" << Asm->getFunctionNumber() << "_" << Index;
|
||||||
|
MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
|
||||||
|
Asm->OutStreamer.EmitLabel(DotSym);
|
||||||
|
|
||||||
|
PersonalityRef =
|
||||||
|
MCBinaryExpr::CreateSub(PersonalityRef,
|
||||||
|
MCSymbolRefExpr::Create(DotSym,Asm->OutContext),
|
||||||
|
Asm->OutContext);
|
||||||
|
}
|
||||||
|
|
||||||
O << MAI->getData32bitsDirective();
|
O << MAI->getData32bitsDirective();
|
||||||
|
PersonalityRef->print(O, MAI);
|
||||||
O << MAI->getPersonalityPrefix();
|
|
||||||
O << Asm->Mang->getMangledName(Personality);
|
|
||||||
O << MAI->getPersonalitySuffix();
|
|
||||||
|
|
||||||
if (strcmp(MAI->getPersonalitySuffix(), "+4@GOTPCREL"))
|
|
||||||
O << "-" << MAI->getPCSymbol();
|
|
||||||
Asm->EOL("Personality");
|
Asm->EOL("Personality");
|
||||||
|
|
||||||
Asm->EmitInt8(LSDAEncoding);
|
Asm->EmitInt8(LSDAEncoding);
|
||||||
@ -185,8 +212,7 @@ void DwarfException::EmitCIE(const Function *Personality, unsigned Index) {
|
|||||||
// On Darwin the linker honors the alignment of eh_frame, which means it must
|
// On Darwin the linker honors the alignment of eh_frame, which means it must
|
||||||
// be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
|
// be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
|
||||||
// holes which confuse readers of eh_frame.
|
// holes which confuse readers of eh_frame.
|
||||||
Asm->EmitAlignment(TD->getPointerSize() == sizeof(int32_t) ? 2 : 3,
|
Asm->EmitAlignment(TD->getPointerSize() == 4 ? 2 : 3, 0, 0, false);
|
||||||
0, 0, false);
|
|
||||||
EmitLabel("eh_frame_common_end", Index);
|
EmitLabel("eh_frame_common_end", Index);
|
||||||
|
|
||||||
Asm->EOL();
|
Asm->EOL();
|
||||||
|
@ -30,9 +30,6 @@ MCAsmInfo::MCAsmInfo() {
|
|||||||
GlobalPrefix = "";
|
GlobalPrefix = "";
|
||||||
PrivateGlobalPrefix = ".";
|
PrivateGlobalPrefix = ".";
|
||||||
LinkerPrivateGlobalPrefix = "";
|
LinkerPrivateGlobalPrefix = "";
|
||||||
PersonalityPrefix = "";
|
|
||||||
PersonalitySuffix = "";
|
|
||||||
NeedsIndirectEncoding = false;
|
|
||||||
InlineAsmStart = "APP";
|
InlineAsmStart = "APP";
|
||||||
InlineAsmEnd = "NO_APP";
|
InlineAsmEnd = "NO_APP";
|
||||||
AssemblerDialect = 0;
|
AssemblerDialect = 0;
|
||||||
|
@ -20,9 +20,8 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
|||||||
// Syntax:
|
// Syntax:
|
||||||
GlobalPrefix = "_";
|
GlobalPrefix = "_";
|
||||||
PrivateGlobalPrefix = "L";
|
PrivateGlobalPrefix = "L";
|
||||||
LinkerPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata
|
LinkerPrivateGlobalPrefix = "l";
|
||||||
NeedsSet = true;
|
NeedsSet = true;
|
||||||
NeedsIndirectEncoding = true;
|
|
||||||
AllowQuotesInName = true;
|
AllowQuotesInName = true;
|
||||||
HasSingleParameterDotFile = false;
|
HasSingleParameterDotFile = false;
|
||||||
|
|
||||||
|
@ -22,9 +22,6 @@ PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) {
|
|||||||
if (!is64Bit)
|
if (!is64Bit)
|
||||||
Data64bitsDirective = 0; // We can't emit a 64-bit unit in PPC32 mode.
|
Data64bitsDirective = 0; // We can't emit a 64-bit unit in PPC32 mode.
|
||||||
AssemblerDialect = 1; // New-Style mnemonics.
|
AssemblerDialect = 1; // New-Style mnemonics.
|
||||||
|
|
||||||
PersonalityPrefix = "L";
|
|
||||||
PersonalitySuffix = "$non_lazy_ptr";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
|
PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/GlobalVariable.h"
|
#include "llvm/GlobalVariable.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
@ -275,6 +276,30 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const {
|
|||||||
return DataSection;
|
return DataSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a
|
||||||
|
/// pc-relative reference to the specified global variable from exception
|
||||||
|
/// handling information. In addition to the symbol, this returns
|
||||||
|
/// by-reference:
|
||||||
|
///
|
||||||
|
/// IsIndirect - True if the returned symbol is actually a stub that contains
|
||||||
|
/// the address of the symbol, false if the symbol is the global itself.
|
||||||
|
///
|
||||||
|
/// IsPCRel - True if the symbol reference is already pc-relative, false if
|
||||||
|
/// the caller needs to subtract off the address of the reference from the
|
||||||
|
/// symbol.
|
||||||
|
///
|
||||||
|
const MCExpr *TargetLoweringObjectFile::
|
||||||
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||||
|
bool &IsIndirect, bool &IsPCRel) const {
|
||||||
|
// The generic implementation of this just returns a direct reference to the
|
||||||
|
// symbol.
|
||||||
|
IsIndirect = false;
|
||||||
|
IsPCRel = false;
|
||||||
|
|
||||||
|
SmallString<128> Name;
|
||||||
|
Mang->getNameWithPrefix(Name, GV, false);
|
||||||
|
return MCSymbolRefExpr::Create(Name.str(), getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -929,6 +954,19 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MCExpr *TargetLoweringObjectFileMachO::
|
||||||
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||||
|
bool &IsIndirect, bool &IsPCRel) const {
|
||||||
|
// The mach-o version of this method defaults to returning a stub reference.
|
||||||
|
IsIndirect = true;
|
||||||
|
IsPCRel = false;
|
||||||
|
|
||||||
|
SmallString<128> Name;
|
||||||
|
Mang->getNameWithPrefix(Name, GV, true);
|
||||||
|
Name += "$non_lazy_ptr";
|
||||||
|
return MCSymbolRefExpr::Create(Name.str(), getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// COFF
|
// COFF
|
||||||
@ -1046,3 +1084,4 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
|||||||
|
|
||||||
return getDataSection();
|
return getDataSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "X86InstrBuilder.h"
|
#include "X86InstrBuilder.h"
|
||||||
#include "X86ISelLowering.h"
|
#include "X86ISelLowering.h"
|
||||||
#include "X86TargetMachine.h"
|
#include "X86TargetMachine.h"
|
||||||
|
#include "X86TargetObjectFile.h"
|
||||||
#include "llvm/CallingConv.h"
|
#include "llvm/CallingConv.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
@ -36,7 +37,6 @@
|
|||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/ADT/SmallSet.h"
|
#include "llvm/ADT/SmallSet.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
@ -63,6 +63,8 @@ static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
|||||||
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
|
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
|
||||||
default: llvm_unreachable("unknown subtarget type");
|
default: llvm_unreachable("unknown subtarget type");
|
||||||
case X86Subtarget::isDarwin:
|
case X86Subtarget::isDarwin:
|
||||||
|
if (TM.getSubtarget<X86Subtarget>().is64Bit())
|
||||||
|
return new X8664_MachoTargetObjectFile();
|
||||||
return new TargetLoweringObjectFileMachO();
|
return new TargetLoweringObjectFileMachO();
|
||||||
case X86Subtarget::isELF:
|
case X86Subtarget::isELF:
|
||||||
return new TargetLoweringObjectFileELF();
|
return new TargetLoweringObjectFileELF();
|
||||||
|
@ -57,14 +57,6 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
|
|||||||
// Leopard and above support aligned common symbols.
|
// Leopard and above support aligned common symbols.
|
||||||
COMMDirectiveTakesAlignment = Triple.getDarwinMajorNumber() >= 9;
|
COMMDirectiveTakesAlignment = Triple.getDarwinMajorNumber() >= 9;
|
||||||
|
|
||||||
if (is64Bit) {
|
|
||||||
PersonalityPrefix = "";
|
|
||||||
PersonalitySuffix = "+4@GOTPCREL";
|
|
||||||
} else {
|
|
||||||
PersonalityPrefix = "L";
|
|
||||||
PersonalitySuffix = "$non_lazy_ptr";
|
|
||||||
}
|
|
||||||
|
|
||||||
CommentString = "##";
|
CommentString = "##";
|
||||||
PCSymbol = ".";
|
PCSymbol = ".";
|
||||||
|
|
||||||
|
33
lib/Target/X86/X86TargetObjectFile.cpp
Normal file
33
lib/Target/X86/X86TargetObjectFile.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//===-- llvm/Target/X86/X86TargetObjectFile.cpp - X86 Object Info ---------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "X86TargetObjectFile.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/Support/Mangler.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
const MCExpr *X8664_MachoTargetObjectFile::
|
||||||
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||||
|
bool &IsIndirect, bool &IsPCRel) const {
|
||||||
|
|
||||||
|
// On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
|
||||||
|
// is an indirect pc-relative reference.
|
||||||
|
IsIndirect = true;
|
||||||
|
IsPCRel = true;
|
||||||
|
|
||||||
|
SmallString<128> Name;
|
||||||
|
Mang->getNameWithPrefix(Name, GV, false);
|
||||||
|
Name += "@GOTPCREL";
|
||||||
|
const MCExpr *Res =
|
||||||
|
MCSymbolRefExpr::Create(Name.str(), getContext());
|
||||||
|
const MCExpr *Four = MCConstantExpr::Create(4, getContext());
|
||||||
|
return MCBinaryExpr::CreateAdd(Res, Four, getContext());
|
||||||
|
}
|
||||||
|
|
28
lib/Target/X86/X86TargetObjectFile.h
Normal file
28
lib/Target/X86/X86TargetObjectFile.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
//===-- llvm/Target/X86/X86TargetObjectFile.h - X86 Object Info -*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_TARGET_X86_TARGETOBJECTFILE_H
|
||||||
|
#define LLVM_TARGET_X86_TARGETOBJECTFILE_H
|
||||||
|
|
||||||
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
/// X8664_MachoTargetObjectFile - This TLOF implementation is used for
|
||||||
|
/// Darwin/x86-64.
|
||||||
|
class X8664_MachoTargetObjectFile : public TargetLoweringObjectFileMachO {
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual const MCExpr *
|
||||||
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||||
|
bool &IsIndirect, bool &IsPCRel) const;
|
||||||
|
};
|
||||||
|
} // end namespace llvm
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user