• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2
3## i386-got32x-baseless.elf is a file produced using GNU as v.2.27
4## using following code and command line:
5## (as --32 -o base.o base.s)
6##
7## .text
8## .globl foo
9## .type foo, @function
10## foo:
11##  nop
12##
13## _start:
14##  movl foo@GOT, %eax
15##  movl foo@GOT, %ebx
16##  movl foo@GOT(%eax), %eax
17##  movl foo@GOT(%ebx), %eax
18##
19## Result file contains four R_386_GOT32X relocations. Generated code
20## is also a four mov instructions. And first two has no base register:
21## <_start>:
22##   1: 8b 05 00 00 00 00 mov 0x0,%eax
23##   7: 8b 1d 00 00 00 00 mov 0x0,%ebx
24##   d: 8b 80 00 00 00 00 mov 0x0(%eax),%eax
25##  13: 8b 83 00 00 00 00 mov 0x0(%ebx),%eax
26##
27## R_386_GOT32X is computed as G + A - GOT, but if it used without base
28## register, it should be calculated as G + A. Using without base register
29## is only allowed for non-PIC code.
30##
31# RUN: ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1
32# RUN: llvm-objdump --section-headers -d %t1 | FileCheck %s
33
34## 73728 == 0x12000 == ADDR(.got)
35# CHECK: Sections:
36# CHECK:  Name     Size     VMA
37# CHECK:  .got.plt 0000000c 00403134
38# CHECK:       <_start>:
39# CHECK-NEXT:   401115: 8b 05 {{.*}} movl 4202800, %eax
40# CHECK-NEXT:   40111b: 8b 1d {{.*}} movl 4202800, %ebx
41# CHECK-NEXT:   401121: 8b 80 {{.*}} movl -4100(%eax), %eax
42# CHECK-NEXT:   401127: 8b 83 {{.*}} movl -4100(%ebx), %eax
43
44# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o /dev/null -pie 2>&1 | \
45# RUN:   FileCheck %s --check-prefix=ERR
46# ERR-COUNT-2: error: symbol 'foo' cannot be preempted; recompile with -fPIE
47