[PATCH] D54577: [ELF] - Implement -z nodefaultlib

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 23 00:05:08 PST 2018


grimar updated this revision to Diff 175086.
grimar added a comment.

- Addressed review comment.


https://reviews.llvm.org/D54577

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/SyntheticSections.cpp
  docs/ld.lld.1
  test/ELF/dt_flags.s


Index: test/ELF/dt_flags.s
===================================================================
--- test/ELF/dt_flags.s
+++ test/ELF/dt_flags.s
@@ -3,8 +3,8 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
 # RUN: ld.lld -shared %t -o %t.so
 
-# RUN: ld.lld -z global -z initfirst -z interpose -z now -z nodelete \
-# RUN:   -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld -z global -z initfirst -z interpose -z now -z nodefaultlib \
+# RUN:   -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
 # RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
 
 # RUN: ld.lld %t %t.so -o %t2
@@ -15,7 +15,7 @@
 
 # FLAGS: DynamicSection [
 # FLAGS:   0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# FLAGS:   0x000000006FFFFFFB FLAGS_1 NOW GLOBAL NODELETE INITFIRST NOOPEN ORIGIN INTERPOSE
+# FLAGS:   0x000000006FFFFFFB FLAGS_1 NOW GLOBAL NODELETE INITFIRST NOOPEN ORIGIN INTERPOSE NODEFLIB
 # FLAGS: ]
 
 # CHECK: DynamicSection [
Index: docs/ld.lld.1
===================================================================
--- docs/ld.lld.1
+++ docs/ld.lld.1
@@ -496,6 +496,10 @@
 Disable combining and sorting multiple relocation sections.
 .It Cm nocopyreloc
 Disable the creation of copy relocations.
+.It Cm nodefaultlib
+Set the
+.Dv DF_1_NODEFLIB
+flag to indicate that default library search path should be ignored.
 .It Cm nodelete
 Set the
 .Dv DF_1_NODELETE
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1271,6 +1271,8 @@
     DtFlags1 |= DF_1_INITFIRST;
   if (Config->ZInterpose)
     DtFlags1 |= DF_1_INTERPOSE;
+  if (Config->ZNodefaultlib)
+    DtFlags1 |= DF_1_NODEFLIB;
   if (Config->ZNodelete)
     DtFlags1 |= DF_1_NODELETE;
   if (Config->ZNodlopen)
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -350,8 +350,8 @@
          S == "execstack" || S == "global" || S == "hazardplt" ||
          S == "initfirst" || S == "interpose" ||
          S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" ||
-         S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" ||
-         S == "nodlopen" || S == "noexecstack" ||
+         S == "nocombreloc" || S == "nocopyreloc" || S == "nodefaultlib" ||
+         S == "nodelete" || S == "nodlopen" || S == "noexecstack" ||
          S == "nokeep-text-section-prefix" || S == "norelro" || S == "notext" ||
          S == "now" || S == "origin" || S == "relro" || S == "retpolineplt" ||
          S == "rodynamic" || S == "text" || S == "wxneeded" ||
@@ -876,6 +876,7 @@
   Config->ZInterpose = hasZOption(Args, "interpose");
   Config->ZKeepTextSectionPrefix = getZFlag(
       Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
+  Config->ZNodefaultlib = hasZOption(Args, "nodefaultlib");
   Config->ZNodelete = hasZOption(Args, "nodelete");
   Config->ZNodlopen = hasZOption(Args, "nodlopen");
   Config->ZNow = getZFlag(Args, "now", "lazy", false);
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -189,6 +189,7 @@
   bool ZInitfirst;
   bool ZInterpose;
   bool ZKeepTextSectionPrefix;
+  bool ZNodefaultlib;
   bool ZNodelete;
   bool ZNodlopen;
   bool ZNow;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54577.175086.patch
Type: text/x-patch
Size: 3403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181123/04af2c0a/attachment.bin>


More information about the llvm-commits mailing list