Sophie

Sophie

distrib > Mandriva > 2010.2 > x86_64 > by-pkgid > fbaee924b14d9e589e5bb7c78cc33ff5 > files > 4

cross-arm-binutils-2.20.51.0.4-2mnb2.src.rpm

2009-11-25 Per Øyvind Karlsen <peroyvind@mandriva.org>

	* Regenerate patch against binutils 2.20.51

2009-07-27 Matthew Dawkins <mattydaw@gmail.com>

	* Regenerate patch against binutils 2.19.51.0.14
	
2008-01-29  Per ?~Xyvind Karlsen  <peroyvind@mandriva.org>

        * Regenerate patch again binutils 2.18.50.3.

2006-12-11  Gwenole Beauchesne  <gbeauchesne@mandriva.com>

        * gas/config/tc-ppc.c (ppc_get_obj64): New. Handle run-time
        detection of 32-bit personality on Linux for ppc64 so that 32-bit
        code can be generated.
        (ppc_set_obj64): New.
        (md_parse_option): Use it.

2005-01-19  Gwenole Beauchesne  <gbeauchesne@mandrakesoft.com>

        * gas/config/tc-i386.c (is_linux32): New.
        (get_default_arch): Handle detection of 32-bit personality on
        Linux for x86-64 so that 32-bit code can be generated.
        (set_default_arch): New.
        (md_parse_option): Use it.
        (i386_mach): Use new default_arch accessors.
        (i386_target_format): Likewise.


diff -p -up binutils-2.20.51/gas/config/tc-i386.c.linux32~ binutils-2.20.51/gas/config/tc-i386.c
--- binutils-2.20.51/gas/config/tc-i386.c.linux32~	2009-11-18 15:28:57.000000000 -0500
+++ binutils-2.20.51/gas/config/tc-i386.c	2009-11-25 05:44:32.131923412 -0500
@@ -35,6 +35,13 @@
 #include "elf/x86-64.h"
 #include "opcodes/i386-init.h"
 
+#if defined(__linux__) && defined(__x86_64__)
+#include <sys/syscall.h>
+#include <sys/personality.h>
+
+#define is_linux32() ((syscall(SYS_personality, 0xffffffff) & PER_MASK) == PER_LINUX32)
+#endif
+
 #ifndef REGISTER_WARNINGS
 #define REGISTER_WARNINGS 1
 #endif
@@ -180,7 +187,16 @@ static void s_bss (int);
 static void handle_large_common (int small ATTRIBUTE_UNUSED);
 #endif
 
-static const char *default_arch = DEFAULT_ARCH;
+enum x86_arch
+  {
+    ARCH_default,
+    ARCH_i386,
+    ARCH_x86_64
+  };
+
+static enum x86_arch g_default_arch = ARCH_default;
+static enum x86_arch get_default_arch PARAMS ((void));
+static INLINE void set_default_arch PARAMS ((enum x86_arch arch));
 
 /* VEX prefix.  */
 typedef struct
@@ -2000,7 +2016,7 @@ check_cpu_arch_compatible (const char *n
 	 use default_arch.  */
       arch = cpu_arch_name;
       if (!arch)
-	arch = default_arch;
+	arch = (get_default_arch () == ARCH_x86_64) ? "x86_64" : "i386";
     }
 
   /* If we are targeting Intel L1OM, we must enable it.  */
@@ -2122,11 +2138,40 @@ i386_arch (void)
     return bfd_arch_i386;
 }
 
+static enum x86_arch
+get_default_arch ()
+{
+  const char *default_arch_str = DEFAULT_ARCH;
+
+  if (g_default_arch != ARCH_default)
+    return g_default_arch;
+
+#ifdef is_linux32
+  if (is_linux32 ())
+    default_arch_str = "i386";
+#endif
+
+  if (!strcmp (default_arch_str, "x86_64"))
+    g_default_arch = ARCH_x86_64;
+  else if (!strcmp (default_arch_str, "i386"))
+    g_default_arch = ARCH_i386;
+
+  return g_default_arch;
+}
+
+static INLINE void
+set_default_arch (arch)
+     enum x86_arch arch;
+{
+  g_default_arch = arch;
+}
+
 unsigned long
 i386_mach ()
 {
-  if (!strcmp (default_arch, "x86_64"))
+  switch (get_default_arch ())
     {
+    case ARCH_x86_64:
       if (cpu_arch_isa == PROCESSOR_L1OM)
 	{
 	  if (OUTPUT_FLAVOR != bfd_target_elf_flavour)
@@ -2135,11 +2180,11 @@ i386_mach ()
 	}
       else
 	return bfd_mach_x86_64;
+    case ARCH_i386:
+      return bfd_mach_i386_i386;
+    default:
+      as_fatal (_("Unknown architecture"));
     }
-  else if (!strcmp (default_arch, "i386"))
-    return bfd_mach_i386_i386;
-  else
-    as_fatal (_("Unknown architecture"));
 }
 
 void
@@ -3281,7 +3326,7 @@ check_suffix:
     {
       as_bad (_("`%s' is not supported on `%s%s'"),
 	      current_templates->start->name,
-	      cpu_arch_name ? cpu_arch_name : default_arch,
+	      cpu_arch_name ? cpu_arch_name : ((get_default_arch () == ARCH_x86_64) ? "x86_64" : "i386"),
 	      cpu_sub_arch_name ? cpu_sub_arch_name : "");
       return NULL;
     }
