brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.8 KiB · c15cf35 Raw
282 lines · plain
1// REQUIRES: arm2/// Test CMSE diagnostics.3 4// RUN: rm -rf %t && split-file %s %t && cd %t5 6/// Test diagnostics emitted during checks of the CMSE import library7// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base lib -o lib.o8// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base app -I %S/Inputs -o app.o9// RUN: llvm-objcopy --redefine-sym=entry7_duplicate=entry6_duplicate lib.o10// RUN: not ld.lld --cmse-implib --in-implib=lib.o app.o 2>&1 | FileCheck %s --check-prefixes=ERR_IMPLIB11// RUN: not ld.lld --cmse-implib --in-implib=lib.o --in-implib=lib.o app.o 2>&1 | FileCheck %s --check-prefixes=ERR_MULT_INIMPLIB12// RUN: not ld.lld --in-implib=lib.o app.o 2>&1 | FileCheck %s --check-prefixes=ERR_IN_IMPLIB13// RUN: not ld.lld --out-implib=out.lib app.o 2>&1 | FileCheck %s --check-prefixes=ERR_OUT_IMPLIB14// RUN: not ld.lld --out-implib=out.lib --in-implib=lib.o app.o 2>&1 | FileCheck %s --check-prefixes=ERR_IN_IMPLIB,ERR_OUT_IMPLIB15 16// ERR_IMPLIB: error: CMSE symbol 'entry_not_external' in import library '{{.*}}' is not global17// ERR_IMPLIB: error: CMSE symbol 'entry_not_absolute' in import library '{{.*}}' is not absolute18// ERR_IMPLIB: error: CMSE symbol 'entry_not_function' in import library '{{.*}}' is not a Thumb function definition19// ERR_IMPLIB: error: CMSE symbol 'entry_not_thumb' in import library '{{.*}}' is not a Thumb function definition20// ERR_IMPLIB: warning: CMSE symbol 'entry5_incorrect_size' in import library '{{.*}}' does not have correct size of 8 bytes21// ERR_IMPLIB: error: CMSE symbol 'entry6_duplicate' is multiply defined in import library '{{.*}}'22// ERR_MULT_INIMPLIB: error: multiple CMSE import libraries not supported23// ERR_IN_IMPLIB: error: --in-implib may not be used without --cmse-implib24// ERR_OUT_IMPLIB: error: --out-implib may not be used without --cmse-implib25 26/// CMSE Only supported by ARMv8-M architecture or later.27// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv8m.base app -I %S/Inputs -o app1.o28// RUN: ld.lld --cmse-implib -pie -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app1 app1.o 2>&1 | FileCheck /dev/null --implicit-check-not=error:29 30// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv8m.main app -I %S/Inputs -o app2.o31// RUN: ld.lld --cmse-implib -pie -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app2 app2.o 2>&1 | FileCheck /dev/null --implicit-check-not=error:32 33// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv8.1m.main app -I %S/Inputs -o app3.o34// RUN: ld.lld --cmse-implib -pie -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app3 app3.o 2>&1 | FileCheck /dev/null --implicit-check-not=error:35 36/// Expect errors for other architectures.37// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv9a app -I %S/Inputs -o app4.o38// RUN: not ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app4 app4.o 2>&1 | FileCheck %s --check-prefixes=ERR_ARCH39 40// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7-m app -I %S/Inputs -o app5.o41// RUN: not ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app5 app5.o 2>&1 | FileCheck %s --check-prefixes=ERR_ARCH42 43// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv8-m app -I %S/Inputs -o app6.o44// RUN: not ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app6 app6.o 2>&1 | FileCheck %s --check-prefixes=ERR_ARCH45 46/// Invalid triple defaults to v4T. Error.47// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumb app -I %S/Inputs -o app7.o48// RUN: not ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app7 app7.o  2>&1 | FileCheck %s --check-prefixes=ERR_ARCH49 50/// No build attributes. Error.51// RUN: llvm-mc -filetype=obj -triple=thumb app -I %S/Inputs -o app8.o52// RUN: not ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app8 app8.o  2>&1 | FileCheck %s --check-prefixes=ERR_ARCH53 54// ERR_ARCH: CMSE is only supported by ARMv8-M architecture or later55 56/// Test that the linker diagnoses cases where the linker synthesized veneer addresses57/// specified by the CMSE input library cannot be placed at the .gnu.sgstubs section address.58 59// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main app -I %S/Inputs -o 1.o60/// Create a CMSE import library with a secure gateway veneer at 0x1000061// RUN: ld.lld --cmse-implib --section-start .gnu.sgstubs=0x10000 1.o -o 1 --out-implib=1.lib 2>&1 | FileCheck /dev/null --implicit-check-not=error:62/// Create a new import library with the secure gateway veneer and .gnu.sgstubs specified at the same address63// RUN: ld.lld --cmse-implib --section-start .gnu.sgstubs=0x10000 1.o -o 2 --out-implib=2.lib --in-implib=1.lib 2>&1 | FileCheck /dev/null --implicit-check-not=error:64/// Create a new import library with the secure gateway veneer specified at a same address but .gnu.sgstubs at a higher address.65// RUN: not ld.lld --cmse-implib -pie --section-start .gnu.sgstubs=0x11000 1.o -o 3 --out-implib=3.lib --in-implib=1.lib 2>&1 | FileCheck %s --check-prefixes=ERR_ADDR66/// Create a new import library with the secure gateway veneer specified at a same address but .gnu.sgstubs at a lower address.67// RUN: not ld.lld --cmse-implib -pie --section-start .gnu.sgstubs=0x9000 1.o -o 4 --out-implib=4.lib --in-implib=1.lib 2>&1 | FileCheck %s --check-prefixes=ERR_ADDR68 69// ERR_ADDR: error: start address of '.gnu.sgstubs' is different from previous link70 71/// Test that the address of .gnu.sgstubs can be specified via command line or linker script.72/// Test that the linker errors when the address of .gnu.sgstubs is not specified using either method.73 74// RUN: ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --script with_sgstubs.script 1.o -o 1 2>&1 | FileCheck /dev/null --implicit-check-not=error:75// RUN: ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --script wout_sgstubs.script 1.o -o 2 2>&1 | FileCheck /dev/null --implicit-check-not=error:76// RUN: ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 1.o -o 3 2>&1 | FileCheck /dev/null --implicit-check-not=error:77// RUN: ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --script with_sgstubs.script 1.o -o 4 2>&1 | FileCheck /dev/null --implicit-check-not=error:78// RUN: not ld.lld --cmse-implib --image-base=0x8000 -Ttext=0x8000 --script wout_sgstubs.script 1.o -o 5 2>&1 | FileCheck %s --check-prefixes=ERR_NOADDR79 80// RUN: llvm-readelf -S 1 | FileCheck %s --check-prefixes=ADDRCMDLINE81// RUN: llvm-readelf -S 2 | FileCheck %s --check-prefixes=ADDRCMDLINE82// RUN: llvm-readelf -S 3 | FileCheck %s --check-prefixes=ADDRCMDLINE83// RUN: llvm-readelf -S 4 | FileCheck %s --check-prefixes=ADDRLNKSCRIPT84 85// ERR_NOADDR: error: no address assigned to the veneers output section .gnu.sgstubs86 87///                       Name          Type         Address    Off   Size ES Flg Lk Inf Al88// ADDRCMDLINE:   .gnu.sgstubs      PROGBITS        00020000 020000 000008 08  AX  0   0 3289// ADDRLNKSCRIPT: .gnu.sgstubs      PROGBITS        00040000 040000 000008 08  AX  0   0 3290 91/// Test diagnostics emitted during symbol attribute checks.92 93// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -I %S/Inputs --triple=thumbv8m.base symattr -o symattr.o94// RUN: not ld.lld --cmse-implib symattr.o 2>&1 | FileCheck %s --check-prefixes=ERR_SYMATTR95 96// ERR_SYMATTR-NOT: __acle_se_valid_{{.*}}97// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_1' is not a Thumb function definition98// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_2' is not a Thumb function definition99// ERR_SYMATTR: error: {{.*}}: cmse entry symbol 'invalid_3' is not a Thumb function definition100// ERR_SYMATTR: error: {{.*}}: cmse entry symbol 'invalid_4' is not a Thumb function definition101// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_5' detected, but no associated entry function definition 'invalid_5' with external linkage found102// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_6' detected, but no associated entry function definition 'invalid_6' with external linkage found103// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_7' is not a Thumb function definition104// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_8' detected, but no associated entry function definition 'invalid_8' with external linkage found105// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_9' cannot be an absolute symbol106// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_10' cannot be an absolute symbol107// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_11' is not a Thumb function definition108// ERR_SYMATTR: error: {{.*}}: cmse entry symbol 'invalid_12' is not a Thumb function definition109 110/// Test diagnostics emitted when a symbol is removed from a later version of the import library.111// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -I %S/Inputs --triple=thumbv8m.base libv1 -o libv1.o112// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -I %S/Inputs --triple=thumbv8m.base libv2 -o libv2.o113// RUN: ld.lld --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --cmse-implib libv1.o --out-implib=libv1.lib114// RUN: ld.lld --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --cmse-implib libv2.o --in-implib=libv1.lib --out-implib=libv2.lib 2>&1 | FileCheck %s --check-prefixes=WARN_MISSING115// RUN: ld.lld --image-base=0x8000 -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --cmse-implib libv1.o --in-implib=libv2.lib 2>&1 | FileCheck %s --check-prefixes=WARN_NEWENTRY116 117// WARN_MISSING: warning: entry function 'bar' from CMSE import library is not present in secure application118// WARN_NEWENTRY: warning: new entry function 'bar' introduced but no output import library specified119 120//--- with_sgstubs.script121SECTIONS {122  .text : { *(.text) }123  .gnu.sgstubs 0x40000 : { *(.gnu.sgstubs*) }124}125 126//--- wout_sgstubs.script127SECTIONS {128  .text : { *(.text) }129}130 131//--- app132  .include "arm-cmse-macros.s"133  .text134  .thumb135 136cmse_veneer entry, function, global, function, global137 138//--- lib139    .text140    .thumb141 142/// Symbol not absolute.143    .global entry_not_absolute144    .type entry_not_absolute, STT_FUNC145    .thumb_func146entry_not_absolute:147    .size entry_not_absolute, 8148 149/// Symbol not global or weak.150    .local entry_not_external151    .type entry_not_external, STT_FUNC152entry_not_external=0x1001153    .size entry_not_external, 8154 155/// Symbol not the function type.156    .global entry_not_function157    .type entry_not_function, STT_NOTYPE158entry_not_function=0x1001159    .size entry_not_function, 8160 161/// Symbol not a Thumb code symbol.162    .global entry_not_thumb163    .type entry_not_thumb, STT_FUNC164entry_not_thumb=0x1000165    .size entry_not_thumb, 8166 167/// Symbol with incorrect size.168    .global entry5_incorrect_size169    .type entry5_incorrect_size, STT_FUNC170entry5_incorrect_size=0x1009171    .size entry5_incorrect_size, 6172 173/// Duplicate symbols.174    .global entry6_duplicate175    .type entry6_duplicate, STT_FUNC176entry6_duplicate=0x1001177    .size entry6_duplicate, 8178 179/// entry7_duplicate gets renamed to entry6_duplicate by llvm-objcopy.180    .global entry7_duplicate181    .type entry7_duplicate, STT_FUNC182entry7_duplicate=0x1009183    .size entry7_duplicate, 8184 185//--- symattr186.include "arm-cmse-macros.s"187 188  .text189  .thumb190 191/// Valid sequences192/// both sym and __acle_se_sym should be global or weak Thumb code symbols.193  cmse_veneer valid_1, function, global, function, global194  cmse_veneer valid_2, function,   weak, function,   weak195  cmse_veneer valid_3, function,   weak, function, global196  cmse_veneer valid_4, function, global, function,   weak197 198/// Invalid sequences199/// __acle_se_sym is an object200  cmse_veneer invalid_1, function, global,   object, global201  cmse_veneer invalid_2, function, global,   object,   weak202/// sym is an object203  cmse_veneer invalid_3,   object, global, function, global204  cmse_veneer invalid_4,   object, global, function,   weak205/// sym is local206  cmse_veneer invalid_5, function,  local, function, global207  cmse_veneer invalid_6, function,  local, function,   weak208 209/// __acle_se_invalid_7 not defined.210  .global invalid_7211	.type	invalid_7, %function212  .global __acle_se_invalid_7213  .thumb_func214invalid_7:215 216/// invalid_8 not defined.217  .global __acle_se_invalid_8218  .thumb_func219__acle_se_invalid_8:220 221// Absolute symbols with same values222  .global invalid_9223  .global __acle_se_invalid_9224	.type	__acle_se_invalid_9, %function225	.type	invalid_9, %function226__acle_se_invalid_9=0x1001227invalid_9=0x1001228	.size	invalid_9, 0229  .size __acle_se_invalid_9, 0230 231// Absolute symbols with different values232	.align 2233	.global	__acle_se_invalid_10234	.global	invalid_10235	.type	__acle_se_invalid_10, %function236	.type	invalid_10, %function237__acle_se_invalid_10 = 0x10001238invalid_10 = 0x10005239	.size	invalid_10, 0240  .size __acle_se_invalid_10, 0241 242  .section nonthumb243  .thumb244  .align  2245  .global  invalid_11246  .global  __acle_se_invalid_11247  .type  invalid_11, %function248  .type  __acle_se_invalid_11, %function249invalid_11:250  .size  invalid_11, .-invalid_11251/// Invalid non-thumb function symbol __acle_se_invalid_11252__acle_se_invalid_11=0x1000253 254  .global  invalid_12255  .global  __acle_se_invalid_12256  .type  invalid_12, %function257  .type  __acle_se_invalid_12, %function258/// Invalid non-thumb function symbol invalid_12259invalid_12=0x1000260  .thumb261__acle_se_invalid_12:262  .size  __acle_se_invalid_12, .-__acle_se_invalid_12263 264//--- libv1265.include "arm-cmse-macros.s"266 267  .text268  .thumb269 270/// Import library version 1 with foo and bar271  cmse_veneer foo, function, global, function, global272  cmse_veneer bar, function,   weak, function,   weak273 274//--- libv2275.include "arm-cmse-macros.s"276 277  .text278  .thumb279 280/// Import library version 2 with bar missing.281  cmse_veneer foo, function, global, function, global282