The initial .text section generated in object files was missing the
authorEric Christopher <echristo@gmail.com>
Thu, 6 Sep 2018 22:09:31 +0000 (22:09 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 6 Sep 2018 22:09:31 +0000 (22:09 +0000)
commitfe83270ee9ad66548326625a170ac062079556d0
treeb600d892a0905f2039d7a59dd3fdb93639664f11
parent950a1a393675c806e24f803a33e6ece7652c4160
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
13 files changed:
llvm/include/llvm/MC/MCELFObjectWriter.h
llvm/include/llvm/MC/MCSection.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/MCELFObjectTargetWriter.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCSection.cpp
llvm/lib/Target/ARM/ARMTargetObjectFile.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
llvm/test/CodeGen/ARM/execute-only.ll
llvm/test/MC/ARM/elf-execute-only-section.ll [new file with mode: 0644]
llvm/test/MC/ELF/ARM/execute-only-populated-text-section.s [new file with mode: 0644]
llvm/test/MC/ELF/ARM/execute-only-section.s
llvm/test/MC/ELF/ARM/execute-only-text-section-data.s [new file with mode: 0644]