aboutsummaryrefslogtreecommitdiff
path: root/bfd/aoutx.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-06-08 09:49:09 +0930
committerAlan Modra <amodra@gmail.com>2022-06-08 21:33:00 +0930
commit57698478b75319a962b899c3f8d3a03baa5eaab4 (patch)
treeb8c1b2c7f1dcb060a535ac8a21745bdf55698a40 /bfd/aoutx.h
parent5d2834cc7e943014cff0cef6a2a25972eb85d84a (diff)
downloadbinutils-57698478b75319a962b899c3f8d3a03baa5eaab4.zip
binutils-57698478b75319a962b899c3f8d3a03baa5eaab4.tar.gz
binutils-57698478b75319a962b899c3f8d3a03baa5eaab4.tar.bz2
Don't encode reloc.size
I expect the encoded reloc.size field originally came from aout r_length ecoding, but somehow went wrong for 64-bit relocs (which should have been encoded as 3). Toss all that out, just use a byte size instead. The changes outside of reloc.c in this patch should make the code independent of how reloc.size is encoded. * reloc.c (struct reloc_howto_struct): Increase size field by one bit. Comment. (HOWTO_RSIZE): Don't encode size. (bfd_get_reloc_size): Adjust, and make it an inline function. (read_reloc, write_reloc): Adjust. * bfd-in2.h: Regenerate. * aout-ns32k.c: Include libbfd.h. (put_reloc): Don't use howto->size directly. Calculate r_length using bfd_log2 and bfd_get_reloc_size. * aoutx.h (swap_std_reloc_out): Likewise. (aout_link_reloc_link_order): Likewise. * i386lynx.c (swap_std_reloc_out * mach-o-i386.c (bfd_mach_o_i386_swap_reloc_out * pdp11.c (aout_link_reloc_link_order * coff-arm.c (coff_arm_reloc): Don't use howto->size directly, use bfd_get_reloc_size instead and adjust switch cases. * coff-i386.c (coff_i386_reloc): Similarly. * coff-x86_64.c (coff_amd64_reloc): Likewise. * cpu-ns32k.c (do_ns32k_reloc): Likewise. * elf32-arc.c (arc_do_relocation): Likewise. * elf32-arm.c (elf32_arm_final_link_relocate): Likewise. * elf32-bfin.c (bfin_bfd_reloc): Likewise. * elf32-cr16.c (cr16_elf_final_link_relocate): Likewise. * elf32-cris.c (cris_elf_pcrel_reloc): Likewise. * elf32-crx.c (crx_elf_final_link_relocate): Likewise. * elf32-csky.c (csky_elf_relocate_section): Likewise. * elf32-d10v.c (extract_rel_addend, insert_rel_addend): Likewise. * elf32-i386.c (elf_i386_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_generic_reloc): Likewise. * elf32-nds32.c (nds32_elf_generic_reloc): Likewise. * syms.c (_bfd_stab_section_find_nearest_line): Likewise. * coff-rs6000.c (xcoff_ppc_relocate_section): Adjust howto.size. * coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
Diffstat (limited to 'bfd/aoutx.h')
-rw-r--r--bfd/aoutx.h22
1 files changed, 6 insertions, 16 deletions
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 2bff7a8..e9b5188 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1947,7 +1947,7 @@ NAME (aout, swap_std_reloc_out) (bfd *abfd,
int r_index;
asymbol *sym = *(g->sym_ptr_ptr);
int r_extern;
- unsigned int r_length;
+ unsigned int r_length, r_size;
int r_pcrel;
int r_baserel, r_jmptable, r_relative;
asection *output_section = sym->section->output_section;
@@ -1956,21 +1956,14 @@ NAME (aout, swap_std_reloc_out) (bfd *abfd,
BFD_ASSERT (g->howto != NULL);
- switch (bfd_get_reloc_size (g->howto))
+ r_size = bfd_get_reloc_size (g->howto);
+ r_length = bfd_log2 (r_size);
+ if (1u << r_length != r_size)
{
- default:
_bfd_error_handler (_("%pB: unsupported AOUT relocation size: %d"),
- abfd, bfd_get_reloc_size (g->howto));
+ abfd, r_size);
bfd_set_error (bfd_error_bad_value);
return;
- case 1:
- case 2:
- case 4:
- r_length = g->howto->size; /* Size as a power of two. */
- break;
- case 8:
- r_length = 3;
- break;
}
r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
@@ -3835,10 +3828,7 @@ aout_link_reloc_link_order (struct aout_final_link_info *flaginfo,
r_baserel = (howto->type & 8) != 0;
r_jmptable = (howto->type & 16) != 0;
r_relative = (howto->type & 32) != 0;
- if (bfd_get_reloc_size (howto) != 8)
- r_length = howto->size; /* Size as a power of two. */
- else
- r_length = 3;
+ r_length = bfd_log2 (bfd_get_reloc_size (howto));
PUT_WORD (flaginfo->output_bfd, p->offset, srel.r_address);
if (bfd_header_big_endian (flaginfo->output_bfd))