Fix text relocations in linux-user targets

There is a link hack in linux-user which produces an executable that
looks like PIE, but always has text relocations since all object files
isn't position-independent (compiled without -fpic/-fpie). Dynamic loader
has to do more work to load a binary with text relocations.

The best way to keep this functionality is to build a true PIE without
text relocations.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Kirill A. Shutemov 2009-09-12 02:17:54 +03:00 committed by Blue Swirl
parent 5791f45b58
commit df70204db5
2 changed files with 1 additions and 37 deletions

12
configure vendored
View file

@ -2376,16 +2376,6 @@ fi
linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
case "$ARCH" in
i386)
if test "$gprof" = "yes" -o "$static" = "yes" ; then
ldflags="$linker_script $ldflags"
else
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
# that the kernel ELF loader considers as an executable. I think this
# is the simplest way to make it self virtualizable!
ldflags="-Wl,-shared $ldflags"
fi
;;
sparc)
# -static is used to avoid g1/g3 usage by the dynamic linker
ldflags="$linker_script -static $ldflags"
@ -2393,7 +2383,7 @@ if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
ia64)
ldflags="-Wl,-G0 $linker_script -static $ldflags"
;;
x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
ldflags="$linker_script $ldflags"
;;
esac

View file

@ -48,32 +48,6 @@ int have_guest_base;
static const char *interp_prefix = CONFIG_QEMU_PREFIX;
const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
#if defined(__i386__) && !defined(CONFIG_STATIC)
/* Force usage of an ELF interpreter even if it is an ELF shared
object ! */
const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2";
#endif
/* for recent libc, we add these dummy symbols which are not declared
when generating a linked object (bug in ld ?) */
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC)
asm(".globl __preinit_array_start\n"
".globl __preinit_array_end\n"
".globl __init_array_start\n"
".globl __init_array_end\n"
".globl __fini_array_start\n"
".globl __fini_array_end\n"
".section \".rodata\"\n"
"__preinit_array_start:\n"
"__preinit_array_end:\n"
"__init_array_start:\n"
"__init_array_end:\n"
"__fini_array_start:\n"
"__fini_array_end:\n"
".long 0\n"
".previous\n");
#endif
/* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
we allocate a bigger stack. Need a better solution, for example
by remapping the process stack directly at the right place */