[PATCH][GOLD] Make gold buildable on OSX

Doug Kwan (關振德) dougkwan@google.com
Tue Jun 23 01:37:00 GMT 2009


This patch makes gold buildable on OSX for cross-compilation.  This
has been tested by building and running the testsuite for the
following host/target combinations:

host                                                  target
-----------------------------------------------------------------------------------
x86_64-unknown-linux-gnu             arm-none-eabi
x86_64-unknown-linux-gnu             x86_64-unknown-linux-gnu
i386-apple-darwin9.7.0                   arm-none-eabi

-Doug

2009-06-22  Doug Kwan  <dougkwan@google.com>

        * Makefile.am (libgold_a_LIBADD): New.
        (ld_new_DEPENDENCIES, ld_new_LDADD): Remove LIBOBJS
        * Makefile.in: Regenerate.
        * config.in (HAVE_DECL_MEMMEM, HAVE_DECL_STRNDUP): New.
        * configure: Regenerate.
        * configure.ac (AC_CHECK_DECLS): Add strndup and memmem.
        * fileread.cc: Include sys/state.h
        * gold.h: Declare memmem and strndup if found missing.
        * gold_reloc.h: Include byteswap.h if HAVE_BYTESWAP_H is defined.
-------------- next part --------------
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.196
diff -u -u -p -r1.196 elf32-arm.c
--- bfd/elf32-arm.c	22 May 2009 11:58:44 -0000	1.196
+++ bfd/elf32-arm.c	12 Jun 2009 00:30:17 -0000
@@ -3981,7 +3981,7 @@ cortex_a8_erratum_scan (bfd *input_bfd, 
               if (((base_vma + i) & 0xfff) == 0xffe && insn_32bit
 		  && is_32bit_branch && last_was_32bit && !last_was_branch)
                 {
-                  bfd_vma offset;
+                  bfd_signed_vma offset;
                   bfd_boolean force_target_arm = FALSE;
 		  bfd_boolean force_target_thumb = FALSE;
                   bfd_vma target;
@@ -4030,7 +4030,7 @@ cortex_a8_erratum_scan (bfd *input_bfd, 
                       offset |= (insn & 0x800) ? 0x80000 : 0;
                       offset |= (insn & 0x4000000) ? 0x100000 : 0;
                       if (offset & 0x100000)
-                        offset |= ~0xfffff;
+                        offset |= ~((bfd_signed_vma) 0xfffff);
                       stub_type = arm_stub_a8_veneer_b_cond;
                     }
                   else if (is_b || is_bl || is_blx)
@@ -4047,10 +4047,10 @@ cortex_a8_erratum_scan (bfd *input_bfd, 
                       offset |= i1 << 23;
                       offset |= s << 24;
                       if (offset & 0x1000000)
-                        offset |= ~0xffffff;
+                        offset |= ~((bfd_signed_vma) 0xffffff);
 
                       if (is_blx)
-                        offset &= ~3u;
+                        offset &= ~((bfd_signed_vma) 3);
 
                       stub_type = is_blx ? arm_stub_a8_veneer_blx :
                         is_bl ? arm_stub_a8_veneer_bl : arm_stub_a8_veneer_b;
@@ -4083,14 +4083,15 @@ cortex_a8_erratum_scan (bfd *input_bfd, 
 			}
 
                       if (is_blx)
-                        pc_for_insn &= ~3u;
+                        pc_for_insn &= ~((bfd_vma) 3);
 
                       /* If we found a relocation, use the proper destination,
 		         not the offset in the (unrelocated) instruction.
 			 Note this is always done if we switched the stub type
 			 above.  */
                       if (found)
-                        offset = found->destination - pc_for_insn;
+                        offset =
+			  (bfd_signed_vma)(found->destination - pc_for_insn);
 
                       target = pc_for_insn + offset;
 


More information about the Binutils mailing list