X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fcoff-i386.c;h=a9725c4e1c7309deb69b1e9a412b7812215fcb85;hb=b6518b3871859f9eeb7653bf2f3baaa43fa0a5d0;hp=312037e3e730180bd6fd60963de1fce0c4739bbb;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index 312037e3e7..a9725c4e1c 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 COFF files. - Copyright (C) 1990-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2015 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -340,16 +340,18 @@ static reloc_howto_type howto_table[] = PCRELOFFSET) /* pcrel_offset */ }; +#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0])) + /* Turn a howto into a reloc nunmber */ #define SELECT_RELOC(x,howto) { x.r_type = howto->type; } #define BADMAG(x) I386BADMAG(x) #define I386 1 /* Customize coffcode.h */ -#define RTYPE2HOWTO(cache_ptr, dst) \ - ((cache_ptr)->howto = \ - ((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \ - ? howto_table + (dst)->r_type \ +#define RTYPE2HOWTO(cache_ptr, dst) \ + ((cache_ptr)->howto = \ + ((dst)->r_type < NUM_HOWTOS \ + ? howto_table + (dst)->r_type \ : NULL)) /* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared @@ -377,7 +379,7 @@ static reloc_howto_type howto_table[] = coffsym = (obj_symbols (abfd) \ + (cache_ptr->sym_ptr_ptr - symbols)); \ else if (ptr) \ - coffsym = coff_symbol_from (abfd, ptr); \ + coffsym = coff_symbol_from (ptr); \ if (coffsym != (coff_symbol_type *) NULL \ && coffsym->native->u.syment.n_scnum == 0) \ cache_ptr->addend = - coffsym->native->u.syment.n_value; \ @@ -386,7 +388,8 @@ static reloc_howto_type howto_table[] = cache_ptr->addend = - (ptr->section->vma + ptr->value); \ else \ cache_ptr->addend = 0; \ - if (ptr && howto_table[reloc.r_type].pc_relative) \ + if (ptr && reloc.r_type < NUM_HOWTOS \ + && howto_table[reloc.r_type].pc_relative) \ cache_ptr->addend += asect->vma; \ } @@ -414,7 +417,7 @@ coff_pe_i386_relocate_section (bfd *output_bfd, struct internal_syment *syms, asection **sections) { - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd, @@ -438,7 +441,7 @@ coff_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, { reloc_howto_type *howto; - if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0])) + if (rel->r_type >= NUM_HOWTOS) { bfd_set_error (bfd_error_bad_value); return NULL; @@ -506,7 +509,12 @@ coff_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase; } - BFD_ASSERT (sym != NULL); + /* PR 17099 - Absolute R_PCRLONG relocations do not need a symbol. */ + if (rel->r_type == R_PCRLONG && sym == NULL) + *addendp -= rel->r_vaddr; + else + BFD_ASSERT (sym != NULL); + if (rel->r_type == R_SECREL32 && sym != NULL) { bfd_vma osect_vma; @@ -574,7 +582,7 @@ coff_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, { unsigned int i; - for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++) + for (i = 0; i < NUM_HOWTOS; i++) if (howto_table[i].name != NULL && strcasecmp (howto_table[i].name, r_name) == 0) return &howto_table[i]; @@ -605,14 +613,11 @@ coff_i386_is_local_label_name (bfd *abfd, const char *name) #include "coffcode.h" -#define _bfd_generic_find_nearest_line_discriminator \ - coff_find_nearest_line_discriminator - const bfd_target #ifdef TARGET_SYM TARGET_SYM = #else - i386coff_vec = + i386_coff_vec = #endif { #ifdef TARGET_NAME