@@ -7921,7 +7966,7 @@ md_parse_option (int c, char *arg)
 	      || strcmp (*l, "pe-x86-64") == 0
 	      || strcmp (*l, "pei-x86-64") == 0)
 	    {
-	      default_arch = "x86_64";
+	      set_default_arch (ARCH_x86_64);
 	      break;
 	    }
 	if (*l == NULL)
@@ -7932,7 +7977,7 @@ md_parse_option (int c, char *arg)
 #endif
 
     case OPTION_32:
-      default_arch = "i386";
+      set_default_arch (ARCH_i386);
       break;
 
     case OPTION_DIVIDE:
@@ -8158,8 +8203,9 @@ md_show_usage (stream)
 const char *
 i386_target_format (void)
 {
-  if (!strcmp (default_arch, "x86_64"))
+  switch (get_default_arch ())
     {
+    case ARCH_x86_64:
       set_code_flag (CODE_64BIT);
       if (cpu_flags_all_zero (&cpu_arch_isa_flags))
 	{
@@ -8188,9 +8234,8 @@ i386_target_format (void)
 	  cpu_arch_tune_flags.bitfield.cpusse = 1;
 	  cpu_arch_tune_flags.bitfield.cpusse2 = 1;
 	}
-    }
-  else if (!strcmp (default_arch, "i386"))
-    {
+      break;
+    case ARCH_i386:
       set_code_flag (CODE_32BIT);
       if (cpu_flags_all_zero (&cpu_arch_isa_flags))
 	{
@@ -8204,9 +8249,11 @@ i386_target_format (void)
 	  cpu_arch_tune_flags.bitfield.cpui286 = 1;
 	  cpu_arch_tune_flags.bitfield.cpui386 = 1;
 	}
+      break;
+    default:
+      as_fatal (_("Unknown architecture"));
+      break;
     }
-  else
-    as_fatal (_("Unknown architecture"));
   switch (OUTPUT_FLAVOR)
     {
 #if defined (OBJ_MAYBE_AOUT) || defined (OBJ_AOUT)
diff -p -up binutils-2.20.51/gas/config/tc-ppc.c.linux32~ binutils-2.20.51/gas/config/tc-ppc.c
--- binutils-2.20.51/gas/config/tc-ppc.c.linux32~	2009-11-18 07:42:52.000000000 -0500
+++ binutils-2.20.51/gas/config/tc-ppc.c	2009-11-25 05:41:34.403053860 -0500
@@ -35,6 +35,10 @@
 #include "coff/pe.h"
 #endif
 
+#if defined(__linux__) && defined(__powerpc64__)
+#include <sys/utsname.h>
+#endif
+
 /* This is the assembler for the PowerPC or POWER (RS/6000) chips.  */
 
 /* Tell the main code what the endianness is.  */
@@ -87,6 +91,8 @@ static bfd_boolean reg_names_p = TARGET_
 static void ppc_macro (char *, const struct powerpc_macro *);
 static void ppc_byte (int);
 
+static void ppc_set_obj64 PARAMS ((int));
+
 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
 static void ppc_tc (int);
 static void ppc_machine (int);
@@ -900,7 +906,7 @@ ppc_parse_name (const char *name, expres
 /* Local variables.  */
 
 /* Whether to target xcoff64/elf64.  */
-static unsigned int ppc_obj64 = BFD_DEFAULT_TARGET_SIZE == 64;
+static int g_ppc_obj64 = -1;
 
 /* Opcode hash table.  */
 static struct hash_control *ppc_hash;
@@ -1070,13 +1076,13 @@ md_parse_option (int c, char *arg)
       if (strcmp (arg, "64") == 0)
 	{
 #ifdef BFD64
-	  ppc_obj64 = 1;
+	  ppc_set_obj64 (1);
 #else
 	  as_fatal (_("%s unsupported"), "-a64");
 #endif
 	}
       else if (strcmp (arg, "32") == 0)
-	ppc_obj64 = 0;
+	ppc_set_obj64 (0);
       else
 	return 0;
       break;
@@ -1229,6 +1235,37 @@ PowerPC options:\n\
 #endif
 }
 
+/* Set ppc_obj64 if it is not already set.  */
+
+#define ppc_obj64 (ppc_get_obj64 ())
+
+static unsigned int
+ppc_get_obj64 (void)
+{
+  if (g_ppc_obj64 < 0)
+    {
+      g_ppc_obj64 = BFD_DEFAULT_TARGET_SIZE == 64;
+
+#if defined(__linux__) && defined(__powerpc64__)
+      /* Determine if we are running under a 32-bit personality. Don't
+	 use plain personality(0xffffffff) syscall because the kernel lies.  */
+      {
+	struct utsname buf;
+	if (uname(&buf) == 0 && strcmp(buf.machine, "ppc") == 0)
+	  g_ppc_obj64 = 0;
+      }
+#endif
+    }
+
+  return g_ppc_obj64;
+}
+
+static void
+ppc_set_obj64 (int obj64)
+{
+  g_ppc_obj64 = obj64;
+}
+
 /* Set ppc_cpu if it is not already set.  */
 
 static void