[ Patch mach-o/gas] adjust more x86_64 relocs for GOT case.

Iain Sandoe developer@sandoe-acoustics.co.uk
Fri Jan 6 12:38:00 GMT 2012


this allows me a step closer to building libgcc...

OK, or a different solution in mind?
Iain

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 4b57d6d..97bab20 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -9039,17 +9039,26 @@ i386_validate_fix (fixS *fixp)
  {
    if (fixp->fx_subsy && fixp->fx_subsy == GOT_symbol)
      {
-      if (fixp->fx_r_type == BFD_RELOC_32_PCREL)
+#ifdef OBJ_MACH_O
+      if (fixp->fx_r_type == BFD_RELOC_32_PCREL
+	  || fixp->fx_r_type == BFD_RELOC_MACH_O_X86_64_PCREL32_1
+	  || fixp->fx_r_type == BFD_RELOC_MACH_O_X86_64_PCREL32_2
+	  || fixp->fx_r_type == BFD_RELOC_MACH_O_X86_64_PCREL32_4)
  	{
  	  if (!object_64bit)
  	    abort ();
-#ifdef OBJ_MACH_O
+	  /* If the instruction is a mov regmem -> reg and operands can be  
words
+	     or dwords, we do a got load.  */
            if (fixp->fx_where > 1
                && fixp->fx_frag->fr_literal[fixp->fx_where - 2] ==  
(char)0x8b)
              fixp->fx_r_type = BFD_RELOC_MACH_O_X86_64_GOT_LOAD;
            else
              fixp->fx_r_type = BFD_RELOC_MACH_O_X86_64_GOT;
  #else
+      if (fixp->fx_r_type == BFD_RELOC_32_PCREL)
+	{
+	  if (!object_64bit)
+	    abort ();
  	  fixp->fx_r_type = BFD_RELOC_X86_64_GOTPCREL;
  #endif
  	}



More information about the Binutils mailing list