[PATCH] Add support for -Ttext-segment linker flag to set image base of a dll.

Tijl Coosemans tijl at coosemans.org
Thu Feb 28 12:32:34 CST 2013


---
 configure.ac            | 2 ++
 tools/winegcc/winegcc.c | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/configure.ac b/configure.ac
index 836c4e7..303091c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -874,6 +874,8 @@ case $host_os in
                            *) LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x7bf00400" ;;
                            esac
                           ])
+          WINE_TRY_CFLAGS([-Wl,-Ttext-segment=0x7bc00000],
+                          [AC_DEFINE([HAVE_TTEXT_SEGMENT],[1],[Define if linker supports -Ttext-segment.])])
           AC_PATH_PROG(PRELINK, prelink, false, [/sbin /usr/sbin $PATH])
           if test "x$PRELINK" = xfalse
           then
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 7d528e0..4c4cfa4 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -1031,6 +1031,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;
     }
 
@@ -1064,6 +1070,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)
     {
@@ -1079,6 +1086,7 @@ static void build(struct options* opts)
             strarray_free(prelink_args);
         }
     }
+#endif
 
     /* create the loader script */
     if (generate_app_loader)
-- 
1.8.1.3




More information about the wine-patches mailing list