This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[GOLD PATCH]: Support for some more options.


The long story is that I'm trying to get a glibc build going using
gold.  I added some hacks so that the glibc configure script accepts
the --help output from gold when checking the version:

--- configure.in	11 Apr 2008 17:52:55 -0000	1.475
+++ configure.in	16 Apr 2008 05:19:02 -0000
@@ -847,8 +847,8 @@ AC_CHECK_PROG_VER(AS, $AS, --version,
 		  [GNU assembler.* \([0-9]*\.[0-9.]*\)],
 		  [2.1[3-9]*], AS=: critic_missing="$critic_missing as")
 AC_CHECK_PROG_VER(LD, $LD, --version,
-		  [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
-		  [2.1[3-9]*], LD=: critic_missing="$critic_missing ld")
+		  [GNU .*ld.* \([0-9][0-9]*\.[0-9.]*\)],
+		  [2.1[3-9]* | 1.[5-9]*], LD=: critic_missing="$critic_missing ld")
 
 # We need the physical current working directory.  We cannot use the
 # "pwd -P" shell builtin since that's not portable.  Instead we try to

But then it wants support for various options gold does not support
yet.

This patch below starts to chisel away at those missing options.
There are still some more needed before glibc is happy enough,
including "-z relro" which I'll take a stab at yet.

The ones below were easy so I wanted to get these out first.

--{enable,disable}-new-dtags seems to do two things in the
BFD linker:

1) If enabled, emit a DT_RUNPATH.

2) If enabled, allows emission of DT_FLAGS.  But even if
   disabled, when the static TLS DT_FLAGS bit needs to be
   indicated a DT_FLAGS will still be emitted.

Since GOLD already unconditonally emits DT_FLAGS even if the flags
value is zero, I did not modify gold's behavior here.

I tried to enable new-dtags by default, but the presence of the
DT_RUNPATH causes ver_test_4 to fail for some reason on Linux systems
I have access to.  Being disabled is the BFD linker default anyways.

The rest are '-z' options that simply set a particular flag in
DT_FLAGS_1, some of which are auto-unset when we are not emitting a
shared object.  All are disabled by default.

Any problems with this?

elfcpp/

2008-04-16  David S. Miller  <davem@davemloft.net>

	* elfcpp.h (DF_1_NOW, DF_1_GLOBAL, DF_1_GROUP,
	DF_1_NODELETE, DF_1_LOADFLTR, DF_1_INITFIRST,
	DF_1_NOOPEN, DF_1_ORIGIN, DF_1_DIRECT, DF_1_TRANS,
	DF_1_INTERPOSE, DF_1_NODEFLIB, DF_1_NODUMP,
	DF_1_CONLFAT): New enum constants.

Index: elfcpp.h
===================================================================
RCS file: /cvs/src/src/elfcpp/elfcpp.h,v
retrieving revision 1.16
diff -u -p -r1.16 elfcpp.h
--- elfcpp.h	11 Apr 2008 19:13:08 -0000	1.16
+++ elfcpp.h	16 Apr 2008 07:01:07 -0000
@@ -688,6 +688,26 @@ enum DF
   DF_STATIC_TLS = 0x10
 };
 
+// Flags found in the DT_FLAGS_1 dynamic element.
+
+enum DF_1
+{
+  DF_1_NOW = 0x1,
+  DF_1_GLOBAL = 0x2,
+  DF_1_GROUP = 0x4,
+  DF_1_NODELETE = 0x8,
+  DF_1_LOADFLTR = 0x10,
+  DF_1_INITFIRST = 0x20,
+  DF_1_NOOPEN = 0x40,
+  DF_1_ORIGIN = 0x80,
+  DF_1_DIRECT = 0x100,
+  DF_1_TRANS = 0x200,
+  DF_1_INTERPOSE = 0x400,
+  DF_1_NODEFLIB = 0x800,
+  DF_1_NODUMP = 0x1000,
+  DF_1_CONLFAT = 0x2000,
+};
+
 // Version numbers which appear in the vd_version field of a Verdef
 // structure.
 
gold/

2008-04-16  David S. Miller  <davem@davemloft.net>

	* options.h (DEFINE_enable): New macro.
	(new_dtags): New enable option.
	(initfirst, interpose, loadfltr, nodefaultlib,
	nodelete, nodlopen, nodump): New -z options.
	* layout.cc (Layout:finish_dynamic_section): If new
	dtags enabled, emit DT_RUNPATH.  Also, emit a
	DT_FLAGS_1 containing any specified -z flags.
	
Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.98
diff -u -p -r1.98 layout.cc
--- layout.cc	15 Apr 2008 04:06:40 -0000	1.98
+++ layout.cc	16 Apr 2008 07:03:21 -0000
@@ -2459,6 +2459,8 @@ Layout::finish_dynamic_section(const Inp
         }
 
       odyn->add_string(elfcpp::DT_RPATH, rpath_val);
+      if (parameters->options().enable_new_dtags())
+	odyn->add_string(elfcpp::DT_RUNPATH, rpath_val);
     }
 
   // Look for text segments that have dynamic relocations.
