llvm-mirror/test/MC/ELF/ARM/execute-only-section.s
Prakhar Bahuguna dc9a43dec1 [ARM] Implement execute-only support in CodeGen
This implements execute-only support for ARM code generation, which
prevents the compiler from generating data accesses to code sections.
The following changes are involved:

* Add the CodeGen option "-arm-execute-only" to the ARM code generator.
* Add the clang flag "-mexecute-only" as well as the GCC-compatible
  alias "-mpure-code" to enable this option.
* When enabled, literal pools are replaced with MOVW/MOVT instructions,
  with VMOV used in addition for floating-point literals. As the MOVT
  instruction is required, execute-only support is only available in
  Thumb mode for targets supporting ARMv8-M baseline or Thumb2.
* Jump tables are placed in data sections when in execute-only mode.
* The execute-only text section is assigned section ID 0, and is
  marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'.
  This also overrides selection of ELF sections for globals.

llvm-svn: 289784
2016-12-15 07:59:08 +00:00

45 lines
1.1 KiB
ArmAsm

// RUN: llvm-mc -filetype=obj -triple thumbv7m-arm-linux-gnu %s -o - \
// RUN: | llvm-readobj -s -t | FileCheck %s
.section .text,"axy",%progbits,unique,0
.globl foo
.align 2
.type foo,%function
.code 16
.thumb_func
foo:
.fnstart
bx lr
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.fnend
.section ".note.GNU-stack","",%progbits
// CHECK: Section {
// CHECK: Name: .text (16)
// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
// CHECK-NEXT: Flags [ (0x6)
// CHECK-NEXT: SHF_ALLOC (0x2)
// CHECK-NEXT: SHF_EXECINSTR (0x4)
// CHECK-NEXT: ]
// CHECK: Size: 0
// CHECK: }
// CHECK: Section {
// CHECK: Name: .text (16)
// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
// CHECK-NEXT: Flags [ (0x20000006)
// CHECK-NEXT: SHF_ALLOC (0x2)
// CHECK-NEXT: SHF_ARM_PURECODE (0x20000000)
// CHECK-NEXT: SHF_EXECINSTR (0x4)
// CHECK-NEXT: ]
// CHECK: Size: 2
// CHECK: }
// CHECK: Symbol {
// CHECK: Name: foo (22)
// CHECK: Section: .text (0x3)
// CHECK: }