#include "coff/internal.h"
#include "libcoff.h"
+static long get_symbol_value PARAMS ((asymbol *));
+static bfd_reloc_status_type a29k_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+
#define INSERT_HWORD(WORD,HWORD) \
(((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff))
#define EXTRACT_HWORD(WORD) \
((HWORD) & 0x8000 ? (HWORD)|0xffff0000 : (HWORD))
/* Provided the symbol, returns the value reffed */
-static long
-get_symbol_value(symbol)
-asymbol *symbol;
+static long
+get_symbol_value (symbol)
+ asymbol *symbol;
{
long relocation = 0;
/* this function is in charge of performing all the 29k relocations */
static bfd_reloc_status_type
-DEFUN(a29k_reloc,(abfd, reloc_entry, symbol_in, data, input_section, output_bfd),
- bfd *abfd AND
- arelent *reloc_entry AND
- asymbol *symbol_in AND
- PTR data AND
- asection *input_section AND
- bfd *output_bfd)
+a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
{
/* the consth relocation comes in two parts, we have to remember
the state between calls, in these variables */
if ((part1_consth_active) && (r_type != R_IHCONST))
{
- fprintf(stderr,"Relocation problem : ");
- fprintf(stderr,"Missing IHCONST in module %s\n",abfd->filename);
part1_consth_active = false;
+ *error_message = (char *) "Missing IHCONST";
return(bfd_reloc_dangerous);
}
case R_IREL:
insn = bfd_get_32(abfd, hit_data);
/* Take the value in the field and sign extend it */
- signed_value = EXTRACT_HWORD(insn) << 2;
+ signed_value = EXTRACT_HWORD(insn);
signed_value = SIGN_EXTEND_HWORD(signed_value);
+ signed_value <<= 2;
signed_value += sym_value + reloc_entry->addend;
if ((signed_value&~0x3ffff) == 0)
{ /* Absolute jmp/call */
{
/* Relative jmp/call, so subtract from the value the
address of the place we're coming from */
- signed_value -= reloc_entry->address +
- input_section->output_section->vma +
- input_section->output_offset;
+ signed_value -= (input_section->output_section->vma
+ + input_section->output_offset);
if (signed_value>0x1ffff || signed_value<-0x20000)
- return(bfd_reloc_outofrange);
+ return(bfd_reloc_overflow);
}
signed_value >>= 2;
insn = INSERT_HWORD(insn, signed_value);
/* consth, part 2
Now relocate the reference */
if (part1_consth_active == false) {
- fprintf(stderr,"Relocation problem : ");
- fprintf(stderr,"IHIHALF missing in module %s\n",
- abfd->filename);
+ *error_message = (char *) "Missing IHIHALF";
return(bfd_reloc_dangerous);
}
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
bfd_put_32(abfd, insn, hit_data);
break;
default:
- fprintf(stderr,"Relocation problem : ");
- fprintf(stderr,"Unrecognized reloc type %d, in module %s\n",
- r_type,abfd->filename);
+ *error_message = "Unrecognized reloc";
return (bfd_reloc_dangerous);
}
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
reloc_processing(relent, reloc, symbols, abfd, section)
-static void DEFUN(reloc_processing,(relent,reloc, symbols, abfd, section) ,
- arelent *relent AND
- struct internal_reloc *reloc AND
- asymbol **symbols AND
- bfd *abfd AND
- asection *section)
+static void
+reloc_processing (relent,reloc, symbols, abfd, section)
+ arelent *relent;
+ struct internal_reloc *reloc;
+ asymbol **symbols;
+ bfd *abfd;
+ asection *section;
{
relent->address = reloc->r_vaddr;
relent->howto = howto_table + reloc->r_type;
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
+ HAS_SYMS | HAS_LOCALS | WP_TEXT),
(SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */
| SEC_LOAD | SEC_RELOC
15, /* ar_max_namelen */
2, /* minimum section alignment */
/* data */
- _do_getb64, _do_getb_signed_64, _do_putb64,
- _do_getb32, _do_getb_signed_32, _do_putb32,
- _do_getb16, _do_getb_signed_16, _do_putb16,
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16,
/* hdrs */
- _do_getb64, _do_getb_signed_64, _do_putb64,
- _do_getb32, _do_getb_signed_32, _do_putb32,
- _do_getb16, _do_getb_signed_16, _do_putb16,
+ bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+ bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+ bfd_getb16, bfd_getb_signed_16, bfd_putb16,
{