summaryrefslogtreecommitdiff
path: root/debian/patches/dyson-ld_altexec.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/dyson-ld_altexec.patch')
-rw-r--r--debian/patches/dyson-ld_altexec.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/debian/patches/dyson-ld_altexec.patch b/debian/patches/dyson-ld_altexec.patch
new file mode 100644
index 0000000..d4c019a
--- /dev/null
+++ b/debian/patches/dyson-ld_altexec.patch
@@ -0,0 +1,77 @@
+Index: binutils-2.26/ld/ld.texinfo
+===================================================================
+--- binutils-2.26.orig/ld/ld.texinfo
++++ binutils-2.26/ld/ld.texinfo
+@@ -2960,7 +2960,10 @@ You can change the behaviour of @command
+ @ifclear SingleFormat
+ @code{GNUTARGET},
+ @end ifclear
+-@code{LDEMULATION} and @code{COLLECT_NO_DEMANGLE}.
++@code{LDEMULATION},
++@code{COLLECT_NO_DEMANGLE}
++and
++@code{LD_ALTEXEC}.
+
+ @ifclear SingleFormat
+ @kindex GNUTARGET
+@@ -2998,6 +3001,12 @@ a similar fashion by the @code{gcc} link
+ may be overridden by the @samp{--demangle} and @samp{--no-demangle}
+ options.
+
++@kindex LD_ALTEXEC
++@cindex alternative linker
++@code{LD_ALTEXEC} sets alternative linker. @command{ld} executes,
++and passes control to this alternative linker. For instance one
++can set @code{LD_ALTEXEC=echo} to debug linker command line.
++
+ @c man end
+ @end ifset
+
+Index: binutils-2.26/ld/ldmain.c
+===================================================================
+--- binutils-2.26.orig/ld/ldmain.c
++++ binutils-2.26/ld/ldmain.c
+@@ -49,6 +49,7 @@
+ #endif
+
+ #include <string.h>
++#include <errno.h>
+
+ #ifdef HAVE_SBRK
+ #if !HAVE_DECL_SBRK
+@@ -183,9 +184,35 @@ ld_bfd_assert_handler (const char *fmt,
+ config.make_executable = FALSE;
+ }
+
++static void
++maybe_altexec(char **argv)
++{
++ char *LD_ALTEXEC;
++
++ /* If LD_ALTEXEC is not set or is empty, just return */
++ LD_ALTEXEC = getenv("LD_ALTEXEC");
++ if (LD_ALTEXEC == NULL)
++ return;
++
++ if (*LD_ALTEXEC == '\0')
++ return;
++
++ /* Unset LD_ALTEXEC for case when it points to this program itself ;-) */
++ if (unsetenv("LD_ALTEXEC"))
++ exit(errno);
++
++ argv[0] = LD_ALTEXEC;
++ execvp(LD_ALTEXEC, argv);
++
++ /* We are here only if execvp() failed */
++ exit(errno);
++}
++
+ int
+ main (int argc, char **argv)
+ {
++ maybe_altexec(argv);
++
+ char *emulation;
+ long start_time = get_run_time ();
+ #ifdef HAVE_SBRK