From 8016bdfd934d0bfed10cf29b255149ad48a523dd Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 8 Sep 2017 18:53:43 +0000 Subject: [PATCH] Handle empty dynamic lists. llvm-svn: 312820 --- lld/ELF/Config.h | 1 + lld/ELF/ScriptParser.cpp | 1 + lld/ELF/Writer.cpp | 2 +- lld/test/ELF/dynamic-list-empty.s | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/dynamic-list-empty.s diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 59745cd0817a..831854eba110 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -126,6 +126,7 @@ struct Configuration { bool GcSections; bool GdbIndex; bool GnuHash; + bool HasDynamicList = false; bool ICF; bool MipsN32Abi = false; bool NoGnuUnique; diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 616164bfc639..6a534e60cbaf 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -180,6 +180,7 @@ static ExprValue bitOr(ExprValue A, ExprValue B) { } void ScriptParser::readDynamicList() { + Config->HasDynamicList = true; expect("{"); std::vector Locals; std::vector Globals; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 0e2504ee9896..d667894a8518 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1244,7 +1244,7 @@ static bool computeIsPreemptible(const SymbolBody &B) { return true; // If we have a dynamic list it specifies which local symbols are preemptible. - if (!Config->DynamicList.empty()) + if (Config->HasDynamicList) return false; if (!Config->Shared) diff --git a/lld/test/ELF/dynamic-list-empty.s b/lld/test/ELF/dynamic-list-empty.s new file mode 100644 index 000000000000..5686ce0c431b --- /dev/null +++ b/lld/test/ELF/dynamic-list-empty.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +# BFD reports a parse error on empty lists, but it is clear how to +# handle it. + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "{ };" > %t.list +# RUN: ld.lld -dynamic-list %t.list -shared %t.o -o %t.so +# RUN: llvm-readobj -r %t.so | FileCheck %s + +# CHECK: Relocations [ +# CHECK-NEXT: ] + + .globl foo +foo: + ret + + call foo@PLT