[PATCH] D30256: [ELF] - Implemented -z noreloc-overflow.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 13:24:53 PST 2017


>I believe GNU linker prints out "relocations against text section; recomiple with -fPIC" warning if the linker is creating a DSO. Does >it warn on text relocations if no -shared is given?

Depends on relocation. It will show this error for relocations that may be truncated in runtime:
2594<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2594> case R_X86_64_32:
2595<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2595> if (!ABI_64_P (abfd))
2596<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2596> goto pointer;
2597<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2597> /* Fall through. */
2598<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2598> case R_X86_64_8:
2599<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2599> case R_X86_64_16:
2600<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=a058eca3abf03cc2f79601d170b2d6b9f9c459e5;hb=HEAD#l2600> case R_X86_64_32S:

But if you take R_X86_64_64:

.text
.global _start
_start:
 .quad _start

llvm-mc -filetype=obj -triple=x86_64-pc-linux test.s -o test.o
ld.bfd test.o -shared -o out

Then no error is produced and DT_TEXTREL is added:

 0x0000000000000016 (TEXTREL)            0x0
 0x0000000000000000 (NULL)               0x0?
Relocation section '.rela.dyn' at offset 0x1e0 contains 1 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
0000000001f8  000100000001 R_X86_64_64       00000000000001f8 _start + 0

George.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/a96019db/attachment.html>


More information about the llvm-commits mailing list