Message ID | 1371734143-780-1-git-send-email-emaste@freebsd.org |
---|---|
State | New |
Headers | show |
On 06/20/2013 06:15 AM, Ed Maste wrote: > + try_ldflags="-Ttext-segment=$textseg_addr" Two problems: (1) you forgot "-Wl," here. (2) We're running into some strange problem with git submodule init dtc. >From config.log: > cc -Werror -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng15 -I/usr/include/spice-server -I/usr/include/cacard -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/spice-1 -I/usr/include/nss3 -I/usr/include/nspr4 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt -o /tmp/qemu-conf-29328-15251-22199.exe /tmp/qemu-conf-7372-15251-10868.c -Wl,--warn-common -m64 -g -Wl,-Ttext-segment=0x60000000 > cc1: error: $(SRC_PATH)/dtc/libfdt: No such file or directory [-Werror] > cc1: all warnings being treated as errors And because of that -Werror, we never detect that -Ttext-segment is supported, which leads to the incorrect frobbing of the config-host.ld: > PROVIDE (__executable_start = 0x60000000SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS; I have no idea what's going wrong with the libfdt thing... r~
diff --git a/configure b/configure index ad32f87..b3025df 100755 --- a/configure +++ b/configure @@ -4072,9 +4072,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 +4434,35 @@ 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 + textseg_addr= case "$ARCH" in - alpha | s390x | aarch64) - # The default placement of the application is fine. + arm | hppa | i386 | ia64 | m68k | ppc | ppc64 | s390 | sparc | sparc64 | x86_64) + textseg_addr=0x60000000 ;; - *) - ldflags="$linker_script $ldflags" + mips) + textseg_addr=0x400000 ;; esac + if [ -n "$textseg_addr" ]; then +cat > $TMPC <<EOF +int main(void) { return 0; } +EOF + try_ldflags="-Ttext-segment=$textseg_addr" + if compile_prog "" "$try_ldflags"; then + ldflags="$ldflags $try_ldflags" + else + # 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 + ldflags="$ldflags -Wl,-T../config-host.ld" + fi + fi fi echo "LDFLAGS+=$ldflags" >> $config_target_mak
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. Note that ldscripts/alpha.ld was already unused prior to this change, as it was handled by the "default placement of the application is fine" case. Signed-off-by: Ed Maste <emaste@freebsd.org> --- Changes from v1: - Drop removal of ldscripts from the patch for now. They remain unused with v2 and can be removed later, but this makes the patch smaller during review and testing. - Don't require knowledge of the default .text address, as suggested by Richard Henderson. - Use configure's existing compile_prog to test for acceptance of the linker flag rather than a hack that fails on current binutils versions. configure | 37 +++++---