1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3# RUN: not ld.lld -pie %t.o -o /dev/null 2>&1 | FileCheck --check-prefixes=CHECK,PIE %s
4# RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck --check-prefixes=CHECK,SHARED %s
5
6## Check we don't create dynamic relocations in a writable section,
7## if the number of bits is smaller than the wordsize.
8
9.globl hidden
10.hidden hidden
11local:
12hidden:
13
14# CHECK: error: relocation R_X86_64_8 cannot be used against local symbol; recompile with -fPIC
15# CHECK-NEXT: >>> defined in {{.*}}.o
16# CHECK-NEXT: >>> referenced by {{.*}}.o:(.data+0x0)
17# CHECK: error: relocation R_X86_64_16 cannot be used against local symbol; recompile with -fPIC
18# CHECK: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
19
20# PIE: error: cannot preempt symbol: hidden
21# SHARED: error: relocation R_X86_64_32 cannot be used against symbol hidden; recompile with -fPIC
22
23.data
24.byte local     # R_X86_64_8
25.short local    # R_X86_64_16
26.long local     # R_X86_64_32
27
28.long hidden    # R_X86_64_32
29