aboutsummaryrefslogtreecommitdiff
path: root/bfd/mach-o-x86-64.c
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2011-08-08 07:47:41 +0000
committerTristan Gingold <gingold@adacore.com>2011-08-08 07:47:41 +0000
commitfde3380891f9bd7fd64cc2226bd5541b9e4a530e (patch)
tree827a930a2e6a771ea8766d8d4f22978d422b996c /bfd/mach-o-x86-64.c
parent53d58d96a751e0ff3c3bc4323f676bed1d521e0f (diff)
downloadgdb-fde3380891f9bd7fd64cc2226bd5541b9e4a530e.zip
gdb-fde3380891f9bd7fd64cc2226bd5541b9e4a530e.tar.gz
gdb-fde3380891f9bd7fd64cc2226bd5541b9e4a530e.tar.bz2
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.
Diffstat (limited to 'bfd/mach-o-x86-64.c')
-rw-r--r--bfd/mach-o-x86-64.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/bfd/mach-o-x86-64.c b/bfd/mach-o-x86-64.c
index 005315d..561496b 100644
--- a/bfd/mach-o-x86-64.c
+++ b/bfd/mach-o-x86-64.c
@@ -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;
}