47 lines · plain
1# REQUIRES: x862 3## i386-got32x-baseless.elf is a file produced using GNU as v.2.274## using following code and command line:5## (as --32 -o base.o base.s)6##7## .text8## .globl foo9## .type foo, @function10## foo:11## nop12##13## _start:14## movl foo@GOT, %eax15## movl foo@GOT, %ebx16## movl foo@GOT(%eax), %eax17## movl foo@GOT(%ebx), %eax18##19## Result file contains four R_386_GOT32X relocations. Generated code20## 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,%eax23## 7: 8b 1d 00 00 00 00 mov 0x0,%ebx24## d: 8b 80 00 00 00 00 mov 0x0(%eax),%eax25## 13: 8b 83 00 00 00 00 mov 0x0(%ebx),%eax26##27## R_386_GOT32X is computed as G + A - GOT, but if it used without base28## register, it should be calculated as G + A. Using without base register29## is only allowed for non-PIC code.30##31# RUN: ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t132# RUN: llvm-objdump --no-print-imm-hex --section-headers -d %t1 | FileCheck %s33 34## 73728 == 0x12000 == ADDR(.got)35# CHECK: Sections:36# CHECK: Name Size VMA37# CHECK: .got.plt 0000000c 0040313438# CHECK: <_start>:39# CHECK-NEXT: 401115: 8b 05 {{.*}} movl 4202800, %eax40# CHECK-NEXT: 40111b: 8b 1d {{.*}} movl 4202800, %ebx41# CHECK-NEXT: 401121: 8b 80 {{.*}} movl -4100(%eax), %eax42# CHECK-NEXT: 401127: 8b 83 {{.*}} movl -4100(%ebx), %eax43 44# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o /dev/null -pie 2>&1 | \45# RUN: FileCheck %s --check-prefix=ERR46# ERR-COUNT-2: error: relocation R_386_GOT32X cannot be used against symbol 'foo'; recompile with -fPIC47