Simplify handling of --noexecstack by using getNonexecutableStackSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-10-15 16:12:52 +00:00
parent 5c2d60d357
commit 90ce9f70e2
31 changed files with 81 additions and 127 deletions

View File

@@ -15,6 +15,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCContext.h"
@@ -38,19 +39,23 @@ using namespace llvm;
MCELFStreamer::~MCELFStreamer() {
}
void MCELFStreamer::InitSections() {
void MCELFStreamer::InitSections(bool NoExecStack) {
// This emulates the same behavior of GNU as. This makes it easier
// to compare the output as the major sections are in the same order.
SwitchSection(getContext().getObjectFileInfo()->getTextSection());
MCContext &Ctx = getContext();
SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
EmitCodeAlignment(4);
SwitchSection(getContext().getObjectFileInfo()->getDataSection());
SwitchSection(Ctx.getObjectFileInfo()->getDataSection());
EmitCodeAlignment(4);
SwitchSection(getContext().getObjectFileInfo()->getBSSSection());
SwitchSection(Ctx.getObjectFileInfo()->getBSSSection());
EmitCodeAlignment(4);
SwitchSection(getContext().getObjectFileInfo()->getTextSection());
SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
if (NoExecStack)
SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx));
}
void MCELFStreamer::EmitLabel(MCSymbol *Symbol) {
@@ -543,12 +548,10 @@ void MCELFStreamer::FinishImpl() {
MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool NoExecStack) {
bool RelaxAll) {
MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
if (NoExecStack)
S->getAssembler().setNoExecStack(true);
return S;
}