[lld] r288617 - Don't discard .L symbol with -r.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 4 00:34:18 PST 2016
Author: rafael
Date: Sun Dec 4 02:34:17 2016
New Revision: 288617
URL: http://llvm.org/viewvc/llvm-project?rev=288617&view=rev
Log:
Don't discard .L symbol with -r.
They might be used by relocations.
Fixes pr31252.
Added:
lld/trunk/test/ELF/relocatable-local-sym.s
Modified:
lld/trunk/ELF/Driver.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=288617&r1=288616&r2=288617&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sun Dec 4 02:34:17 2016
@@ -420,6 +420,8 @@ static bool getArg(opt::InputArgList &Ar
}
static DiscardPolicy getDiscardOption(opt::InputArgList &Args) {
+ if (Config->Relocatable)
+ return DiscardPolicy::None;
auto *Arg =
Args.getLastArg(OPT_discard_all, OPT_discard_locals, OPT_discard_none);
if (!Arg)
@@ -515,7 +517,6 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
Config->Demangle = getArg(Args, OPT_demangle, OPT_no_demangle, true);
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
- Config->Discard = getDiscardOption(Args);
Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
@@ -530,6 +531,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
Config->Relocatable = Args.hasArg(OPT_relocatable);
+ Config->Discard = getDiscardOption(Args);
Config->SaveTemps = Args.hasArg(OPT_save_temps);
Config->SingleRoRx = Args.hasArg(OPT_no_rosegment);
Config->Shared = Args.hasArg(OPT_shared);
Added: lld/trunk/test/ELF/relocatable-local-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocatable-local-sym.s?rev=288617&view=auto
==============================================================================
--- lld/trunk/test/ELF/relocatable-local-sym.s (added)
+++ lld/trunk/test/ELF/relocatable-local-sym.s Sun Dec 4 02:34:17 2016
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: ld.lld -r %t1.o -o %t2.o
+# RUN: llvm-readobj -r %t2.o | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.text {
+# CHECK-NEXT: 0x3 R_X86_64_PC32 .Lstr 0xFFFFFFFFFFFFFFFC
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+ leaq .Lstr(%rip), %rdi
+
+ .section .rodata.str1.1,"aMS", at progbits,1
+ .Lstr:
+ .asciz "abc\n"
More information about the llvm-commits
mailing list