X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=bfd%2Felf32-s12z.c;h=5a7f15194d03951c8a5e9330f50409794ae03dda;hb=5f3fc928df037b21ee401d7115951b988a3ea571;hp=05e515326392eccb029e69bd2261444ebebc171f;hpb=2849d19feb458ade67cdcc6a82f0e7b1be99b46b;p=binutils-gdb.git diff --git a/bfd/elf32-s12z.c b/bfd/elf32-s12z.c index 05e51532639..5a7f15194d0 100644 --- a/bfd/elf32-s12z.c +++ b/bfd/elf32-s12z.c @@ -1,5 +1,5 @@ /* Freescale S12Z-specific support for 32-bit ELF - Copyright (C) 1999-2018 Free Software Foundation, Inc. + Copyright (C) 1999-2022 Free Software Foundation, Inc. (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com)) This file is part of BFD, the Binary File Descriptor library. @@ -27,10 +27,13 @@ #include "elf/s12z.h" +/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */ +#define OCTETS_PER_BYTE(ABFD, SEC) 1 + /* Relocation functions. */ static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -static bfd_boolean s12z_info_to_howto_rel +static bool s12z_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *); static bfd_reloc_status_type @@ -43,7 +46,8 @@ opru18_reloc (bfd *abfd, arelent *reloc_entry, struct bfd_symbol *symbol, is shifted one place to the left of where it would normally be. See Appendix A.4 of the S12Z reference manual. */ - bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); + bfd_size_type octets = (reloc_entry->address + * OCTETS_PER_BYTE (abfd, input_section)); bfd_vma result = bfd_get_24 (abfd, (unsigned char *) data + octets); bfd_vma val = bfd_asymbol_value (symbol); @@ -98,90 +102,90 @@ static reloc_howto_type elf_s12z_howto_table[] = 0, /* rightshift */ 3, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_S12Z_NONE", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* A 24 bit absolute relocation emitted by the OPR mode operands */ HOWTO (R_S12Z_OPR, /* type */ 0, /* rightshift */ 5, /* size (0 = byte, 1 = short, 2 = long) */ 24, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ shift_addend_reloc, "R_S12Z_OPR", /* name */ - FALSE, /* partial_inplace */ - 0x00000000, /* src_mask */ + false, /* partial_inplace */ + 0x00ffffff, /* src_mask */ 0x00ffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* The purpose of this reloc is not known */ HOWTO (R_S12Z_UKNWN_2, /* type */ 0, /* rightshift */ 3, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_S12Z_UKNWN_2", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* A 15 bit PC-rel relocation */ HOWTO (R_S12Z_PCREL_7_15, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 15, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ shift_addend_reloc, "R_S12Z_PCREL_7_15", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x00, /* src_mask */ 0x007fff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* A 24 bit absolute relocation emitted by EXT24 mode operands */ HOWTO (R_S12Z_EXT24, /* type */ 0, /* rightshift */ 5, /* size (0 = byte, 1 = short, 2 = long) */ 24, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_S12Z_EXT24", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x00000000, /* src_mask */ 0x00ffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* An 18 bit absolute relocation */ HOWTO (R_S12Z_EXT18, /* type */ 0, /* rightshift */ 5, /* size (0 = byte, 1 = short, 2 = long) */ 18, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ opru18_reloc, /* special_function */ "R_S12Z_EXT18", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x00000000, /* src_mask */ 0x0005ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* A 32 bit absolute relocation. This kind of relocation is schizophrenic - Although they appear in sections named .rela.debug.* @@ -196,30 +200,30 @@ static reloc_howto_type elf_s12z_howto_table[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_S12Z_CW32", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* A 32 bit absolute relocation */ HOWTO (R_S12Z_EXT32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_S12Z_EXT32", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x00000000, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ }; /* Map BFD reloc types to S12Z ELF reloc types. */ @@ -232,11 +236,12 @@ struct s12z_reloc_map static const struct s12z_reloc_map s12z_reloc_map[] = { - /* bfd reloc val */ /* elf reloc val */ - {BFD_RELOC_NONE, R_S12Z_NONE}, - {BFD_RELOC_32, R_S12Z_EXT32}, - {BFD_RELOC_24, R_S12Z_EXT24}, - {BFD_RELOC_16_PCREL, R_S12Z_PCREL_7_15} + /* bfd reloc val */ /* elf reloc val */ + {BFD_RELOC_NONE, R_S12Z_NONE}, + {BFD_RELOC_32, R_S12Z_EXT32}, + {BFD_RELOC_24, R_S12Z_EXT24}, + {BFD_RELOC_16_PCREL, R_S12Z_PCREL_7_15}, + {BFD_RELOC_S12Z_OPR, R_S12Z_OPR} }; static reloc_howto_type * @@ -279,7 +284,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an S12Z ELF reloc. */ -static bfd_boolean +static bool s12z_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -291,19 +296,19 @@ s12z_info_to_howto_rel (bfd *abfd, _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - return FALSE; + return false; } cache_ptr->howto = &elf_s12z_howto_table[r_type]; - return TRUE; + return true; } -static bfd_boolean +static bool s12z_elf_set_mach_from_flags (bfd *abfd) { bfd_default_set_arch_mach (abfd, bfd_arch_s12z, 0); - return TRUE; + return true; } #define ELF_ARCH bfd_arch_s12z @@ -316,7 +321,5 @@ s12z_elf_set_mach_from_flags (bfd *abfd) #define elf_info_to_howto NULL #define elf_info_to_howto_rel s12z_info_to_howto_rel #define elf_backend_object_p s12z_elf_set_mach_from_flags -#define elf_backend_final_write_processing NULL -#define elf_backend_can_gc_sections 1 #include "elf32-target.h"