gcc7/gcc-4.7.1-linux32.patch

69 lines
2.4 KiB
Diff

--- gcc-linaro-4.8-2013.10/gcc/config/i386/biarch64.h.linux32~ 2013-10-23 13:05:04.743417335 +0200
+++ gcc-linaro-4.8-2013.10/gcc/config/i386/biarch64.h 2013-10-23 13:06:46.186149127 +0200
@@ -27,3 +27,11 @@ see the files COPYING3 and COPYING.RUNTI
#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64)
#define TARGET_BI_ARCH 1
+#if defined(__linux__)
+#ifndef inhibit_libc
+#include <sys/syscall.h>
+#include <sys/personality.h>
+#define TARGET_32BIT_PERSONALITY \
+ ((syscall(SYS_personality, 0xffffffff) & PER_MASK) == PER_LINUX32)
+#endif
+#endif
--- gcc-linaro-4.8-2013.10/gcc/opts-common.c.linux32~ 2013-04-08 21:06:00.000000000 +0200
+++ gcc-linaro-4.8-2013.10/gcc/opts-common.c 2013-10-23 13:05:04.743417335 +0200
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.
#include "system.h"
#include "intl.h"
#include "coretypes.h"
+#include "tm.h"
#include "opts.h"
#include "flags.h"
#include "diagnostic.h"
@@ -744,6 +745,10 @@ decode_cmdline_options_to_array (unsigne
unsigned int n, i;
struct cl_decoded_option *opt_array;
unsigned int num_decoded_options;
+#ifdef TARGET_32BIT_PERSONALITY
+ bool arch_flag = false;
+ bool arch_32bit = TARGET_32BIT_PERSONALITY;
+#endif
opt_array = XNEWVEC (struct cl_decoded_option, argc);
@@ -773,11 +778,33 @@ decode_cmdline_options_to_array (unsigne
continue;
}
+#ifdef TARGET_32BIT_PERSONALITY
+ if (!arch_flag && arch_32bit
+ && opt[1] == 'm' && ((opt[2] == '3' && opt[3] == '2')
+ || (opt[2] == '6' && opt[3] == '4'))
+ && opt[4] == '\0')
+ arch_flag = true;
+#endif
n = decode_cmdline_option (argv + i, lang_mask,
&opt_array[num_decoded_options]);
num_decoded_options++;
}
+#ifdef TARGET_32BIT_PERSONALITY
+ if (!arch_flag && arch_32bit)
+ {
+ char const **argvec = XNEWVEC (char const *, 2);
+ argvec[0] = "-m32";
+ argvec[1] = NULL;
+ if (++num_decoded_options > argc)
+ opt_array = XRESIZEVEC (struct cl_decoded_option,
+ opt_array, num_decoded_options);
+ (void)decode_cmdline_option (argvec, lang_mask,
+ &opt_array[num_decoded_options - 1]);
+ free (argvec);
+ }
+#endif
+
*decoded_options = opt_array;
*decoded_options_count = num_decoded_options;
prune_options (decoded_options, decoded_options_count);