2011-08-08 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Mon, 8 Aug 2011 07:47:41 +0000 (07:47 +0000)
committerTristan Gingold <gingold@adacore.com>
Mon, 8 Aug 2011 07:47:41 +0000 (07:47 +0000)
* mach-o-x86-64.c (bfd_mach_o_x86_64_mkobject): Fix cut-and-past typos.
(bfd_mach_o_x86_64_swap_reloc_out): Handle BFD_RELOC_32_PCREL,
BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64 and
BFD_RELOC_MACH_O_X86_64_GOT_LOAD.  Share common code.

bfd/ChangeLog
bfd/mach-o-x86-64.c

index db8e2939ea6a41ced3dc88de8baac123688a06ac..99f221b011cfa67da3b021ef319f0ad0d97fb41c 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-08  Tristan Gingold  <gingold@adacore.com>
+
+       * mach-o-x86-64.c (bfd_mach_o_x86_64_mkobject): Fix cut-and-past typos.
+       (bfd_mach_o_x86_64_swap_reloc_out): Handle BFD_RELOC_32_PCREL,
+       BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64 and
+       BFD_RELOC_MACH_O_X86_64_GOT_LOAD.  Share common code.
+
 2011-08-08  Tristan Gingold  <gingold@adacore.com>
 
        * mach-o.c (bfd_mach_o_normalize_section_name): New function.
index 005315dea977d943e5f616dad7bea64ebfbafd81..561496bdc83ec2719f5a9942f47121c5d4ab2016 100644 (file)
@@ -51,11 +51,11 @@ bfd_mach_o_x86_64_mkobject (bfd *abfd)
     return FALSE;
 
   mdata = bfd_mach_o_get_data (abfd);
-  mdata->header.magic = BFD_MACH_O_MH_MAGIC;
+  mdata->header.magic = BFD_MACH_O_MH_MAGIC_64;
   mdata->header.cputype = BFD_MACH_O_CPU_TYPE_X86_64;
   mdata->header.cpusubtype = BFD_MACH_O_CPU_SUBTYPE_X86_ALL;
   mdata->header.byteorder = BFD_ENDIAN_LITTLE;
-  mdata->header.version = 1;
+  mdata->header.version = 2;
 
   return TRUE;
 }
@@ -220,27 +220,42 @@ static bfd_boolean
 bfd_mach_o_x86_64_swap_reloc_out (arelent *rel, bfd_mach_o_reloc_info *rinfo)
 {
   rinfo->r_address = rel->address;
+  rinfo->r_scattered = 0;
   switch (rel->howto->type)
     {
     case BFD_RELOC_64:
-      rinfo->r_scattered = 0;
       rinfo->r_type = BFD_MACH_O_X86_64_RELOC_UNSIGNED;
       rinfo->r_pcrel = 0;
-      rinfo->r_length = rel->howto->size; /* Correct in practice.  */
-      if ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM)
-        {
-          rinfo->r_extern = 0;
-          rinfo->r_value = (*rel->sym_ptr_ptr)->section->target_index;
-        }
-      else
-        {
-          rinfo->r_extern = 1;
-          rinfo->r_value = (*rel->sym_ptr_ptr)->udata.i;
-        }
+      rinfo->r_length = 3;
+      break;
+    case BFD_RELOC_32_PCREL:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_BRANCH;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
+      break;
+    case BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SUBTRACTOR;
+      rinfo->r_pcrel = 0;
+      rinfo->r_length = 3;
+      break;
+    case BFD_RELOC_MACH_O_X86_64_GOT_LOAD:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_GOT_LOAD;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
       break;
     default:
       return FALSE;
     }
+  if ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM)
+    {
+      rinfo->r_extern = 0;
+      rinfo->r_value = (*rel->sym_ptr_ptr)->section->target_index;
+    }
+  else
+    {
+      rinfo->r_extern = 1;
+      rinfo->r_value = (*rel->sym_ptr_ptr)->udata.i;
+    }
   return TRUE;
 }