[PATCH] D26133: [ELF] Allow relative relocations to absolute symbols in PIC

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 12:13:54 PST 2017


Petr Hosek via Phabricator <reviews at reviews.llvm.org> writes:
> Index: test/ELF/symbol-absolute.s
> ===================================================================
> --- /dev/null
> +++ test/ELF/symbol-absolute.s
> @@ -0,0 +1,13 @@
> +# REQUIRES: x86
> +
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tinput1.o
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
> +# RUN:   %S/Inputs/symbol-absolute.s -o %tinput2.o
> +# RUN: ld.lld -shared --gc-sections -o %t %tinput1.o %tinput2.o
> +# RUN: llvm-readobj --elf-output-style=GNU --file-headers --symbols %t | FileCheck %s
> +# CHECK: 0000000000000000     0 NOTYPE  LOCAL  HIDDEN   ABS _BASE
> +
> +.text
> +.globl _start
> +_start:
> +       lea _BASE(%rip),%rax

It is not clear why this should link. You have a relative relocation to
an absolute symbol. You are also producing a shared object, so the final
value will depend on where the .so is loaded in memory.

Cheers,
Rafael


More information about the llvm-commits mailing list