diff options
author | Tristan Gingold <gingold@adacore.com> | 2015-11-18 15:43:27 +0100 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2015-11-18 15:47:56 +0100 |
commit | bcb51645d3ef1211efbce59f0935f5f0223602a3 (patch) | |
tree | b13d0345ad27ab30bd8ce54f80b0129cddd1716e /bfd/mach-o-x86-64.c | |
parent | 1798301e20d5c5be69a362bbec149abce446c215 (diff) | |
download | gdb-bcb51645d3ef1211efbce59f0935f5f0223602a3.zip gdb-bcb51645d3ef1211efbce59f0935f5f0223602a3.tar.gz gdb-bcb51645d3ef1211efbce59f0935f5f0223602a3.tar.bz2 |
mach-o: use a per-target reloc canonicalize function.
bfd/
* mach-o.h (bfd_mach_o_swap_in_non_scattered_reloc)
(bfd_mach_o_canonicalize_non_scattered_reloc)
(bfd_mach_o_pre_canonicalize_one_reloc): Declare.
(bfd_mach_o_backend_data): Rename field
_bfd_mach_o_swap_reloc_in to _bfd_mach_o_canonicalize_one_reloc.
* mach-o.c (bfd_mach_o_swap_in_non_scattered_reloc): Now public.
(bfd_mach_o_canonicalize_non_scattered_reloc): Renames from
bfd_mach_o_canonicalize_one_reloc.
(bfd_mach_o_pre_canonicalize_one_reloc): New function.
(bfd_mach_o_canonicalize_relocs): Adjust.
(bfd_mach_o_canonicalize_relocs): Rename define from
bfd_mach_o_swap_reloc_in.
* mach-o-target.c (TARGET_NAME_BACKEND): Use
bfd_mach_o_canonicalize_one_reloc instead of
bfd_mach_o_swap_reloc_in.
* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc): Renames
from bfd_mach_o_i386_swap_reloc_in and adjust.
(bfd_mach_o_canonicalize_one_reloc): Renames from
bfd_mach_o_i386_canonicalize_one_reloc.
* mach-o-x86_64.c (bfd_mach_o_x86_64_canonicalize_one_reloc): Renames
from bfd_mach_o_x86_64_swap_reloc_in and adjust.
(bfd_mach_o_canonicalize_one_reloc): Renames from
bfd_mach_o_x86_64_canonicalize_one_reloc.
Diffstat (limited to 'bfd/mach-o-x86-64.c')
-rw-r--r-- | bfd/mach-o-x86-64.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/bfd/mach-o-x86-64.c b/bfd/mach-o-x86-64.c index b0eef2c..5914ae8 100644 --- a/bfd/mach-o-x86-64.c +++ b/bfd/mach-o-x86-64.c @@ -120,18 +120,25 @@ static reloc_howto_type x86_64_howto_table[]= }; static bfd_boolean -bfd_mach_o_x86_64_swap_reloc_in (arelent *res, bfd_mach_o_reloc_info *reloc) +bfd_mach_o_x86_64_canonicalize_one_reloc (bfd *abfd, + struct mach_o_reloc_info_external *raw, + arelent *res, asymbol **syms) { + bfd_mach_o_reloc_info reloc; + + if (!bfd_mach_o_pre_canonicalize_one_reloc (abfd, raw, &reloc, res, syms)) + return FALSE; + /* On x86-64, scattered relocs are not used. */ - if (reloc->r_scattered) + if (reloc.r_scattered) return FALSE; - switch (reloc->r_type) + switch (reloc.r_type) { case BFD_MACH_O_X86_64_RELOC_UNSIGNED: - if (reloc->r_pcrel) + if (reloc.r_pcrel) return FALSE; - switch (reloc->r_length) + switch (reloc.r_length) { case 2: res->howto = &x86_64_howto_table[1]; @@ -143,16 +150,16 @@ bfd_mach_o_x86_64_swap_reloc_in (arelent *res, bfd_mach_o_reloc_info *reloc) return FALSE; } case BFD_MACH_O_X86_64_RELOC_SIGNED: - if (reloc->r_length == 2 && reloc->r_pcrel) + if (reloc.r_length == 2 && reloc.r_pcrel) { res->howto = &x86_64_howto_table[2]; return TRUE; } break; case BFD_MACH_O_X86_64_RELOC_BRANCH: - if (!reloc->r_pcrel) + if (!reloc.r_pcrel) return FALSE; - switch (reloc->r_length) + switch (reloc.r_length) { case 2: res->howto = &x86_64_howto_table[6]; @@ -162,23 +169,23 @@ bfd_mach_o_x86_64_swap_reloc_in (arelent *res, bfd_mach_o_reloc_info *reloc) } break; case BFD_MACH_O_X86_64_RELOC_GOT_LOAD: - if (reloc->r_length == 2 && reloc->r_pcrel && reloc->r_extern) + if (reloc.r_length == 2 && reloc.r_pcrel && reloc.r_extern) { res->howto = &x86_64_howto_table[7]; return TRUE; } break; case BFD_MACH_O_X86_64_RELOC_GOT: - if (reloc->r_length == 2 && reloc->r_pcrel && reloc->r_extern) + if (reloc.r_length == 2 && reloc.r_pcrel && reloc.r_extern) { res->howto = &x86_64_howto_table[10]; return TRUE; } break; case BFD_MACH_O_X86_64_RELOC_SUBTRACTOR: - if (reloc->r_pcrel) + if (reloc.r_pcrel) return FALSE; - switch (reloc->r_length) + switch (reloc.r_length) { case 2: res->howto = &x86_64_howto_table[8]; @@ -191,21 +198,21 @@ bfd_mach_o_x86_64_swap_reloc_in (arelent *res, bfd_mach_o_reloc_info *reloc) } break; case BFD_MACH_O_X86_64_RELOC_SIGNED_1: - if (reloc->r_length == 2 && reloc->r_pcrel) + if (reloc.r_length == 2 && reloc.r_pcrel) { res->howto = &x86_64_howto_table[3]; return TRUE; } break; case BFD_MACH_O_X86_64_RELOC_SIGNED_2: - if (reloc->r_length == 2 && reloc->r_pcrel) + if (reloc.r_length == 2 && reloc.r_pcrel) { res->howto = &x86_64_howto_table[4]; return TRUE; } break; case BFD_MACH_O_X86_64_RELOC_SIGNED_4: - if (reloc->r_length == 2 && reloc->r_pcrel) + if (reloc.r_length == 2 && reloc.r_pcrel) { res->howto = &x86_64_howto_table[5]; return TRUE; @@ -344,7 +351,7 @@ const mach_o_segment_name_xlat mach_o_x86_64_segsec_names_xlat[] = { NULL, NULL } }; -#define bfd_mach_o_swap_reloc_in bfd_mach_o_x86_64_swap_reloc_in +#define bfd_mach_o_canonicalize_one_reloc bfd_mach_o_x86_64_canonicalize_one_reloc #define bfd_mach_o_swap_reloc_out bfd_mach_o_x86_64_swap_reloc_out #define bfd_mach_o_bfd_reloc_type_lookup bfd_mach_o_x86_64_bfd_reloc_type_lookup |