more on ARM ELF flag merging

Philip Blundell philb@gnu.org
Sun Nov 5 07:34:00 GMT 2000


At the risk of appearing to be an man obsessed with this topic, it turns out 
things are still not quite right.  Consider this situation, which turns up in 
the Linux kernel:

$ as -mapcs-26 -o a.o a.s
$ ar cq b.a
$ ld -r b.o b.a
$ ld a.o b.o

This link is rejected because the flags don't match on a.o and b.o.  But in 
fact b.o doesn't contain any code, so it won't do any harm to include it in 
the output regardless of what the flags might say ... and here's a patch to 
implement just this.

p.

2000-11-05  Philip Blundell  <philb@gnu.org>

	* elf32-arm.h (elf32_arm_merge_private_bfd_data): Always permit
	BFDs containing no sections to be merged, regardless of their flags.

Index: elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.25.2.5
diff -u -p -u -r1.25.2.5 elf32-arm.h
--- elf32-arm.h	2000/10/31 22:56:17	1.25.2.5
+++ elf32-arm.h	2000/11/05 15:31:28
@@ -1974,6 +1979,8 @@ elf32_arm_merge_private_bfd_data (ibfd, 
   flagword out_flags;
   flagword in_flags;
   boolean flags_compatible = true;
+  boolean null_input_bfd = true;
+  asection *sec;
 
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -2027,6 +2034,22 @@ elf32_arm_merge_private_bfd_data (ibfd, 
 
   /* Identical flags must be compatible.  */
   if (in_flags == out_flags)
+    return true;
+
+  /* Check to see if the input BFD actually contains any sections.
+     If not, its flags may not have been initialised either, but it cannot
+     actually cause any incompatibility.  */
+  for (sec = ibfd->sections; sec != NULL; sec = sec->next)
+    {
+      /* Ignore synthetic glue sections.  */
+      if (strcmp (sec->name, ".glue_7")
+	  && strcmp (sec->name, ".glue_7t"))
+	{
+	  null_input_bfd = false;
+	  break;
+	}
+    }
+  if (null_input_bfd)
     return true;
 
   /* If any of the input BFDs is non-PIC, the output is also position 




More information about the Binutils mailing list