File: got32x-i386.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (46 lines) | stat: -rw-r--r-- 1,551 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# REQUIRES: x86

## i386-got32x-baseless.elf is a file produced using GNU as v.2.27
## using following code and command line:
## (as --32 -o base.o base.s)
##
## .text
## .globl foo
## .type foo, @function
## foo:
##  nop
##
## _start:
##  movl foo@GOT, %eax
##  movl foo@GOT, %ebx
##  movl foo@GOT(%eax), %eax
##  movl foo@GOT(%ebx), %eax
##
## Result file contains four R_386_GOT32X relocations. Generated code
## is also a four mov instructions. And first two has no base register:
## <_start>:
##   1: 8b 05 00 00 00 00 mov 0x0,%eax
##   7: 8b 1d 00 00 00 00 mov 0x0,%ebx
##   d: 8b 80 00 00 00 00 mov 0x0(%eax),%eax
##  13: 8b 83 00 00 00 00 mov 0x0(%ebx),%eax
##
## R_386_GOT32X is computed as G + A - GOT, but if it used without base
## register, it should be calculated as G + A. Using without base register
## is only allowed for non-PIC code.
##
# RUN: ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1
# RUN: llvm-objdump --section-headers -d %t1 | FileCheck %s

## 73728 == 0x12000 == ADDR(.got)
# CHECK: Sections:
# CHECK:  Name     Size     VMA
# CHECK:  .got.plt 0000000c 00403134
# CHECK:       <_start>:
# CHECK-NEXT:   401115: 8b 05 {{.*}} movl 4202800, %eax
# CHECK-NEXT:   40111b: 8b 1d {{.*}} movl 4202800, %ebx
# CHECK-NEXT:   401121: 8b 80 {{.*}} movl -4100(%eax), %eax
# CHECK-NEXT:   401127: 8b 83 {{.*}} movl -4100(%ebx), %eax

# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o /dev/null -pie 2>&1 | \
# RUN:   FileCheck %s --check-prefix=ERR
# ERR-COUNT-2: error: symbol 'foo' cannot be preempted; recompile with -fPIE