@@ -2509,6 +2511,27 @@ Layout::finish_dynamic_section(const Inp
   if (parameters->options().shared() && this->has_static_tls())
     flags |= elfcpp::DF_STATIC_TLS;
   odyn->add_constant(elfcpp::DT_FLAGS, flags);
+
+  flags = 0;
+  if (parameters->options().initfirst())
+    flags |= elfcpp::DF_1_INITFIRST;
+  if (parameters->options().interpose())
+    flags |= elfcpp::DF_1_INTERPOSE;
+  if (parameters->options().loadfltr())
+    flags |= elfcpp::DF_1_LOADFLTR;
+  if (parameters->options().nodefaultlib())
+    flags |= elfcpp::DF_1_NODEFLIB;
+  if (parameters->options().nodelete())
+    flags |= elfcpp::DF_1_NODELETE;
+  if (parameters->options().nodlopen())
+    flags |= elfcpp::DF_1_NOOPEN;
+  if (parameters->options().nodump())
+    flags |= elfcpp::DF_1_NODUMP;
+  if (!parameters->options().shared())
+    flags &= ~(elfcpp::DF_1_INITFIRST
+	       | elfcpp::DF_1_NODELETE
+	       | elfcpp::DF_1_NOOPEN);
+  odyn->add_constant(elfcpp::DT_FLAGS_1, flags);
 }
 
 // The mapping of .gnu.linkonce section names to real section names.
Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.69
diff -u -p -r1.69 options.h
--- options.h	11 Apr 2008 20:28:34 -0000	1.69
+++ options.h	16 Apr 2008 07:03:22 -0000
@@ -286,6 +286,28 @@ struct Struct_special : public Struct_va
   };                                                                     \
   Struct_no_##varname__ no_##varname__##_initializer_
 
+#define DEFINE_enable(varname__, dashes__, shortname__, default_value__, \
+                      helpstring__, no_helpstring__)                     \
+  DEFINE_var(enable_##varname__, dashes__, shortname__, default_value__, \
+             default_value__ ? "true" : "false", helpstring__, NULL,     \
+             false, bool, bool, options::parse_bool)			 \
+  struct Struct_disable_##varname__ : public options::Struct_var         \
+  {                                                                      \
+    Struct_disable_##varname__() : option("disable-" #varname__,         \
+                                     dashes__, '\0',                     \
+                                     default_value__ ? "false" : "true", \
+                                     no_helpstring__, NULL, false, this) \
+    { }                                                                  \
+                                                                         \
+    void                                                                 \
+    parse_to_value(const char*, const char*,                             \
+                   Command_line*, General_options* options)              \
+    { options->set_enable_##varname__(false); }                          \
+                                                                         \
+    options::One_option option;                                          \
+  };                                                                     \
+  Struct_disable_##varname__ disable_##varname__##_initializer_
+
 #define DEFINE_uint(varname__, dashes__, shortname__, default_value__,  \
                    helpstring__, helparg__)                             \
   DEFINE_var(varname__, dashes__, shortname__, default_value__,         \
@@ -538,6 +560,10 @@ class General_options
   DEFINE_string(m, options::EXACTLY_ONE_DASH, 'm', "",
                 N_("Ignored for compatibility"), N_("EMULATION"));
 
+  DEFINE_enable(new_dtags, options::EXACTLY_TWO_DASHES, '\0', false,
+		N_("Enable use of DT_RUNPATH and DT_FLAGS"),
+		N_("Disable use of DT_RUNPATH and DT_FLAGS"));
+
   DEFINE_bool(noinhibit_exec, options::TWO_DASHES, '\0', false,
 	      N_("Create an output file even if errors occur"), NULL);
 
@@ -653,6 +679,27 @@ class General_options
                 N_("Set maximum page size to SIZE"), N_("SIZE"));
   DEFINE_bool(noexecstack, options::DASH_Z, '\0', false,
               N_("Mark output as not requiring executable stack"), NULL);
+  DEFINE_bool(initfirst, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_INITFIRST in DT_FLAGS_1 of shared object."),
+	      NULL);
+  DEFINE_bool(interpose, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_INTERPOSE in DT_FLAGS_1 of output object."),
+	      NULL);
+  DEFINE_bool(loadfltr, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_LOADFLTR in DT_FLAGS_1 of output object."),
+	      NULL);
+  DEFINE_bool(nodefaultlib, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_NODEFLIB in DT_FLAGS_1 of output object."),
+	      NULL);
+  DEFINE_bool(nodelete, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_NODELETE in DT_FLAGS_1 of output object."),
+	      NULL);
+  DEFINE_bool(nodlopen, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_NOOPEN in DT_FLAGS_1 of output object."),
+	      NULL);
+  DEFINE_bool(nodump, options::DASH_Z, '\0', false,
+	      N_("Set DT_1_NODUMP in DT_FLAGS_1 of output object."),
+	      NULL);
 
  public:
   typedef options::Dir_list Dir_list;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]