Add support for M32R GOT relocs
[deliverable/binutils-gdb.git] / bfd / reloc.c
index e50eb11bc4e09d1c240474066f67ee036de43a04..df50af47a7af9e012f16b8bdfa86b99a5c763bda 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD support for handling relocation entries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003
+   2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -98,7 +98,7 @@ CODE_FRAGMENT
 .typedef struct reloc_cache_entry
 .{
 .  {* A pointer into the canonical table of pointers.  *}
-.  struct symbol_cache_entry **sym_ptr_ptr;
+.  struct bfd_symbol **sym_ptr_ptr;
 .
 .  {* offset in section.  *}
 .  bfd_size_type address;
@@ -122,15 +122,16 @@ DESCRIPTION
         o <<sym_ptr_ptr>>
 
         The symbol table pointer points to a pointer to the symbol
-        associated with the relocation request.  It is
-        the pointer into the table returned by the back end's
-        <<get_symtab>> action. @xref{Symbols}. The symbol is referenced
-        through a pointer to a pointer so that tools like the linker
-        can fix up all the symbols of the same name by modifying only
-        one pointer. The relocation routine looks in the symbol and
-        uses the base of the section the symbol is attached to and the
-        value of the symbol as the initial relocation offset. If the
-        symbol pointer is zero, then the section provided is looked up.
+        associated with the relocation request.  It is the pointer
+        into the table returned by the back end's
+        <<canonicalize_symtab>> action. @xref{Symbols}. The symbol is
+        referenced through a pointer to a pointer so that tools like
+        the linker can fix up all the symbols of the same name by
+        modifying only one pointer. The relocation routine looks in
+        the symbol and uses the base of the section the symbol is
+        attached to and the value of the symbol as the initial
+        relocation offset. If the symbol pointer is zero, then the
+        section provided is looked up.
 
         o <<address>>
 
@@ -277,7 +278,7 @@ SUBSUBSECTION
         information that libbfd needs to know to tie up a back end's data.
 
 CODE_FRAGMENT
-.struct symbol_cache_entry;            {* Forward declaration.  *}
+.struct bfd_symbol;            {* Forward declaration.  *}
 .
 .struct reloc_howto_struct
 .{
@@ -318,10 +319,10 @@ CODE_FRAGMENT
 .
 .  {* If this field is non null, then the supplied function is
 .     called rather than the normal function.  This allows really
-.     strange relocation methods to be accomodated (e.g., i960 callj
+.     strange relocation methods to be accommodated (e.g., i960 callj
 .     instructions).  *}
 .  bfd_reloc_status_type (*special_function)
-.    (bfd *, arelent *, struct symbol_cache_entry *, void *, asection *,
+.    (bfd *, arelent *, struct bfd_symbol *, void *, asection *,
 .     bfd *, char **);
 .
 .  {* The textual name of the relocation type.  *}
@@ -586,6 +587,7 @@ bfd_perform_relocation (bfd *abfd,
 {
   bfd_vma relocation;
   bfd_reloc_status_type flag = bfd_reloc_ok;
+  bfd_size_type sz;
   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
@@ -622,11 +624,11 @@ bfd_perform_relocation (bfd *abfd,
     }
 
   /* Is the address of the relocation really within the section?  */
-  if (reloc_entry->address > (input_section->_cooked_size
-                             / bfd_octets_per_byte (abfd)))
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (reloc_entry->address > sz / bfd_octets_per_byte (abfd))
     return bfd_reloc_outofrange;
 
-  /* Work out which section the relocation is targetted at and the
+  /* Work out which section the relocation is targeted at and the
      initial relocation command value.  */
 
   /* Get symbol value.  (Common symbols are special.)  */
@@ -979,6 +981,7 @@ bfd_install_relocation (bfd *abfd,
 {
   bfd_vma relocation;
   bfd_reloc_status_type flag = bfd_reloc_ok;
+  bfd_size_type sz;
   bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd);
   bfd_vma output_base = 0;
   reloc_howto_type *howto = reloc_entry->howto;
@@ -1012,11 +1015,11 @@ bfd_install_relocation (bfd *abfd,
     }
 
   /* Is the address of the relocation really within the section?  */
-  if (reloc_entry->address > (input_section->_cooked_size
-                             / bfd_octets_per_byte (abfd)))
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (reloc_entry->address > sz / bfd_octets_per_byte (abfd))
     return bfd_reloc_outofrange;
 
-  /* Work out which section the relocation is targetted at and the
+  /* Work out which section the relocation is targeted at and the
      initial relocation command value.  */
 
   /* Get symbol value.  (Common symbols are special.)  */
@@ -1347,9 +1350,11 @@ _bfd_final_link_relocate (reloc_howto_type *howto,
                          bfd_vma addend)
 {
   bfd_vma relocation;
+  bfd_size_type sz;
 
   /* Sanity check the address.  */
-  if (address > input_section->_raw_size)
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (address > sz)
     return bfd_reloc_outofrange;
 
   /* This function assumes that we are dealing with a basic relocation
@@ -1645,6 +1650,11 @@ the section containing the relocation.  It depends on the specific target.
 
 The 24-bit relocation is used in some Intel 960 configurations.
 
+ENUM
+  BFD_RELOC_32_SECREL
+ENUMDOC
+  Section relative relocations.  Some targets need this for DWARF2.
+
 ENUM
   BFD_RELOC_32_GOT_PCREL
 ENUMX
@@ -2060,14 +2070,6 @@ ENUM
   BFD_RELOC_LO16
 ENUMDOC
   Low 16 bits.
-ENUM
-  BFD_RELOC_PCREL_HI16_S
-ENUMDOC
-  Like BFD_RELOC_HI16_S, but PC relative.
-ENUM
-  BFD_RELOC_PCREL_LO16
-ENUMDOC
-  Like BFD_RELOC_LO16, but PC relative.
 
 ENUM
   BFD_RELOC_MIPS_LITERAL
@@ -2116,7 +2118,10 @@ ENUMX
   BFD_RELOC_MIPS_RELGOT
 ENUMX
   BFD_RELOC_MIPS_JALR
+ENUMDOC
+  MIPS ELF relocations.
 COMMENT
+
 ENUM
   BFD_RELOC_FRV_LABEL16
 ENUMX
@@ -2135,13 +2140,73 @@ ENUMX
   BFD_RELOC_FRV_GPRELHI
 ENUMX
   BFD_RELOC_FRV_GPRELLO
+ENUMX
+  BFD_RELOC_FRV_GOT12
+ENUMX
+  BFD_RELOC_FRV_GOTHI
+ENUMX
+  BFD_RELOC_FRV_GOTLO
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_GOT12
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_GOTHI
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_GOTLO
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_VALUE
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_GOTOFF12
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_GOTOFFHI
+ENUMX
+  BFD_RELOC_FRV_FUNCDESC_GOTOFFLO
+ENUMX
+  BFD_RELOC_FRV_GOTOFF12
+ENUMX
+  BFD_RELOC_FRV_GOTOFFHI
+ENUMX
+  BFD_RELOC_FRV_GOTOFFLO
 ENUMDOC
   Fujitsu Frv Relocations.
 COMMENT
-COMMENT
-ENUMDOC
-  MIPS ELF relocations.
 
+ENUM
+  BFD_RELOC_MN10300_GOTOFF24
+ENUMDOC
+  This is a 24bit GOT-relative reloc for the mn10300.
+ENUM
+  BFD_RELOC_MN10300_GOT32
+ENUMDOC
+  This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes
+  in the instruction.
+ENUM
+  BFD_RELOC_MN10300_GOT24
+ENUMDOC
+  This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes
+  in the instruction.
+ENUM
+  BFD_RELOC_MN10300_GOT16
+ENUMDOC
+  This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes
+  in the instruction.
+ENUM
+  BFD_RELOC_MN10300_COPY
+ENUMDOC
+  Copy symbol at runtime.
+ENUM
+  BFD_RELOC_MN10300_GLOB_DAT
+ENUMDOC
+  Create GOT entry.
+ENUM
+  BFD_RELOC_MN10300_JMP_SLOT
+ENUMDOC
+  Create PLT entry.
+ENUM
+  BFD_RELOC_MN10300_RELATIVE
+ENUMDOC
+  Adjust by program base.
 COMMENT
 
 ENUM
@@ -2471,7 +2536,7 @@ ENUMDOC
 ENUM
   BFD_RELOC_CTOR
 ENUMDOC
-  The type of reloc used to build a contructor table - at the moment
+  The type of reloc used to build a constructor table - at the moment
   probably a 32 bit wide absolute relocation, but the target can choose.
   It generally does map to one of the other relocation types.
 
@@ -2875,6 +2940,43 @@ ENUM
 ENUMDOC
   This is a 16-bit reloc containing the small data area offset for use in
   add3, load, and store instructions.
+ENUM
+  BFD_RELOC_M32R_GOT24
+ENUMX
+  BFD_RELOC_M32R_26_PLTREL
+ENUMX
+  BFD_RELOC_M32R_COPY
+ENUMX
+  BFD_RELOC_M32R_GLOB_DAT
+ENUMX
+  BFD_RELOC_M32R_JMP_SLOT
+ENUMX
+  BFD_RELOC_M32R_RELATIVE
+ENUMX
+  BFD_RELOC_M32R_GOTOFF
+ENUMX
+  BFD_RELOC_M32R_GOTOFF_HI_ULO
+ENUMX
+  BFD_RELOC_M32R_GOTOFF_HI_SLO
+ENUMX
+  BFD_RELOC_M32R_GOTOFF_LO
+ENUMX
+  BFD_RELOC_M32R_GOTPC24
+ENUMX
+  BFD_RELOC_M32R_GOT16_HI_ULO
+ENUMX
+  BFD_RELOC_M32R_GOT16_HI_SLO
+ENUMX
+  BFD_RELOC_M32R_GOT16_LO
+ENUMX
+  BFD_RELOC_M32R_GOTPC_HI_ULO
+ENUMX
+  BFD_RELOC_M32R_GOTPC_HI_SLO
+ENUMX
+  BFD_RELOC_M32R_GOTPC_LO
+ENUMDOC
+  For PIC.
+
 
 ENUM
   BFD_RELOC_V850_9_PCREL
@@ -2935,12 +3037,12 @@ ENUM
   BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET
 ENUMDOC
   This is a 16 bit offset from the short data area pointer, with the
-  bits placed non-contigously in the instruction.
+  bits placed non-contiguously in the instruction.
 ENUM
   BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET
 ENUMDOC
   This is a 16 bit offset from the zero data area pointer, with the
-  bits placed non-contigously in the instruction.
+  bits placed non-contiguously in the instruction.
 ENUM
   BFD_RELOC_V850_CALLT_6_7_OFFSET
 ENUMDOC
@@ -3097,6 +3199,8 @@ ENUMX
   BFD_RELOC_MMIX_PUSHJ_2
 ENUMX
   BFD_RELOC_MMIX_PUSHJ_3
+ENUMX
+  BFD_RELOC_MMIX_PUSHJ_STUBBABLE
 ENUMDOC
   These are relocations for the PUSHJ instruction.
 ENUM
@@ -3444,7 +3548,7 @@ ENUMDOC
   included in the output.
 
   VTABLE_INHERIT is a zero-space relocation used to describe to the
-  linker the inheritence tree of a C++ virtual function table.  The
+  linker the inheritance tree of a C++ virtual function table.  The
   relocation's symbol should be the parent class' vtable, and the
   relocation should be located at the child vtable.
 
@@ -3637,7 +3741,7 @@ ENUMDOC
   Motorola 68HC11 reloc.
   This reloc marks the beginning of a jump/call instruction.
   It is used for linker relaxation to correctly identify beginning
-  of instruction and change some branchs to use PC-relative
+  of instruction and change some branches to use PC-relative
   addressing mode.
 ENUM
   BFD_RELOC_M68HC11_RL_GROUP
@@ -3667,6 +3771,94 @@ ENUMDOC
   This is a 24-bit reloc that represents the address with a 16-bit
   value and a 8-bit page number.  The symbol address is transformed
   to follow the 16K memory bank of 68HC12 (seen as mapped in the window).
+ENUM
+  BFD_RELOC_M68HC12_5B
+ENUMDOC
+  Motorola 68HC12 reloc.
+  This is the 5 bits of a value.
+
+ENUM
+  BFD_RELOC_16C_NUM08
+ENUMX
+  BFD_RELOC_16C_NUM08_C
+ENUMX
+  BFD_RELOC_16C_NUM16
+ENUMX
+  BFD_RELOC_16C_NUM16_C
+ENUMX
+  BFD_RELOC_16C_NUM32
+ENUMX
+  BFD_RELOC_16C_NUM32_C
+ENUMX
+  BFD_RELOC_16C_DISP04
+ENUMX
+  BFD_RELOC_16C_DISP04_C
+ENUMX
+  BFD_RELOC_16C_DISP08
+ENUMX
+  BFD_RELOC_16C_DISP08_C
+ENUMX
+  BFD_RELOC_16C_DISP16
+ENUMX
+  BFD_RELOC_16C_DISP16_C
+ENUMX
+  BFD_RELOC_16C_DISP24
+ENUMX
+  BFD_RELOC_16C_DISP24_C
+ENUMX
+  BFD_RELOC_16C_DISP24a
+ENUMX
+  BFD_RELOC_16C_DISP24a_C
+ENUMX
+  BFD_RELOC_16C_REG04
+ENUMX
+  BFD_RELOC_16C_REG04_C
+ENUMX
+  BFD_RELOC_16C_REG04a
+ENUMX
+  BFD_RELOC_16C_REG04a_C
+ENUMX
+  BFD_RELOC_16C_REG14
+ENUMX
+  BFD_RELOC_16C_REG14_C
+ENUMX
+  BFD_RELOC_16C_REG16
+ENUMX
+  BFD_RELOC_16C_REG16_C
+ENUMX
+  BFD_RELOC_16C_REG20
+ENUMX
+  BFD_RELOC_16C_REG20_C
+ENUMX
+  BFD_RELOC_16C_ABS20
+ENUMX
+  BFD_RELOC_16C_ABS20_C
+ENUMX
+  BFD_RELOC_16C_ABS24
+ENUMX
+  BFD_RELOC_16C_ABS24_C
+ENUMX
+  BFD_RELOC_16C_IMM04
+ENUMX
+  BFD_RELOC_16C_IMM04_C
+ENUMX
+  BFD_RELOC_16C_IMM16
+ENUMX
+  BFD_RELOC_16C_IMM16_C
+ENUMX
+  BFD_RELOC_16C_IMM20
+ENUMX
+  BFD_RELOC_16C_IMM20_C
+ENUMX
+  BFD_RELOC_16C_IMM24
+ENUMX
+  BFD_RELOC_16C_IMM24_C
+ENUMX
+  BFD_RELOC_16C_IMM32
+ENUMX
+  BFD_RELOC_16C_IMM32_C
+ENUMDOC
+  NS CR16C Relocations.
 
 ENUM
   BFD_RELOC_CRIS_BDISP8
@@ -3994,7 +4186,7 @@ SYNOPSIS
 
 DESCRIPTION
        Provides default handling for relaxing for back ends which
-       don't do relaxing -- i.e., does nothing.
+       don't do relaxing.
 */
 
 bfd_boolean
@@ -4081,6 +4273,7 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
   long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
   arelent **reloc_vector = NULL;
   long reloc_count;
+  bfd_size_type sz;
 
   if (reloc_size < 0)
     goto error_return;
@@ -4090,17 +4283,10 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
     goto error_return;
 
   /* Read in the section.  */
-  if (!bfd_get_section_contents (input_bfd,
-                                input_section,
-                                data,
-                                0,
-                                input_section->_raw_size))
+  sz = input_section->rawsize ? input_section->rawsize : input_section->size;
+  if (!bfd_get_section_contents (input_bfd, input_section, data, 0, sz))
     goto error_return;
 
-  /* We're not relaxing the section, so just copy the size info.  */
-  input_section->_cooked_size = input_section->_raw_size;
-  input_section->reloc_done = TRUE;
-
   reloc_count = bfd_canonicalize_reloc (input_bfd,
                                        input_section,
                                        reloc_vector,
This page took 0.03276 seconds and 4 git commands to generate.