/* BFD support for handling relocation entries.
- Copyright (C) 1990-2019 Free Software Foundation, Inc.
+ Copyright (C) 1990-2021 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
#include "bfdlink.h"
#include "libbfd.h"
#include "bfdver.h"
+
/*
DOCDD
INODE
This is used to fill in an empty howto entry in an array.
.#define EMPTY_HOWTO(C) \
-. HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
-. NULL, FALSE, 0, 0, FALSE)
+. HOWTO ((C), 0, 0, 0, false, 0, complain_overflow_dont, NULL, \
+. NULL, false, 0, 0, false)
.
*/
.
*/
-/* N_ONES produces N one bits, without overflowing machine arithmetic. */
-#define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1)
+/* N_ONES produces N one bits, without undefined behaviour for N
+ between zero and the number of bits in a bfd_vma. */
+#define N_ONES(n) ((n) == 0 ? 0 : ((bfd_vma) 1 << ((n) - 1) << 1) - 1)
/*
FUNCTION
bfd_vma fieldmask, addrmask, signmask, ss, a;
bfd_reloc_status_type flag = bfd_reloc_ok;
+ if (bitsize == 0)
+ return flag;
+
/* Note: BITSIZE should always be <= ADDRSIZE, but in case it's not,
we'll be permissive: extra bits in the field mask will
automatically extend the address mask for purposes of the
bfd_reloc_offset_in_range
SYNOPSIS
- bfd_boolean bfd_reloc_offset_in_range
+ bool bfd_reloc_offset_in_range
(reloc_howto_type *howto,
bfd *abfd,
asection *section,
/* HOWTO describes a relocation, at offset OCTET. Return whether the
relocation field is within SECTION of ABFD. */
-bfd_boolean
+bool
bfd_reloc_offset_in_range (reloc_howto_type *howto,
bfd *abfd,
asection *section,
else
output_base = reloc_target_output_section->vma;
- /* For sections where relocations are in octets, output_base and
- output_offset must also be converted to octets. */
+ 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))
- relocation += ((output_base + symbol->section->output_offset)
- * bfd_octets_per_byte (abfd, NULL));
- else
- relocation += output_base + symbol->section->output_offset;
+ output_base *= bfd_octets_per_byte (abfd, input_section);
+
+ relocation += output_base;
/* Add in supplied addend. */
relocation += reloc_entry->addend;
else
output_base = reloc_target_output_section->vma;
- /* For sections where relocations are in octets, output_base and
- output_offset must also be converted to octets. */
+ 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))
- relocation += ((output_base + symbol->section->output_offset)
- * bfd_octets_per_byte (abfd, NULL));
- else
- relocation += output_base + symbol->section->output_offset;
+ output_base *= bfd_octets_per_byte (abfd, input_section);
+
+ relocation += output_base;
/* Add in supplied addend. */
relocation += reloc_entry->addend;
}
return _bfd_relocate_contents (howto, input_bfd, relocation,
- contents
- + address
- * bfd_octets_per_byte (input_bfd,
- input_section));
+ contents + octets);
}
/* Relocate a given location using a given value and howto. */
BFD_RELOC_PPC_BA26
ENUMX
BFD_RELOC_PPC_TOC16
+ENUMX
+ BFD_RELOC_PPC_TOC16_LO
+ENUMX
+ BFD_RELOC_PPC_TOC16_HI
ENUMX
BFD_RELOC_PPC_B16
ENUMX
BFD_RELOC_PPC_16DX_HA
ENUMX
BFD_RELOC_PPC_REL16DX_HA
+ENUMX
+ BFD_RELOC_PPC_NEG
ENUMX
BFD_RELOC_PPC64_HIGHER
ENUMX
BFD_RELOC_PPC_TLSGD
ENUMX
BFD_RELOC_PPC_TLSLD
+ENUMX
+ BFD_RELOC_PPC_TLSLE
+ENUMX
+ BFD_RELOC_PPC_TLSIE
+ENUMX
+ BFD_RELOC_PPC_TLSM
+ENUMX
+ BFD_RELOC_PPC_TLSML
ENUMX
BFD_RELOC_PPC_DTPMOD
ENUMX
BFD_RELOC_PPC_GOT_DTPREL16_HI
ENUMX
BFD_RELOC_PPC_GOT_DTPREL16_HA
+ENUMX
+ BFD_RELOC_PPC64_TLSGD
+ENUMX
+ BFD_RELOC_PPC64_TLSLD
+ENUMX
+ BFD_RELOC_PPC64_TLSLE
+ENUMX
+ BFD_RELOC_PPC64_TLSIE
+ENUMX
+ BFD_RELOC_PPC64_TLSM
+ENUMX
+ BFD_RELOC_PPC64_TLSML
ENUMX
BFD_RELOC_PPC64_TPREL16_DS
ENUMX
ENUMX
BFD_RELOC_PPC64_DTPREL34
ENUMX
- BFD_RELOC_PPC64_GOT_TLSGD34
+ BFD_RELOC_PPC64_GOT_TLSGD_PCREL34
ENUMX
- BFD_RELOC_PPC64_GOT_TLSLD34
+ BFD_RELOC_PPC64_GOT_TLSLD_PCREL34
ENUMX
- BFD_RELOC_PPC64_GOT_TPREL34
+ BFD_RELOC_PPC64_GOT_TPREL_PCREL34
ENUMX
- BFD_RELOC_PPC64_GOT_DTPREL34
+ BFD_RELOC_PPC64_GOT_DTPREL_PCREL34
ENUMX
BFD_RELOC_PPC64_TLS_PCREL
ENUMDOC
BFD_RELOC_OR1K_GOTPC_HI16
ENUMX
BFD_RELOC_OR1K_GOTPC_LO16
+ENUMX
+ BFD_RELOC_OR1K_GOT_AHI16
ENUMX
BFD_RELOC_OR1K_GOT16
ENUMX
BFD_RELOC_MSP430_PREL31
ENUMX
BFD_RELOC_MSP430_SYM_DIFF
+ENUMX
+ BFD_RELOC_MSP430_SET_ULEB128
+ENUMX
+ BFD_RELOC_MSP430_SUB_ULEB128
+
ENUMDOC
msp430 specific relocation codes
ENUMX
BFD_RELOC_XTENSA_DIFF32
ENUMDOC
+ Xtensa relocations for backward compatibility. These have been replaced
+ by BFD_RELOC_XTENSA_PDIFF and BFD_RELOC_XTENSA_NDIFF.
Xtensa relocations to mark the difference of two local symbols.
These are only needed to support linker relaxation and can be ignored
when not relaxing. The field is set to the value of the difference
BFD_RELOC_XTENSA_TLS_CALL
ENUMDOC
Xtensa TLS relocations.
+ENUM
+ BFD_RELOC_XTENSA_PDIFF8
+ENUMX
+ BFD_RELOC_XTENSA_PDIFF16
+ENUMX
+ BFD_RELOC_XTENSA_PDIFF32
+ENUMX
+ BFD_RELOC_XTENSA_NDIFF8
+ENUMX
+ BFD_RELOC_XTENSA_NDIFF16
+ENUMX
+ BFD_RELOC_XTENSA_NDIFF32
+ENUMDOC
+ Xtensa relocations to mark the difference of two local symbols.
+ These are only needed to support linker relaxation and can be ignored
+ when not relaxing. The field is set to the value of the difference
+ assuming no relaxation. The relocation encodes the position of the
+ subtracted symbol so the linker can determine whether to adjust the field
+ value. PDIFF relocations are used for positive differences, NDIFF
+ relocations are used for negative differences. The difference value
+ is treated as unsigned with these relocation types, giving full
+ 8/16 value ranges.
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
}
static reloc_howto_type bfd_howto_32 =
-HOWTO (0, 00, 2, 32, FALSE, 0, complain_overflow_dont, 0, "VRT32", FALSE, 0xffffffff, 0xffffffff, TRUE);
+HOWTO (0, 00, 2, 32, false, 0, complain_overflow_dont, 0, "VRT32", false, 0xffffffff, 0xffffffff, true);
/*
INTERNAL_FUNCTION
bfd_generic_relax_section
SYNOPSIS
- bfd_boolean bfd_generic_relax_section
+ bool bfd_generic_relax_section
(bfd *abfd,
asection *section,
struct bfd_link_info *,
- bfd_boolean *);
+ bool *);
DESCRIPTION
Provides default handling for relaxing for back ends which
don't do relaxing.
*/
-bfd_boolean
+bool
bfd_generic_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
asection *section ATTRIBUTE_UNUSED,
struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
- bfd_boolean *again)
+ bool *again)
{
if (bfd_link_relocatable (link_info))
(*link_info->callbacks->einfo)
(_("%P%F: --relax and -r may not be used together\n"));
- *again = FALSE;
- return TRUE;
+ *again = false;
+ return true;
}
/*
bfd_generic_gc_sections
SYNOPSIS
- bfd_boolean bfd_generic_gc_sections
+ bool bfd_generic_gc_sections
(bfd *, struct bfd_link_info *);
DESCRIPTION
don't do section gc -- i.e., does nothing.
*/
-bfd_boolean
+bool
bfd_generic_gc_sections (bfd *abfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
- return TRUE;
+ return true;
}
/*
bfd_generic_lookup_section_flags
SYNOPSIS
- bfd_boolean bfd_generic_lookup_section_flags
+ bool bfd_generic_lookup_section_flags
(struct bfd_link_info *, struct flag_info *, asection *);
DESCRIPTION
Returns FALSE if the section should be omitted, otherwise TRUE.
*/
-bfd_boolean
+bool
bfd_generic_lookup_section_flags (struct bfd_link_info *info ATTRIBUTE_UNUSED,
struct flag_info *flaginfo,
asection *section ATTRIBUTE_UNUSED)
if (flaginfo != NULL)
{
_bfd_error_handler (_("INPUT_SECTION_FLAGS are not supported"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/*
bfd_generic_merge_sections
SYNOPSIS
- bfd_boolean bfd_generic_merge_sections
+ bool bfd_generic_merge_sections
(bfd *, struct bfd_link_info *);
DESCRIPTION
which don't have SEC_MERGE support -- i.e., does nothing.
*/
-bfd_boolean
+bool
bfd_generic_merge_sections (bfd *abfd ATTRIBUTE_UNUSED,
struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
{
- return TRUE;
+ return true;
}
/*
struct bfd_link_info *link_info,
struct bfd_link_order *link_order,
bfd_byte *data,
- bfd_boolean relocatable,
+ bool relocatable,
asymbol **symbols);
DESCRIPTION
struct bfd_link_info *link_info,
struct bfd_link_order *link_order,
bfd_byte *data,
- bfd_boolean relocatable,
+ bool relocatable,
asymbol **symbols)
{
bfd *input_bfd = link_order->u.indirect.section->owner;
{
bfd_vma off;
static reloc_howto_type none_howto
- = HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
- "unused", FALSE, 0, 0, FALSE);
+ = 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, input_section));
case bfd_reloc_undefined:
(*link_info->callbacks->undefined_symbol)
(link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
- input_bfd, input_section, (*parent)->address, TRUE);
+ input_bfd, input_section, (*parent)->address, true);
break;
case bfd_reloc_dangerous:
BFD_ASSERT (error_message != NULL);
free (reloc_vector);
return data;
-error_return:
+ error_return:
free (reloc_vector);
return NULL;
}
_bfd_unrecognized_reloc
SYNOPSIS
- bfd_boolean _bfd_unrecognized_reloc
+ bool _bfd_unrecognized_reloc
(bfd * abfd,
sec_ptr section,
unsigned int r_type);
Returns FALSE so that it can be called from a return statement.
*/
-bfd_boolean
+bool
_bfd_unrecognized_reloc (bfd * abfd, sec_ptr section, unsigned int r_type)
{
/* xgettext:c-format */
BFD_VERSION_STRING);
bfd_set_error (bfd_error_bad_value);
- return FALSE;
+ return false;
}
reloc_howto_type *