[PATCH] configure: Check for linker relocation support before relying on prelink

Michael Cronenworth mike at cchtml.com
Wed Oct 14 22:45:40 CDT 2015


Prelink was used to rewrite binares and set their text segment, but
modern linkers support setting the value at link time. Prelink is
being retired by upstream.

Signed-off-by: Michael Cronenworth <mike at cchtml.com>
---
 configure.ac            | 13 ++++++++++---
 tools/winegcc/winegcc.c |  8 ++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index de8cde5..e6954ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -988,10 +988,17 @@ wine-installed: main.o
                            *) LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x7bf00400" ;;
                            esac
                           ])
-          AC_PATH_PROG(PRELINK, prelink, false, [/sbin /usr/sbin $PATH])
-          if test "x$PRELINK" = xfalse
+          WINE_TRY_CFLAGS([-Wl,-Ttext-segment=0x7bc00000],
+                          [AC_DEFINE([HAVE_TTEXT_SEGMENT],[1],[Define if
+linker supports -Ttext-segment.])],
+                          [HAVE_TTEXT_SEGMENT="no"])
+          if test "x$HAVE_TTEXT_SEGMENT" = "xno"
           then
-              WINE_WARNING([prelink not found, base address of core dlls won't be set correctly.])
+              AC_PATH_PROG(PRELINK, prelink, false, [/sbin /usr/sbin $PATH])
+              if test "x$PRELINK" = xfalse
+              then
+                  WINE_WARNING([prelink not found and linker does not support relocation, base address of core dlls won't be set correctly.])
+              fi
           fi
           ;;
       esac
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 3b2794e..9adfc9c 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -1134,6 +1134,12 @@ static void build(struct options* opts)
         }
         break;
     default:
+#ifdef HAVE_TTEXT_SEGMENT
+        if (opts->image_base)
+        {
+            strarray_add(link_args, strmake("-Wl,-Ttext-segment=%s", opts->image_base));
+        }
+#endif
         break;
     }
 
@@ -1167,6 +1173,7 @@ static void build(struct options* opts)
     spawn(opts->prefix, link_args, 0);
     strarray_free (link_args);
 
+#ifndef HAVE_TTEXT_SEGMENT
     /* set the base address */
     if (opts->image_base && !opts->target)
     {
@@ -1182,6 +1189,7 @@ static void build(struct options* opts)
             strarray_free(prelink_args);
         }
     }
+#endif
 
     /* create the loader script */
     if (generate_app_loader)
-- 
2.4.3




More information about the wine-patches mailing list