pkgsrc/devel/binutils/patches/patch-gold_options.h
marino 4dd8c1fc15 devel/binutils: Change default behavior of gold for NetBSD & OpenBSD
The Gold linker defaults to the use of --new-dtags which uses DT_RUNPATH
instead of DT_RPATH.  In previous version of binutils, --new-dtags would
write set both DT_RUNPATH and DT_PATH, but not anymore.  The problem is
that neither NetBSD nor OpenBSD runtime linkers properly handle it
AFAICT.  Use macros to make DT_RPATH get set when -rpath switch is used
so that linked libraries can get found on these platforms.

Similarly, it appears that DT_INIT_ARRAY tags are also not handled by
rtld, so don't use these tags by default otherwise C++ will not link
on these platforms.

The copy-as-needed attribute has been left at its binutils default of
--no-copy-dt-needed.  This has been the default since binutils 2.22.
2014-05-12 16:33:20 +00:00

36 lines
1.5 KiB
C

$NetBSD: patch-gold_options.h,v 1.1 2014/05/12 16:33:20 marino Exp $
The NetBSD and OpenBSD real-time linkers do not understand DT_RUNPATH
or DT_INIT_ARRAY. The current gold defaults are not suitable for them.
The last couple of DragonFly and FreeBSD releases do support these tags.
--- gold/options.h.orig 2013-11-04 15:33:39.000000000 +0000
+++ gold/options.h
@@ -716,9 +716,15 @@ class General_options
N_("Output cross reference table"),
N_("Do not output cross reference table"));
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ DEFINE_bool(ctors_in_init_array, options::TWO_DASHES, '\0', false,
+ N_("Use DT_INIT_ARRAY for all constructors"),
+ N_("Handle constructors as directed by compiler (default)"));
+#else
DEFINE_bool(ctors_in_init_array, options::TWO_DASHES, '\0', true,
N_("Use DT_INIT_ARRAY for all constructors (default)"),
N_("Handle constructors as directed by compiler"));
+#endif
DEFINE_bool(define_common, options::TWO_DASHES, 'd', false,
N_("Define common symbols"),
@@ -949,7 +955,11 @@ class General_options
N_("Do not page align data, do not make text readonly"),
N_("Page align data, make text readonly"));
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ DEFINE_enable(new_dtags, options::EXACTLY_TWO_DASHES, '\0', false,
+#else
DEFINE_enable(new_dtags, options::EXACTLY_TWO_DASHES, '\0', true,
+#endif
N_("Enable use of DT_RUNPATH and DT_FLAGS"),
N_("Disable use of DT_RUNPATH and DT_FLAGS"));