X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Freloc.c;h=c4dec86d1d4607a13ac668fa73f56aca629e997b;hb=efba5c2319d6c25393e5cce9a2d30bbc0cb53123;hp=ae71f6b0054c53e4594add9c799cc4034dfd9368;hpb=595d3787e9cbedbceb6182f873a4774707c0e74f;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/reloc.c b/bfd/reloc.c index ae71f6b005..c4dec86d1d 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -1,5 +1,5 @@ /* BFD support for handling relocation entries. - Copyright (C) 1990-2019 Free Software Foundation, Inc. + Copyright (C) 1990-2020 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -722,7 +722,7 @@ bfd_perform_relocation (bfd *abfd, return bfd_reloc_undefined; /* Is the address of the relocation really within the section? */ - octets = reloc_entry->address * bfd_octets_per_byte (abfd); + octets = reloc_entry->address * bfd_octets_per_byte (abfd, input_section); if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets)) return bfd_reloc_outofrange; @@ -744,7 +744,14 @@ bfd_perform_relocation (bfd *abfd, else output_base = reloc_target_output_section->vma; - relocation += output_base + symbol->section->output_offset; + output_base += symbol->section->output_offset; + + /* If symbol addresses are in octets, convert to bytes. */ + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (symbol->section->flags & SEC_ELF_OCTETS)) + output_base *= bfd_octets_per_byte (abfd, input_section); + + relocation += output_base; /* Add in supplied addend. */ relocation += reloc_entry->addend; @@ -1052,7 +1059,7 @@ bfd_install_relocation (bfd *abfd, it will have been checked in `bfd_perform_relocation already'. */ /* Is the address of the relocation really within the section? */ - octets = reloc_entry->address * bfd_octets_per_byte (abfd); + octets = reloc_entry->address * bfd_octets_per_byte (abfd, input_section); if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets)) return bfd_reloc_outofrange; @@ -1073,7 +1080,14 @@ bfd_install_relocation (bfd *abfd, else output_base = reloc_target_output_section->vma; - relocation += output_base + symbol->section->output_offset; + output_base += symbol->section->output_offset; + + /* If symbol addresses are in octets, convert to bytes. */ + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (symbol->section->flags & SEC_ELF_OCTETS)) + output_base *= bfd_octets_per_byte (abfd, input_section); + + relocation += output_base; /* Add in supplied addend. */ relocation += reloc_entry->addend; @@ -1337,7 +1351,8 @@ _bfd_final_link_relocate (reloc_howto_type *howto, bfd_vma addend) { bfd_vma relocation; - bfd_size_type octets = address * bfd_octets_per_byte (input_bfd); + bfd_size_type octets = (address + * bfd_octets_per_byte (input_bfd, input_section)); /* Sanity check the address. */ if (!bfd_reloc_offset_in_range (howto, input_bfd, input_section, octets)) @@ -1368,8 +1383,7 @@ _bfd_final_link_relocate (reloc_howto_type *howto, } return _bfd_relocate_contents (howto, input_bfd, relocation, - contents - + address * bfd_octets_per_byte (input_bfd)); + contents + octets); } /* Relocate a given location using a given value and howto. */ @@ -6659,6 +6673,34 @@ ENUM BFD_RELOC_Z80_DISP8 ENUMDOC 8 bit signed offset in (ix+d) or (iy+d). +ENUM + BFD_RELOC_Z80_BYTE0 +ENUMDOC + First 8 bits of multibyte (32, 24 or 16 bit) value. +ENUM + BFD_RELOC_Z80_BYTE1 +ENUMDOC + Second 8 bits of multibyte (32, 24 or 16 bit) value. +ENUM + BFD_RELOC_Z80_BYTE2 +ENUMDOC + Third 8 bits of multibyte (32 or 24 bit) value. +ENUM + BFD_RELOC_Z80_BYTE3 +ENUMDOC + Fourth 8 bits of multibyte (32 bit) value. +ENUM + BFD_RELOC_Z80_WORD0 +ENUMDOC + Lowest 16 bits of multibyte (32 or 24 bit) value. +ENUM + BFD_RELOC_Z80_WORD1 +ENUMDOC + Highest 16 bits of multibyte (32 or 24 bit) value. +ENUM + BFD_RELOC_Z80_16_BE +ENUMDOC + Like BFD_RELOC_16 but big-endian. ENUM BFD_RELOC_Z8K_DISP7 @@ -8123,28 +8165,11 @@ DESCRIPTION reloc_howto_type * bfd_default_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) { - switch (code) - { - case BFD_RELOC_CTOR: - /* The type of reloc used in a ctor, which will be as wide as the - address - so either a 64, 32, or 16 bitter. */ - switch (bfd_arch_bits_per_address (abfd)) - { - case 64: - BFD_FAIL (); - break; - case 32: - return &bfd_howto_32; - case 16: - BFD_FAIL (); - break; - default: - BFD_FAIL (); - } - break; - default: - BFD_FAIL (); - } + /* Very limited support is provided for relocs in generic targets + such as elf32-little. FIXME: Should we always return NULL? */ + if (code == BFD_RELOC_CTOR + && bfd_arch_bits_per_address (abfd) == 32) + return &bfd_howto_32; return NULL; } @@ -8363,7 +8388,8 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, = HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, "unused", FALSE, 0, 0, FALSE); - off = (*parent)->address * bfd_octets_per_byte (input_bfd); + off = ((*parent)->address + * bfd_octets_per_byte (input_bfd, input_section)); _bfd_clear_contents ((*parent)->howto, input_bfd, input_section, data, off); (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; @@ -8448,7 +8474,7 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, free (reloc_vector); return data; -error_return: + error_return: free (reloc_vector); return NULL; }