diff options
author | Eric Christopher <echristo@gmail.com> | 2018-09-06 22:09:31 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2018-09-06 22:09:31 +0000 |
commit | fe83270ee9ad66548326625a170ac062079556d0 (patch) | |
tree | b600d892a0905f2039d7a59dd3fdb93639664f11 /llvm/lib/MC/MCObjectStreamer.cpp | |
parent | 950a1a393675c806e24f803a33e6ece7652c4160 (diff) | |
download | bcm5719-llvm-fe83270ee9ad66548326625a170ac062079556d0.tar.gz bcm5719-llvm-fe83270ee9ad66548326625a170ac062079556d0.zip |
The initial .text section generated in object files was missing the
SHF_ARM_PURECODE flag when being built with the -mexecute-only flag.
All code sections of an ELF must have the flag set for the final .text
section to be execute-only, otherwise the flag gets removed.
A HasData flag is added to MCSection to aid in the determination that
the section is empty. A virtual setTargetSectionFlags is added to
MCELFObjectTargetWriter to allow subclasses to set target specific
section flags to be added to sections which we then use in the ARM
backend to set SHF_ARM_PURECODE.
Patch by Ivan Lozano!
Reviewed By: echristo
Differential Revision: https://reviews.llvm.org/D48792
llvm-svn: 341593
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 019b9348a4e..8c88db009bd 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -496,6 +496,12 @@ 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, |