forked from OSchip/llvm-project
[MC][ARM] Delete MCSection::HasData and move SHF_ARM_PURECODE logic to ARMELFObjectWriter::addTargetSectionFlags
This simplifies the generic interface and also makes SHF_ARM_PURECODE more robust (fixes a TODO). Inspecting MCDataFragment contents covers more cases than MCObjectStreamer::EmitBytes.
This commit is contained in:
parent
35efef5351
commit
5511861e6d
|
@ -78,10 +78,6 @@ private:
|
|||
/// Whether this section has had instructions emitted into it.
|
||||
bool HasInstructions : 1;
|
||||
|
||||
/// Whether this section has had data emitted into it.
|
||||
/// Right now this is only used by the ARM backend.
|
||||
bool HasData : 1;
|
||||
|
||||
bool IsRegistered : 1;
|
||||
|
||||
MCDummyFragment DummyFragment;
|
||||
|
@ -150,9 +146,6 @@ public:
|
|||
bool hasInstructions() const { return HasInstructions; }
|
||||
void setHasInstructions(bool Value) { HasInstructions = Value; }
|
||||
|
||||
bool hasData() const { return HasData; }
|
||||
void setHasData(bool Value) { HasData = Value; }
|
||||
|
||||
bool isRegistered() const { return IsRegistered; }
|
||||
void setIsRegistered(bool Value) { IsRegistered = Value; }
|
||||
|
||||
|
|
|
@ -569,12 +569,6 @@ void MCObjectStreamer::EmitBytes(StringRef Data) {
|
|||
MCDataFragment *DF = getOrCreateDataFragment();
|
||||
flushPendingLabels(DF, DF->getContents().size());
|
||||
DF->getContents().append(Data.begin(), Data.end());
|
||||
|
||||
// EmitBytes might not cover all possible ways we emit data (or could be used
|
||||
// to emit executable code in some cases), but is the best method we have
|
||||
// right now for checking this.
|
||||
MCSection *Sec = getCurrentSectionOnly();
|
||||
Sec->setHasData(true);
|
||||
}
|
||||
|
||||
void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment,
|
||||
|
|
|
@ -22,8 +22,7 @@ using namespace llvm;
|
|||
|
||||
MCSection::MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
|
||||
: Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false),
|
||||
HasData(false), IsRegistered(false), DummyFragment(this), Variant(V),
|
||||
Kind(K) {}
|
||||
IsRegistered(false), DummyFragment(this), Variant(V), Kind(K) {}
|
||||
|
||||
MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) {
|
||||
if (!End)
|
||||
|
|
|
@ -255,8 +255,11 @@ void ARMELFObjectWriter::addTargetSectionFlags(MCContext &Ctx,
|
|||
// execute-only section in the object.
|
||||
MCSectionELF *TextSection =
|
||||
static_cast<MCSectionELF *>(Ctx.getObjectFileInfo()->getTextSection());
|
||||
if (Sec.getKind().isExecuteOnly() && !TextSection->hasInstructions() &&
|
||||
!TextSection->hasData()) {
|
||||
if (Sec.getKind().isExecuteOnly() && !TextSection->hasInstructions()) {
|
||||
for (auto &F : TextSection->getFragmentList())
|
||||
if (auto *DF = dyn_cast<MCDataFragment>(&F))
|
||||
if (!DF->getContents().empty())
|
||||
return;
|
||||
TextSection->setFlags(TextSection->getFlags() | ELF::SHF_ARM_PURECODE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue