Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lib/Target/ARM/ARMTargetObjectFile.cpp
Show All 21 Lines | |||||
using namespace dwarf; | using namespace dwarf; | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// ELF Target | // ELF Target | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
void ARMElfTargetObjectFile::Initialize(MCContext &Ctx, | void ARMElfTargetObjectFile::Initialize(MCContext &Ctx, | ||||
const TargetMachine &TM) { | const TargetMachine &TM) { | ||||
bool isAAPCS_ABI = static_cast<const ARMTargetMachine &>(TM).TargetABI == | const ARMTargetMachine &ARM_TM = static_cast<const ARMTargetMachine &>(TM); | ||||
ARMTargetMachine::ARMABI::ARM_ABI_AAPCS; | bool isAAPCS_ABI = ARM_TM.TargetABI == ARMTargetMachine::ARMABI::ARM_ABI_AAPCS; | ||||
genExecuteOnly = ARM_TM.getSubtargetImpl()->genExecuteOnly(); | |||||
TargetLoweringObjectFileELF::Initialize(Ctx, TM); | TargetLoweringObjectFileELF::Initialize(Ctx, TM); | ||||
InitializeELF(isAAPCS_ABI); | InitializeELF(isAAPCS_ABI); | ||||
if (isAAPCS_ABI) { | if (isAAPCS_ABI) { | ||||
LSDASection = nullptr; | LSDASection = nullptr; | ||||
} | } | ||||
AttributesSection = | AttributesSection = | ||||
getContext().getELFSection(".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0); | getContext().getELFSection(".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0); | ||||
// Make code section unreadable when in execute-only mode | |||||
if (genExecuteOnly) { | |||||
unsigned Type = ELF::SHT_PROGBITS; | |||||
unsigned Flags = ELF::SHF_EXECINSTR | ELF::SHF_ALLOC | ELF::SHF_ARM_PURECODE; | |||||
// Since we cannot modify flags for an existing section, we create a new | |||||
// section with the right flags, and use 0 as the unique ID for | |||||
rengolin: Where is the TextSection initialised if it's not pure? Shouldn't this move to the same place? | |||||
Not Done ReplyInline ActionsWe cannot change the flags of an existing section, so we create a new text section with the flags set in addition to the default one. prakhar: We cannot change the flags of an existing section, so we create a new text section with the… | |||||
Not Done ReplyInline ActionsOh, I see. I think this deserves a nice comment. :) rengolin: Oh, I see. I think this deserves a nice comment. :) | |||||
// execute-only text | |||||
TextSection = Ctx.getELFSection(".text", Type, Flags, 0, "", 0U); | |||||
} | |||||
} | } | ||||
const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference( | const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference( | ||||
const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, | const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, | ||||
MachineModuleInfo *MMI, MCStreamer &Streamer) const { | MachineModuleInfo *MMI, MCStreamer &Streamer) const { | ||||
if (TM.getMCAsmInfo()->getExceptionHandlingType() != ExceptionHandling::ARM) | if (TM.getMCAsmInfo()->getExceptionHandlingType() != ExceptionHandling::ARM) | ||||
return TargetLoweringObjectFileELF::getTTypeGlobalReference( | return TargetLoweringObjectFileELF::getTTypeGlobalReference( | ||||
GV, Encoding, TM, MMI, Streamer); | GV, Encoding, TM, MMI, Streamer); | ||||
assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only"); | assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only"); | ||||
return MCSymbolRefExpr::create(TM.getSymbol(GV), | return MCSymbolRefExpr::create(TM.getSymbol(GV), | ||||
MCSymbolRefExpr::VK_ARM_TARGET2, getContext()); | MCSymbolRefExpr::VK_ARM_TARGET2, getContext()); | ||||
} | } | ||||
const MCExpr *ARMElfTargetObjectFile:: | const MCExpr *ARMElfTargetObjectFile:: | ||||
getDebugThreadLocalSymbol(const MCSymbol *Sym) const { | getDebugThreadLocalSymbol(const MCSymbol *Sym) const { | ||||
return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_ARM_TLSLDO, | return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_ARM_TLSLDO, | ||||
getContext()); | getContext()); | ||||
} | } | ||||
MCSection * | |||||
ARMElfTargetObjectFile::getExplicitSectionGlobal(const GlobalObject *GO, | |||||
SectionKind SK, const TargetMachine &TM) const { | |||||
// Set execute-only access for the explicit section | |||||
if (genExecuteOnly && SK.isText()) | |||||
SK = SectionKind::getExecuteOnly(); | |||||
return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM); | |||||
} | |||||
MCSection * | |||||
ARMElfTargetObjectFile::SelectSectionForGlobal(const GlobalObject *GO, | |||||
SectionKind SK, const TargetMachine &TM) const { | |||||
// Place the global in the execute-only text section | |||||
if (genExecuteOnly && SK.isText()) | |||||
SK = SectionKind::getExecuteOnly(); | |||||
return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, SK, TM); | |||||
} |
Where is the TextSection initialised if it's not pure? Shouldn't this move to the same place?