/* BFD back-end for MIPS PE COFF files.
- Copyright (C) 1990-2014 Free Software Foundation, Inc.
+ Copyright (C) 1990-2016 Free Software Foundation, Inc.
Modified from coff-i386.c by DJ Delorie, dj@cygnus.com
This file is part of BFD, the Binary File Descriptor library.
#define DOIT(x) \
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + (diff >> howto->rightshift)) & howto->dst_mask))
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+ if (diff != 0)
+ {
+ reloc_howto_type *howto = reloc_entry->howto;
+ unsigned char *addr = (unsigned char *) data + reloc_entry->address;
- switch (howto->size)
+ switch (howto->size)
+ {
+ case 0:
{
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
-
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
+ char x = bfd_get_8 (abfd, addr);
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
+ DOIT (x);
+ bfd_put_8 (abfd, x, addr);
+ }
+ break;
- DOIT (x);
- bfd_put_16 (abfd, (bfd_vma) x, addr);
- }
- break;
+ case 1:
+ {
+ short x = bfd_get_16 (abfd, addr);
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
+ DOIT (x);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
+ }
+ break;
- DOIT (x);
- bfd_put_32 (abfd, (bfd_vma) x, addr);
- }
- break;
+ case 2:
+ {
+ long x = bfd_get_32 (abfd, addr);
- default:
- abort ();
+ DOIT (x);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
- }
+ break;
+
+ default:
+ abort ();
+ }
+ }
/* Now let bfd_perform_relocation finish everything up. */
return bfd_reloc_continue;
FALSE), /* Pcrel_offset. */
};
-#define NUM_HOWTOS ((sizeof (howto_table) / sizeof (howto_table[0]))
+#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0]))
/* Turn a howto into a reloc nunmber. */
/* Customize coffcode.h. */
#define MIPS 1
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = howto_table + (dst)->r_type;
+#define RTYPE2HOWTO(cache_ptr, dst) \
+ ((cache_ptr)->howto = \
+ ((dst)->r_type < NUM_HOWTOS \
+ ? howto_table + (dst)->r_type \
+ : NULL))
/* Compute the addend of a reloc. If the reloc is to a common symbol,
the object file contains the value of the common symbol. By the
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 != NULL \
&& coffsym->native->u.syment.n_scnum == 0) \
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
struct internal_reloc *rel_end;
unsigned int i;
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
{
(*_bfd_error_handler)
(_("%B: `ld -r' not supported with PE MIPS objects\n"), input_bfd);
then we should ignore the symbol value. */
if (howto->pc_relative && howto->pcrel_offset)
{
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
continue;
if (sym != NULL && sym->n_scnum != 0)
addend += sym->n_value;
+ sec->output_offset);
}
- else if (! info->relocatable)
+ else if (! bfd_link_relocatable (info))
{
if (! ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd, input_section,