OSDN Git Service

* lto-elf.c (ELFOSABI_NONE, ELFOSABI_LINUX): Define if not defined.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Jul 2010 21:16:28 +0000 (21:16 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Jul 2010 21:16:28 +0000 (21:16 +0000)
(validate_file): Allow merging of ELFOSABI_NONE with ELFOSABI_LINUX
objects.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161935 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/lto/ChangeLog
gcc/lto/lto-elf.c

index a1a03b6..40886c4 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-07  Jakub Jelinek  <jakub@redhat.com>
+
+       * lto-elf.c (ELFOSABI_NONE, ELFOSABI_LINUX): Define if not defined.
+       (validate_file): Allow merging of ELFOSABI_NONE with ELFOSABI_LINUX
+       objects.
+
 2010-07-05  Jan Hubicka  <jh@suse.cz>
 
        * lto.c (add_cgraph_node_to_partition): Forward declare; walk also
index bb4df80..55a3db2 100644 (file)
@@ -38,6 +38,13 @@ along with GCC; see the file COPYING3.  If not see
 # define EM_SPARC32PLUS 18
 #endif
 
+#ifndef ELFOSABI_NONE
+# define ELFOSABI_NONE 0
+#endif
+#ifndef ELFOSABI_LINUX
+# define ELFOSABI_LINUX 3
+#endif
+
 
 /* Handle opening elf files on hosts, such as Windows, that may use 
    text file handling that will break binary access.  */
@@ -519,10 +526,28 @@ validate_file (lto_elf_file *elf_file)
       memcpy (cached_file_attrs.elf_ident, elf_ident,
              sizeof cached_file_attrs.elf_ident);
     }
+  else
+    {
+      char elf_ident_buf[EI_NIDENT];
+
+      memcpy (elf_ident_buf, elf_ident, sizeof elf_ident_buf);
 
-  if (memcmp (elf_ident, cached_file_attrs.elf_ident,
-             sizeof cached_file_attrs.elf_ident))
-    return false;
+      if (elf_ident_buf[EI_OSABI] != cached_file_attrs.elf_ident[EI_OSABI])
+       {
+         /* Allow mixing ELFOSABI_NONE with ELFOSABI_LINUX, with the result
+            ELFOSABI_LINUX.  */
+         if (elf_ident_buf[EI_OSABI] == ELFOSABI_NONE
+             && cached_file_attrs.elf_ident[EI_OSABI] == ELFOSABI_LINUX)
+           elf_ident_buf[EI_OSABI] = cached_file_attrs.elf_ident[EI_OSABI];
+         else if (elf_ident_buf[EI_OSABI] == ELFOSABI_LINUX
+                  && cached_file_attrs.elf_ident[EI_OSABI] == ELFOSABI_NONE)
+           cached_file_attrs.elf_ident[EI_OSABI] = elf_ident_buf[EI_OSABI];
+       }
+
+      if (memcmp (elf_ident_buf, cached_file_attrs.elf_ident,
+                 sizeof cached_file_attrs.elf_ident))
+       return false;
+    }
 
   /* Check that the input file is a relocatable object file with the correct
      architecture.  */