From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uwa56-0005MN-Eq for qemu-devel@nongnu.org; Tue, 09 Jul 2013 11:43:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uwa51-0000Og-AD for qemu-devel@nongnu.org; Tue, 09 Jul 2013 11:43:56 -0400 Received: from mail-qe0-x230.google.com ([2607:f8b0:400d:c02::230]:46055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uwa51-0000Oc-5M for qemu-devel@nongnu.org; Tue, 09 Jul 2013 11:43:51 -0400 Received: by mail-qe0-f48.google.com with SMTP id 2so3123889qea.35 for ; Tue, 09 Jul 2013 08:43:50 -0700 (PDT) Sender: Richard Henderson Message-ID: <51DC2FB2.3060001@twiddle.net> Date: Tue, 09 Jul 2013 08:43:46 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1371867016-7660-1-git-send-email-rth@twiddle.net> <51D2EDC3.8060709@twiddle.net> In-Reply-To: <51D2EDC3.8060709@twiddle.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] configure: Simplify alternate .text segment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Ed Maste Ping 2. On 07/02/2013 08:12 AM, Richard Henderson wrote: > Ping. > > On 06/21/2013 07:10 PM, Richard Henderson wrote: >> For bsd-user and linux-user emulation modes QEMU needs to be linked at an >> alternate .text segment address, so that it's out of the way of the guest >> executable. Instead of including modified linker scripts for each arch, >> just set the address with -Ttext-segment if supported, or by using sed to >> edit the default linker script. >> >> Cc: Ed Maste >> Signed-off-by: Richard Henderson >> --- >> configure | 48 +++++++++++++++++++++++++++++++----------------- >> 2 files changed, 31 insertions(+), 18 deletions(-) >> -- >> >> Changes v2-v3: >> * Move the check for textseg_ldflags much earlier in the configure file, >> so that we've not got cflags invalid for configure time. Plus, the >> check (and generated ld script) only gets done once, not once per >> target directory. >> * Remove ia64 from the hosts that get relocation >> * Handle s390x like s390. >> >> Tested on x86_64, arm, hppa (old binutils needing config-host.ld), >> sparc64, and ia64. All various versions of linux. >> >> >> r~ >> >> >> >> diff --git a/configure b/configure >> index ad32f87..63da418 100755 >> --- a/configure >> +++ b/configure >> @@ -3444,6 +3444,36 @@ if test "$cpu" = "s390x" ; then >> roms="$roms s390-ccw" >> fi >> >> +# Probe for the need for relocating the user-only binary. >> +if test "$pie" = "no" ; then >> + textseg_addr= >> + case "$cpu" in >> + arm | hppa | i386 | m68k | ppc | ppc64 | s390* | sparc | sparc64 | x86_64) >> + textseg_addr=0x60000000 >> + ;; >> + mips) >> + textseg_addr=0x400000 >> + ;; >> + esac >> + if [ -n "$textseg_addr" ]; then >> + cat > $TMPC <> + int main(void) { return 0; } >> +EOF >> + textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr" >> + if ! compile_prog "" "$textseg_ldflags"; then >> + # In case ld does not support -Ttext-segment, edit the default linker >> + # script via sed to set the .text start addr. This is needed on FreeBSD >> + # at least. >> + $ld --verbose | sed \ >> + -e '1,/==================================================/d' \ >> + -e '/==================================================/,$d' \ >> + -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \ >> + -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld >> + textseg_ldflags="-Wl,-T../config-host.ld" >> + fi >> + fi >> +fi >> + >> # add pixman flags after all config tests are done >> QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags" >> libs_softmmu="$libs_softmmu $pixman_libs" >> @@ -4072,9 +4102,6 @@ if test "$gcov" = "yes" ; then >> echo "GCOV=$gcov_tool" >> $config_host_mak >> fi >> >> -# generate list of library paths for linker script >> -$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > config-host.ld >> - >> # use included Linux headers >> if test "$linux" = "yes" ; then >> mkdir -p linux-headers >> @@ -4437,21 +4464,8 @@ if test "$gprof" = "yes" ; then >> fi >> fi >> >> -if test "$ARCH" = "tci"; then >> - linker_script="" >> -else >> - linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/ldscripts/\$(ARCH).ld" >> -fi >> - >> if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then >> - case "$ARCH" in >> - alpha | s390x | aarch64) >> - # The default placement of the application is fine. >> - ;; >> - *) >> - ldflags="$linker_script $ldflags" >> - ;; >> - esac >> + ldflags="$ldflags $textseg_ldflags" >> fi >> >> echo "LDFLAGS+=$ldflags" >> $config_target_mak >> >