[PATCH] D60306: Fix -emit-reloc against local symbols.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 7 23:43:41 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357885: Fix -emit-reloc against local symbols. (authored by ruiu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60306?vs=193833&id=194095#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60306/new/
https://reviews.llvm.org/D60306
Files:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/emit-relocs-mergeable2.s
Index: lld/trunk/test/ELF/emit-relocs-mergeable2.s
===================================================================
--- lld/trunk/test/ELF/emit-relocs-mergeable2.s
+++ lld/trunk/test/ELF/emit-relocs-mergeable2.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --emit-relocs %t.o -o %t.exe
+# RUN: llvm-readelf --relocations %t.exe | FileCheck %s
+
+# CHECK: 0000000000201004 000000010000000b R_X86_64_32S 0000000000200120 .Lfoo + 8
+
+.globl _start
+_start:
+ movq .Lfoo+8, %rax
+.section .rodata.cst16,"aM", at progbits,16
+.Lfoo:
+ .quad 0
+ .quad 0
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -567,6 +567,11 @@
if (Config->Discard == DiscardPolicy::None)
return true;
+ // If -emit-reloc is given, all symbols including local ones need to be
+ // copied because they may be referenced by relocations.
+ if (Config->EmitRelocs)
+ return true;
+
// In ELF assembly .L symbols are normally discarded by the assembler.
// If the assembler fails to do so, the linker discards them if
// * --discard-locals is used.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60306.194095.patch
Type: text/x-patch
Size: 1231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190408/809f1dc0/attachment.bin>
More information about the llvm-commits
mailing list