[PATCH] [GNU] Implement --enable-new-dtags/--disable-new-dtags

Davide Italiano davide at freebsd.org
Sun Apr 5 18:37:24 PDT 2015


Hi ruiu, shankarke,

This fixes https://llvm.org/bugs/show_bug.cgi?id=23036

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8836

Files:
  include/lld/ReaderWriter/ELFLinkingContext.h
  lib/Driver/GnuLdDriver.cpp
  lib/Driver/GnuLdOptions.td
  lib/ReaderWriter/ELF/OutputELFWriter.h

Index: include/lld/ReaderWriter/ELFLinkingContext.h
===================================================================
--- include/lld/ReaderWriter/ELFLinkingContext.h
+++ include/lld/ReaderWriter/ELFLinkingContext.h
@@ -292,6 +292,10 @@
   bool alignSegments() const { return _alignSegments; }
   void setAlignSegments(bool align) { _alignSegments = align; }
 
+  /// \brief Enable new dtags.
+  bool enableNewDtags() const { return _enableNewDtags; }
+  void setEnableNewDtags(bool e) { _enableNewDtags = e; }
+
   /// \brief Strip symbols.
   bool stripSymbols() const { return _stripSymbols; }
   void setStripSymbols(bool strip) { _stripSymbols = strip; }
@@ -346,6 +350,7 @@
   bool _demangle = true;
   bool _stripSymbols = false;
   bool _alignSegments = true;
+  bool _enableNewDtags = false;
   bool _collectStats = false;
   bool _armTarget1Rel = false;
   uint64_t _maxPageSize = 0x1000;
Index: lib/Driver/GnuLdDriver.cpp
===================================================================
--- lib/Driver/GnuLdDriver.cpp
+++ lib/Driver/GnuLdDriver.cpp
@@ -620,6 +620,14 @@
       ctx->addRpathLink(path);
   }
 
+  // Enable new dynamic tags.
+  bool newdtags;
+  if (parsedArgs->hasArg(OPT_enable_newdtags))
+    newdtags = true;
+  if (parsedArgs->hasArg(OPT_disable_newdtags))
+    newdtags = false;
+  ctx->setEnableNewDtags(newdtags);
+
   // Support --wrap option.
   for (auto *arg : parsedArgs->filtered(OPT_wrap))
     ctx->addWrapForSymbol(arg->getValue());
Index: lib/Driver/GnuLdOptions.td
===================================================================
--- lib/Driver/GnuLdOptions.td
+++ lib/Driver/GnuLdOptions.td
@@ -231,6 +231,12 @@
 //===----------------------------------------------------------------------===//
 def grp_customopts : OptionGroup<"opts">,
      HelpText<"CUSTOM OPTIONS">;
+def disable_newdtags: Flag<["--"], "disable-new-dtags">,
+     HelpText<"Disable new dynamic tags">,
+     Group<grp_customopts>;
+def enable_newdtags: Flag<["--"], "enable-new-dtags">,
+     HelpText<"Enable new dynamic tags">,
+     Group<grp_customopts>;
 def rosegment: Flag<["--"], "rosegment">,
      HelpText<"Put read-only non-executable sections in their own segment">,
      Group<grp_customopts>;
Index: lib/ReaderWriter/ELF/OutputELFWriter.h
===================================================================
--- lib/ReaderWriter/ELF/OutputELFWriter.h
+++ lib/ReaderWriter/ELF/OutputELFWriter.h
@@ -280,7 +280,7 @@
     auto rpath = new (_alloc) std::string(join(rpathList.begin(),
       rpathList.end(), ":"));
     Elf_Dyn dyn;
-    dyn.d_tag = DT_RPATH;
+    dyn.d_tag = (_ctx.enableNewDtags()) ? DT_RUNPATH : DT_RPATH;
     dyn.d_un.d_val = _dynamicStringTable->addString(*rpath);
     _dynamicTable->addEntry(dyn);
   }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8836.23262.patch
Type: text/x-patch
Size: 2765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150406/7126c347/attachment.bin>


More information about the llvm-commits mailing list