X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Freloc.c;h=5e10e7ed7084b71b73a352a8d93f9c5ffb924cdf;hb=727fc41e077139570ea8b8ddfd6c546b2a55627c;hp=1b8c8d75e762bfc6927e207c44cc757fc806e4eb;hpb=b1e24c0220fe6718066991999cb0a6e5b88b569d;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/reloc.c b/bfd/reloc.c index 1b8c8d75e7..5e10e7ed70 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -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, 2004, 2005, 2006 + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Written by Cygnus Support. @@ -8,7 +8,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -18,7 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ /* SECTION @@ -47,8 +48,8 @@ SECTION /* DO compile in the reloc_code name table from libbfd.h. */ #define _BFD_MAKE_TABLE_bfd_reloc_code_real -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "bfdlink.h" #include "libbfd.h" /* @@ -1733,6 +1734,36 @@ ENUMX BFD_RELOC_68K_JMP_SLOT ENUMX BFD_RELOC_68K_RELATIVE +ENUMX + BFD_RELOC_68K_TLS_GD32 +ENUMX + BFD_RELOC_68K_TLS_GD16 +ENUMX + BFD_RELOC_68K_TLS_GD8 +ENUMX + BFD_RELOC_68K_TLS_LDM32 +ENUMX + BFD_RELOC_68K_TLS_LDM16 +ENUMX + BFD_RELOC_68K_TLS_LDM8 +ENUMX + BFD_RELOC_68K_TLS_LDO32 +ENUMX + BFD_RELOC_68K_TLS_LDO16 +ENUMX + BFD_RELOC_68K_TLS_LDO8 +ENUMX + BFD_RELOC_68K_TLS_IE32 +ENUMX + BFD_RELOC_68K_TLS_IE16 +ENUMX + BFD_RELOC_68K_TLS_IE8 +ENUMX + BFD_RELOC_68K_TLS_LE32 +ENUMX + BFD_RELOC_68K_TLS_LE16 +ENUMX + BFD_RELOC_68K_TLS_LE8 ENUMDOC Relocations used by 68K ELF. @@ -1829,6 +1860,16 @@ ENUMX BFD_RELOC_SPARC_UA32 ENUMX BFD_RELOC_SPARC_UA64 +ENUMX + BFD_RELOC_SPARC_GOTDATA_HIX22 +ENUMX + BFD_RELOC_SPARC_GOTDATA_LOX10 +ENUMX + BFD_RELOC_SPARC_GOTDATA_OP_HIX22 +ENUMX + BFD_RELOC_SPARC_GOTDATA_OP_LOX10 +ENUMX + BFD_RELOC_SPARC_GOTDATA_OP ENUMDOC SPARC ELF relocations. There is probably some overlap with other relocation types already defined. @@ -1972,6 +2013,10 @@ ENUMX BFD_RELOC_SPU_LO16 ENUMX BFD_RELOC_SPU_HI16 +ENUMX + BFD_RELOC_SPU_PPU32 +ENUMX + BFD_RELOC_SPU_PPU64 ENUMDOC SPU Relocations. @@ -2064,6 +2109,30 @@ ENUMDOC share a common GP, and the target address is adjusted for STO_ALPHA_STD_GPLOAD. +ENUM + BFD_RELOC_ALPHA_NOP +ENUMDOC + The NOP relocation outputs a NOP if the longword displacement + between two procedure entry points is < 2^21. + +ENUM + BFD_RELOC_ALPHA_BSR +ENUMDOC + The BSR relocation outputs a BSR if the longword displacement + between two procedure entry points is < 2^21. + +ENUM + BFD_RELOC_ALPHA_LDA +ENUMDOC + The LDA relocation outputs a LDA if the longword displacement + between two procedure entry points is < 2^16. + +ENUM + BFD_RELOC_ALPHA_BOH +ENUMDOC + The BOH relocation outputs a BSR if the longword displacement + between two procedure entry points is < 2^21, or else a hint. + ENUM BFD_RELOC_ALPHA_TLSGD ENUMX @@ -2138,6 +2207,13 @@ ENUM ENUMDOC Low 16 bits of pc-relative value +ENUM + BFD_RELOC_MIPS16_GOT16 +ENUMX + BFD_RELOC_MIPS16_CALL16 +ENUMDOC + Equivalent of BFD_RELOC_MIPS_*, but with the MIPS16 layout of + 16-bit immediate fields ENUM BFD_RELOC_MIPS16_HI16 ENUMDOC @@ -2236,7 +2312,7 @@ ENUM ENUMX BFD_RELOC_MIPS_JUMP_SLOT ENUMDOC - MIPS ELF relocations (VxWorks extensions). + MIPS ELF relocations (VxWorks and PLT extensions). COMMENT ENUM @@ -2356,6 +2432,18 @@ ENUM BFD_RELOC_MN10300_RELATIVE ENUMDOC Adjust by program base. +ENUM + BFD_RELOC_MN10300_SYM_DIFF +ENUMDOC + Together with another reloc targeted at the same location, + allows for a value that is the difference of two symbols + in the same section. +ENUM + BFD_RELOC_MN10300_ALIGN +ENUMDOC + The addend of this reloc is an alignment power that must + be honoured at the offset's location, regardless of linker + relaxation. COMMENT ENUM @@ -2622,6 +2710,10 @@ ENUMDOC ENUM BFD_RELOC_PPC_TLS +ENUMX + BFD_RELOC_PPC_TLSGD +ENUMX + BFD_RELOC_PPC_TLSLD ENUMX BFD_RELOC_PPC_DTPMOD ENUMX @@ -2907,6 +2999,11 @@ ENUMX ENUMDOC ARM group relocations. +ENUM + BFD_RELOC_ARM_V4BX +ENUMDOC + Annotation of BX instructions. + ENUM BFD_RELOC_ARM_IMMEDIATE ENUMX @@ -3700,6 +3797,50 @@ ENUMX ENUMDOC Motorola Mcore relocations. +ENUM + BFD_RELOC_MEP_8 +ENUMX + BFD_RELOC_MEP_16 +ENUMX + BFD_RELOC_MEP_32 +ENUMX + BFD_RELOC_MEP_PCREL8A2 +ENUMX + BFD_RELOC_MEP_PCREL12A2 +ENUMX + BFD_RELOC_MEP_PCREL17A2 +ENUMX + BFD_RELOC_MEP_PCREL24A2 +ENUMX + BFD_RELOC_MEP_PCABS24A2 +ENUMX + BFD_RELOC_MEP_LOW16 +ENUMX + BFD_RELOC_MEP_HI16U +ENUMX + BFD_RELOC_MEP_HI16S +ENUMX + BFD_RELOC_MEP_GPREL +ENUMX + BFD_RELOC_MEP_TPREL +ENUMX + BFD_RELOC_MEP_TPREL7 +ENUMX + BFD_RELOC_MEP_TPREL7A2 +ENUMX + BFD_RELOC_MEP_TPREL7A4 +ENUMX + BFD_RELOC_MEP_UIMM24 +ENUMX + BFD_RELOC_MEP_ADDR24A4 +ENUMX + BFD_RELOC_MEP_GNU_VTINHERIT +ENUMX + BFD_RELOC_MEP_GNU_VTENTRY +ENUMDOC + Toshiba Media Processor Relocations. +COMMENT + ENUM BFD_RELOC_MMIX_GETA ENUMX @@ -4057,13 +4198,10 @@ ENUMX ENUMDOC Long displacement extension. -ENUM - BFD_RELOC_SCORE_DUMMY1 -ENUMDOC - Score relocations ENUM BFD_RELOC_SCORE_GPREL15 ENUMDOC + Score relocations Low 16 bit for load/store ENUM BFD_RELOC_SCORE_DUMMY2 @@ -4075,6 +4213,14 @@ ENUM BFD_RELOC_SCORE_BRANCH ENUMDOC This is a 19-bit reloc with the right 1 bit assumed to be 0 +ENUM + BFD_RELOC_SCORE_IMM30 +ENUMDOC + This is a 32-bit reloc for 48-bit instructions. +ENUM + BFD_RELOC_SCORE_IMM32 +ENUMDOC + This is a 32-bit reloc for 48-bit instructions. ENUM BFD_RELOC_SCORE16_JMP ENUMDOC @@ -4083,6 +4229,10 @@ ENUM BFD_RELOC_SCORE16_BRANCH ENUMDOC This is a 8-bit reloc with the right 1 bit assumed to be 0 +ENUM + BFD_RELOC_SCORE_BCMP +ENUMDOC + This is a 9-bit reloc with the right 1 bit assumed to be 0 ENUM BFD_RELOC_SCORE_GOT15 ENUMX @@ -4467,6 +4617,75 @@ ENUMX ENUMDOC NS CR16C Relocations. +ENUM + BFD_RELOC_CR16_NUM8 +ENUMX + BFD_RELOC_CR16_NUM16 +ENUMX + BFD_RELOC_CR16_NUM32 +ENUMX + BFD_RELOC_CR16_NUM32a +ENUMX + BFD_RELOC_CR16_REGREL0 +ENUMX + BFD_RELOC_CR16_REGREL4 +ENUMX + BFD_RELOC_CR16_REGREL4a +ENUMX + BFD_RELOC_CR16_REGREL14 +ENUMX + BFD_RELOC_CR16_REGREL14a +ENUMX + BFD_RELOC_CR16_REGREL16 +ENUMX + BFD_RELOC_CR16_REGREL20 +ENUMX + BFD_RELOC_CR16_REGREL20a +ENUMX + BFD_RELOC_CR16_ABS20 +ENUMX + BFD_RELOC_CR16_ABS24 +ENUMX + BFD_RELOC_CR16_IMM4 +ENUMX + BFD_RELOC_CR16_IMM8 +ENUMX + BFD_RELOC_CR16_IMM16 +ENUMX + BFD_RELOC_CR16_IMM20 +ENUMX + BFD_RELOC_CR16_IMM24 +ENUMX + BFD_RELOC_CR16_IMM32 +ENUMX + BFD_RELOC_CR16_IMM32a +ENUMX + BFD_RELOC_CR16_DISP4 +ENUMX + BFD_RELOC_CR16_DISP8 +ENUMX + BFD_RELOC_CR16_DISP16 +ENUMX + BFD_RELOC_CR16_DISP20 +ENUMX + BFD_RELOC_CR16_DISP24 +ENUMX + BFD_RELOC_CR16_DISP24a +ENUMX + BFD_RELOC_CR16_SWITCH8 +ENUMX + BFD_RELOC_CR16_SWITCH16 +ENUMX + BFD_RELOC_CR16_SWITCH32 +ENUMX + BFD_RELOC_CR16_GOT_REGREL20 +ENUMX + BFD_RELOC_CR16_GOTC_REGREL20 +ENUMX + BFD_RELOC_CR16_GLOB_DAT +ENUMDOC + NS CR16 Relocations. + ENUM BFD_RELOC_CRX_REL4 ENUMX @@ -4572,6 +4791,33 @@ ENUM ENUMDOC 32-bit offset to symbol with PLT entry, relative to this relocation. +ENUM + BFD_RELOC_CRIS_32_GOT_GD +ENUMX + BFD_RELOC_CRIS_16_GOT_GD +ENUMX + BFD_RELOC_CRIS_32_GD +ENUMX + BFD_RELOC_CRIS_DTP +ENUMX + BFD_RELOC_CRIS_32_DTPREL +ENUMX + BFD_RELOC_CRIS_16_DTPREL +ENUMX + BFD_RELOC_CRIS_32_GOT_TPREL +ENUMX + BFD_RELOC_CRIS_16_GOT_TPREL +ENUMX + BFD_RELOC_CRIS_32_TPREL +ENUMX + BFD_RELOC_CRIS_16_TPREL +ENUMX + BFD_RELOC_CRIS_DTPMOD +ENUMX + BFD_RELOC_CRIS_32_IE +ENUMDOC + Relocs used in TLS code for CRIS. + ENUM BFD_RELOC_860_COPY ENUMX @@ -4670,6 +4916,12 @@ ENUMX ENUMDOC Sony Xstormy16 Relocations. +ENUM + BFD_RELOC_RELC +ENUMDOC + Self-describing complex relocations. +COMMENT + ENUM BFD_RELOC_XC16X_PAG ENUMX @@ -4863,6 +5115,22 @@ ENUMDOC assembler-expanded instructions. This is commonly used internally by the linker after analysis of a BFD_RELOC_XTENSA_ASM_EXPAND. +ENUM + BFD_RELOC_XTENSA_TLSDESC_FN +ENUMX + BFD_RELOC_XTENSA_TLSDESC_ARG +ENUMX + BFD_RELOC_XTENSA_TLS_DTPOFF +ENUMX + BFD_RELOC_XTENSA_TLS_TPOFF +ENUMX + BFD_RELOC_XTENSA_TLS_FUNC +ENUMX + BFD_RELOC_XTENSA_TLS_ARG +ENUMX + BFD_RELOC_XTENSA_TLS_CALL +ENUMDOC + Xtensa TLS relocations. ENUM BFD_RELOC_Z80_DISP8 @@ -4882,6 +5150,27 @@ ENUM ENUMDOC 4 bit value. +ENUM + BFD_RELOC_LM32_CALL +ENUMX + BFD_RELOC_LM32_BRANCH +ENUMX + BFD_RELOC_LM32_16_GOT +ENUMX + BFD_RELOC_LM32_GOTOFF_HI16 +ENUMX + BFD_RELOC_LM32_GOTOFF_LO16 +ENUMX + BFD_RELOC_LM32_COPY +ENUMX + BFD_RELOC_LM32_GLOB_DAT +ENUMX + BFD_RELOC_LM32_JMP_SLOT +ENUMX + BFD_RELOC_LM32_RELATIVE +ENUMDOC + Lattice Mico32 relocations. + ENDSENUM BFD_RELOC_UNUSED CODE_FRAGMENT @@ -4892,10 +5181,13 @@ CODE_FRAGMENT /* FUNCTION bfd_reloc_type_lookup + bfd_reloc_name_lookup SYNOPSIS reloc_howto_type *bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); + reloc_howto_type *bfd_reloc_name_lookup + (bfd *abfd, const char *reloc_name); DESCRIPTION Return a pointer to a howto structure which, when @@ -4910,6 +5202,12 @@ bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) return BFD_SEND (abfd, reloc_type_lookup, (abfd, code)); } +reloc_howto_type * +bfd_reloc_name_lookup (bfd *abfd, const char *reloc_name) +{ + return BFD_SEND (abfd, reloc_name_lookup, (abfd, reloc_name)); +} + static reloc_howto_type bfd_howto_32 = HOWTO (0, 00, 2, 32, FALSE, 0, complain_overflow_dont, 0, "VRT32", FALSE, 0xffffffff, 0xffffffff, TRUE); @@ -5064,26 +5362,28 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, bfd_boolean relocatable, asymbol **symbols) { - /* Get enough memory to hold the stuff. */ bfd *input_bfd = link_order->u.indirect.section->owner; asection *input_section = link_order->u.indirect.section; - - long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); - arelent **reloc_vector = NULL; + long reloc_size; + arelent **reloc_vector; long reloc_count; bfd_size_type sz; + reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); if (reloc_size < 0) - goto error_return; - - reloc_vector = bfd_malloc (reloc_size); - if (reloc_vector == NULL && reloc_size != 0) - goto error_return; + return NULL; /* Read in the section. */ 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; + return NULL; + + if (reloc_size == 0) + return data; + + reloc_vector = bfd_malloc (reloc_size); + if (reloc_vector == NULL) + return NULL; reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, @@ -5098,13 +5398,31 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, for (parent = reloc_vector; *parent != NULL; parent++) { char *error_message = NULL; - bfd_reloc_status_type r = - bfd_perform_relocation (input_bfd, - *parent, - data, - input_section, - relocatable ? abfd : NULL, - &error_message); + asymbol *symbol; + bfd_reloc_status_type r; + + symbol = *(*parent)->sym_ptr_ptr; + if (symbol->section && elf_discarded_section (symbol->section)) + { + bfd_byte *p; + static reloc_howto_type none_howto + = HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, + "unused", FALSE, 0, 0, FALSE); + + p = data + (*parent)->address * bfd_octets_per_byte (input_bfd); + _bfd_clear_contents ((*parent)->howto, input_bfd, p); + (*parent)->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr; + (*parent)->addend = 0; + (*parent)->howto = &none_howto; + r = bfd_reloc_ok; + } + else + r = bfd_perform_relocation (input_bfd, + *parent, + data, + input_section, + relocatable ? abfd : NULL, + &error_message); if (relocatable) { @@ -5150,12 +5468,11 @@ bfd_generic_get_relocated_section_contents (bfd *abfd, } } } - if (reloc_vector != NULL) - free (reloc_vector); + + free (reloc_vector); return data; error_return: - if (reloc_vector != NULL) - free (reloc_vector); + free (reloc_vector); return NULL; }