forked from OSchip/llvm-project
Don't discard .L symbol with -r.
They might be used by relocations. Fixes pr31252. llvm-svn: 288617
This commit is contained in:
parent
e3161c568d
commit
61d052d725
|
|
@ -420,6 +420,8 @@ static bool getArg(opt::InputArgList &Args, unsigned K1, unsigned K2,
|
|||
}
|
||||
|
||||
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::InputArgList &Args) {
|
|||
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::InputArgList &Args) {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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",@progbits,1
|
||||
.Lstr:
|
||||
.asciz "abc\n"
|
||||
Loading…
Reference in New Issue