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

Marcus Meissner meissner at suse.de
Thu Oct 15 06:16:50 CDT 2015


On Wed, Oct 14, 2015 at 10:45:40PM -0500, Michael Cronenworth wrote:
> 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>


Signed-off-by: Marcus Meissner <meissner at suse.de>


Ciao, Marcus
> ---
>  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
> 
> 
> 
> 

-- 
Marcus Meissner,SUSE LINUX GmbH; Maxfeldstrasse 5; D-90409 Nuernberg; Zi. 3.1-33,+49-911-740 53-432,,serv=loki,mail=wotan,type=real <meissner at suse.de>



More information about the wine-patches mailing list