[PATCH] D48792: [ARM] Set execute-only flags in .text.

Ivan Lozano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 15:49:24 PDT 2018


ivanlozano added inline comments.


================
Comment at: lib/MC/ELFObjectWriter.cpp:1121
+        !TextSection->hasData()) {
+      if (OWriter.TargetObjectWriter->getEMachine() == ELF::EM_ARM) {
+        TextSection->setFlags(TextSection->getFlags() | ELF::SHF_ARM_PURECODE);
----------------
ivanlozano wrote:
> peter.smith wrote:
> > If the TextSection is completely empty it should have 0 fragments going into MCAssembler::layout(). The layout function then creates a single empty MCDataFragment. I'm thinking it might be more precise and reliable to set a flag like HasNoUserFragments in layout(). That flag can be tested for here.
> > 
> This seems reasonable, I'll put this together and see that it works as expected.
Unfortunately by the time we get to MCAssembler::layout(), the .text section already contains empty fragments. 

Looking at MCObjectFileInfo::initELFMCObjectFileInfo where the text section is created, it contains an empty MCDataFragment upon creation, so I don't think the absence of fragments is something we can look for. We could iterate through each fragment and check to make sure they're all size 0, but this seems clunky.


https://reviews.llvm.org/D48792





More information about the llvm-commits mailing list