From 9e1f9b3eacb51a67e675cd1195c472215fb16373 Mon Sep 17 00:00:00 2001 From: Pavel Chupin Date: Tue, 27 Nov 2012 14:09:50 +0400 Subject: [4.7] x32: Backport x32 support into 4.7 This patch contains all gcc changes required to build x32 compiler. They are backported from 4.8/trunk. Change-Id: I923f639c1f0cee5812b0f555a39bab0bd0723865 Signed-off-by: Pavel Chupin --- gcc-4.7/libffi/ChangeLog.x32 | 27 +++++++++++++++++++++++++++ gcc-4.7/libffi/configure | 13 ++++++++++--- gcc-4.7/libffi/src/x86/ffi64.c | 10 ++++++---- gcc-4.7/libffi/src/x86/ffitarget.h | 7 +++++++ 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 gcc-4.7/libffi/ChangeLog.x32 (limited to 'gcc-4.7/libffi') diff --git a/gcc-4.7/libffi/ChangeLog.x32 b/gcc-4.7/libffi/ChangeLog.x32 new file mode 100644 index 000000000..2cbed6487 --- /dev/null +++ b/gcc-4.7/libffi/ChangeLog.x32 @@ -0,0 +1,27 @@ +2012-07-18 H.J. Lu + + Backported from mainline + 2012-07-18 H.J. Lu + + * src/x86/ffitarget.h: Check __ILP32__ instead of __LP64__ for + x32. + (FFI_SIZEOF_JAVA_RAW): Defined to 4 for x32. + +2012-05-17 H.J. Lu + + Backported from mainline + 2012-03-03 H.J. Lu + + * src/x86/ffi64.c (ffi_call): Cast the return value to unsigned + long. + (ffi_prep_closure_loc): Cast to 64bit address in trampoline. + (ffi_closure_unix64_inner): Cast return pointer to unsigned long + first. + + * src/x86/ffitarget.h (FFI_SIZEOF_ARG): Defined to 8 for x32. + (ffi_arg): Set to unsigned long long for x32. + (ffi_sarg): Set to long long for x32. + +2012-05-16 H.J. Lu + + * configure: Regenerated. diff --git a/gcc-4.7/libffi/configure b/gcc-4.7/libffi/configure index 159149539..28ed5131c 100755 --- a/gcc-4.7/libffi/configure +++ b/gcc-4.7/libffi/configure @@ -6282,7 +6282,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -10766,7 +10773,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10769 "configure" +#line 10776 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10872,7 +10879,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10875 "configure" +#line 10882 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc-4.7/libffi/src/x86/ffi64.c b/gcc-4.7/libffi/src/x86/ffi64.c index bd907d720..41c4e776b 100644 --- a/gcc-4.7/libffi/src/x86/ffi64.c +++ b/gcc-4.7/libffi/src/x86/ffi64.c @@ -426,7 +426,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) /* If the return value is passed in memory, add the pointer as the first integer argument. */ if (ret_in_memory) - reg_args->gpr[gprcount++] = (long) rvalue; + reg_args->gpr[gprcount++] = (unsigned long) rvalue; avn = cif->nargs; arg_types = cif->arg_types; @@ -501,9 +501,11 @@ ffi_prep_closure_loc (ffi_closure* closure, tramp = (volatile unsigned short *) &closure->tramp[0]; tramp[0] = 0xbb49; /* mov , %r11 */ - *(void * volatile *) &tramp[1] = ffi_closure_unix64; + *((unsigned long long * volatile) &tramp[1]) + = (unsigned long) ffi_closure_unix64; tramp[5] = 0xba49; /* mov , %r10 */ - *(void * volatile *) &tramp[6] = codeloc; + *((unsigned long long * volatile) &tramp[6]) + = (unsigned long) codeloc; /* Set the carry bit iff the function uses any sse registers. This is clc or stc, together with the first byte of the jmp. */ @@ -542,7 +544,7 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue, { /* The return value goes in memory. Arrange for the closure return value to go directly back to the original caller. */ - rvalue = (void *) reg_args->gpr[gprcount++]; + rvalue = (void *) (unsigned long) reg_args->gpr[gprcount++]; /* We don't have to do anything in asm for the return. */ ret = FFI_TYPE_VOID; } diff --git a/gcc-4.7/libffi/src/x86/ffitarget.h b/gcc-4.7/libffi/src/x86/ffitarget.h index dfecd1b3c..f9548c609 100644 --- a/gcc-4.7/libffi/src/x86/ffitarget.h +++ b/gcc-4.7/libffi/src/x86/ffitarget.h @@ -53,9 +53,16 @@ typedef unsigned long long ffi_arg; typedef long long ffi_sarg; #endif #else +#if defined __x86_64__ && defined __ILP32__ +#define FFI_SIZEOF_ARG 8 +#define FFI_SIZEOF_JAVA_RAW 4 +typedef unsigned long long ffi_arg; +typedef long long ffi_sarg; +#else typedef unsigned long ffi_arg; typedef signed long ffi_sarg; #endif +#endif typedef enum ffi_abi { FFI_FIRST_ABI = 0, -- cgit v1.2.3