mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-20 15:43:16 +00:00
Removed unused files (about 8MB total).
This commit is contained in:
parent
e747e4bcc1
commit
82db78fb71
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27069
@ -1,19 +0,0 @@
|
||||
|
||||
/* Whether malloc must be declared even if <stdlib.h> is included. */
|
||||
#undef NEED_DECLARATION_MALLOC
|
||||
|
||||
/* Whether free must be declared even if <stdlib.h> is included. */
|
||||
#undef NEED_DECLARATION_FREE
|
||||
@TOP@
|
||||
|
||||
/* Do we need to use the b modifier when opening binary files? */
|
||||
#undef USE_BINARY_FOPEN
|
||||
|
||||
/* Name of host specific header file to include in trad-core.c. */
|
||||
#undef TRAD_HEADER
|
||||
|
||||
/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
|
||||
#undef HAVE_SYS_PROCFS_H
|
||||
|
||||
/* Do we really want to use mmap if it's available? */
|
||||
#undef USE_MMAP
|
@ -1,285 +0,0 @@
|
||||
/* BFD back-end for AIX on PS/2 core files.
|
||||
This was based on trad-core.c, which was written by John Gilmore of
|
||||
Cygnus Support.
|
||||
Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
|
||||
Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/i386.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (_AIX) && defined (_I386)
|
||||
#define NOCHECKS /* this is for coredump.h */
|
||||
#define _h_USER /* avoid including user.h from coredump.h */
|
||||
#include <uinfo.h>
|
||||
#include <sys/i386/coredump.h>
|
||||
#endif /* _AIX && _I386 */
|
||||
|
||||
/* maybe this could work on some other i386 but I have not tried it
|
||||
* mtranle@paris - Tue Sep 24 12:49:35 1991
|
||||
*/
|
||||
|
||||
#ifndef COR_MAGIC
|
||||
# define COR_MAGIC "core"
|
||||
#endif
|
||||
|
||||
/* need this cast because ptr is really void * */
|
||||
#define core_hdr(bfd) \
|
||||
(((bfd->tdata.trad_core_data))->hdr)
|
||||
#define core_section(bfd,n) \
|
||||
(((bfd)->tdata.trad_core_data)->sections[n])
|
||||
#define core_regsec(bfd) \
|
||||
(((bfd)->tdata.trad_core_data)->reg_section)
|
||||
#define core_reg2sec(bfd) \
|
||||
(((bfd)->tdata.trad_core_data)->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
struct trad_core_struct {
|
||||
struct corehdr *hdr; /* core file header */
|
||||
asection *reg_section;
|
||||
asection *reg2_section;
|
||||
asection *sections[MAX_CORE_SEGS];
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
aix386_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int i,n;
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
int core_size = sizeof (struct corehdr);
|
||||
struct corehdr *core;
|
||||
struct mergem {
|
||||
struct trad_core_struct coredata;
|
||||
struct corehdr internal_core;
|
||||
} *mergem;
|
||||
|
||||
if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(longbuf,COR_MAGIC,4)) return 0;
|
||||
|
||||
if (bfd_seek (abfd, 0L, false) < 0) return 0;
|
||||
|
||||
mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
core = &mergem->internal_core;
|
||||
|
||||
if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
bfd_release (abfd, (char *)mergem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
set_tdata (abfd, &mergem->coredata);
|
||||
core_hdr (abfd) = core;
|
||||
|
||||
/* create the sections. This is raunchy, but bfd_close wants to reclaim
|
||||
them */
|
||||
core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_regsec (abfd) == NULL)
|
||||
{
|
||||
loser:
|
||||
bfd_release (abfd, (char *)mergem);
|
||||
return 0;
|
||||
}
|
||||
core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
{
|
||||
loser1:
|
||||
bfd_release (abfd, core_regsec (abfd));
|
||||
goto loser;
|
||||
}
|
||||
|
||||
for (i=0, n=0 ; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type) ; i++)
|
||||
{
|
||||
if (core->cd_segs[i].cs_offset == 0)
|
||||
continue;
|
||||
core_section (abfd,n) =
|
||||
(asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_section (abfd,n) == NULL)
|
||||
{
|
||||
int j;
|
||||
if (n > 0)
|
||||
{
|
||||
for (j=0; j < n; j++)
|
||||
bfd_release (abfd, core_section(abfd, j));
|
||||
}
|
||||
bfd_release (abfd, (char *)mergem);
|
||||
goto loser1;
|
||||
}
|
||||
|
||||
switch (core->cd_segs[i].cs_type)
|
||||
{
|
||||
case COR_TYPE_DATA:
|
||||
core_section (abfd, n)->name = ".data";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
|
||||
SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_STACK:
|
||||
core_section (abfd, n)->name = ".stack";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
|
||||
SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_LIBDATA:
|
||||
core_section (abfd, n)->name = ".libdata";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_WRITE:
|
||||
core_section (abfd, n)->name = ".writeable";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_MSC:
|
||||
core_section (abfd, n)->name = ".misc";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
default:
|
||||
core_section (abfd, n)->name = ".unknown";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
}
|
||||
core_section (abfd, n)->_raw_size = core->cd_segs[i].cs_len;
|
||||
core_section (abfd, n)->vma = core->cd_segs[i].cs_address;
|
||||
core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset;
|
||||
core_section (abfd, n)->alignment_power = 2;
|
||||
core_section (abfd, n)->next = NULL;
|
||||
if (n > 0)
|
||||
core_section (abfd, (n-1))->next = core_section (abfd, n);
|
||||
|
||||
abfd->section_count = ++n;
|
||||
}
|
||||
|
||||
core_regsec (abfd)->name = ".reg";
|
||||
core_reg2sec (abfd)->name = ".reg2";
|
||||
|
||||
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
|
||||
core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
|
||||
core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
|
||||
|
||||
core_regsec (abfd)->vma = -1;
|
||||
core_reg2sec (abfd)->vma = -1;
|
||||
|
||||
/* We'll access the regs afresh in the core file, like any section: */
|
||||
core_regsec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,cd_regs[0]);
|
||||
core_reg2sec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,
|
||||
cd_fpregs);
|
||||
|
||||
/* add the 2 reg fake sections to abfd */
|
||||
abfd->section_count += 2;
|
||||
abfd->sections = core_regsec (abfd);
|
||||
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||
core_reg2sec (abfd)->next = core_section (abfd, 0);
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
aix386_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->cd_comm;
|
||||
}
|
||||
|
||||
static int
|
||||
aix386_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->cd_cursig;
|
||||
}
|
||||
|
||||
static boolean
|
||||
aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
return true; /* FIXME, We have no way of telling at this
|
||||
point */
|
||||
}
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
void
|
||||
swap_abort()
|
||||
{
|
||||
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
|
||||
}
|
||||
#define NO_GET ((PROTO(bfd_vma, (*), ( const bfd_byte *))) swap_abort )
|
||||
#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
|
||||
|
||||
const bfd_target aix386_core_vec =
|
||||
{
|
||||
"aix386-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIANG_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* data */
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, _bfd_dummy_target,
|
||||
_bfd_dummy_target, aix386_core_file_p},
|
||||
{bfd_false, bfd_false, /* bfd_create_object */
|
||||
bfd_false, bfd_false},
|
||||
{bfd_false, bfd_false, /* bfd_write_contents */
|
||||
bfd_false, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (aix386),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0
|
||||
};
|
@ -1,528 +0,0 @@
|
||||
/* BFD back-end for a.out.adobe binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support. Based on bout.c.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "aout/adobe.h"
|
||||
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
extern const bfd_target a_out_adobe_vec; /* Forward decl */
|
||||
|
||||
static const bfd_target *aout_adobe_callback PARAMS ((bfd *));
|
||||
|
||||
extern boolean aout_32_slurp_symbol_table PARAMS ((bfd *abfd));
|
||||
extern boolean aout_32_write_syms PARAMS ((bfd *));
|
||||
static void aout_adobe_write_section PARAMS ((bfd *abfd, sec_ptr sect));
|
||||
|
||||
/* Swaps the information in an executable header taken from a raw byte
|
||||
stream memory image, into the internal exec_header structure. */
|
||||
|
||||
void aout_adobe_swap_exec_header_in
|
||||
PARAMS ((bfd *abfd, struct external_exec *raw_bytes,
|
||||
struct internal_exec *execp));
|
||||
|
||||
void
|
||||
aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
|
||||
bfd *abfd;
|
||||
struct external_exec *raw_bytes;
|
||||
struct internal_exec *execp;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
|
||||
execp->a_text = GET_WORD (abfd, bytes->e_text);
|
||||
execp->a_data = GET_WORD (abfd, bytes->e_data);
|
||||
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
|
||||
execp->a_syms = GET_WORD (abfd, bytes->e_syms);
|
||||
execp->a_entry = GET_WORD (abfd, bytes->e_entry);
|
||||
execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
|
||||
execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
|
||||
}
|
||||
|
||||
/* Swaps the information in an internal exec header structure into the
|
||||
supplied buffer ready for writing to disk. */
|
||||
|
||||
PROTO(void, aout_adobe_swap_exec_header_out,
|
||||
(bfd *abfd,
|
||||
struct internal_exec *execp,
|
||||
struct external_exec *raw_bytes));
|
||||
void
|
||||
aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
|
||||
bfd *abfd;
|
||||
struct internal_exec *execp;
|
||||
struct external_exec *raw_bytes;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||
|
||||
/* Now fill in fields in the raw data, from the fields in the exec struct. */
|
||||
bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
|
||||
PUT_WORD (abfd, execp->a_text , bytes->e_text);
|
||||
PUT_WORD (abfd, execp->a_data , bytes->e_data);
|
||||
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
|
||||
PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
|
||||
PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
|
||||
PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
|
||||
PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
|
||||
}
|
||||
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec anexec;
|
||||
struct external_exec exec_bytes;
|
||||
char *targ;
|
||||
|
||||
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE) {
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
|
||||
|
||||
/* Normally we just compare for the magic number.
|
||||
However, a bunch of Adobe tools aren't fixed up yet; they generate
|
||||
files using ZMAGIC(!).
|
||||
If the environment variable GNUTARGET is set to "a.out.adobe", we will
|
||||
take just about any a.out file as an Adobe a.out file. FIXME! */
|
||||
|
||||
if (N_BADMAG (anexec)) {
|
||||
extern char *getenv ();
|
||||
|
||||
targ = getenv ("GNUTARGET");
|
||||
if (targ && !strcmp (targ, a_out_adobe_vec.name))
|
||||
; /* Just continue anyway, if specifically set to this format */
|
||||
else
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
|
||||
return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_callback);
|
||||
}
|
||||
|
||||
|
||||
/* Finish up the opening of a b.out file for reading. Fill in all the
|
||||
fields that are not handled by common code. */
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
asection *sect;
|
||||
struct external_segdesc ext[1];
|
||||
char *section_name;
|
||||
char try_again[30]; /* name and number */
|
||||
char *newname;
|
||||
int trynum;
|
||||
flagword flags;
|
||||
|
||||
/* Architecture and machine type -- unknown in this format. */
|
||||
bfd_set_arch_mach(abfd, bfd_arch_unknown, 0);
|
||||
|
||||
/* The positions of the string table and symbol table. */
|
||||
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||
|
||||
/* Suck up the section information from the file, one section at a time. */
|
||||
|
||||
for (;;) {
|
||||
if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) {
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
switch (ext->e_type[0]) {
|
||||
case N_TEXT:
|
||||
section_name = ".text";
|
||||
flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case N_DATA:
|
||||
section_name = ".data";
|
||||
flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case N_BSS:
|
||||
section_name = ".bss";
|
||||
flags = SEC_DATA | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
goto no_more_sections;
|
||||
|
||||
default:
|
||||
(*_bfd_error_handler)
|
||||
("%s: Unknown section type in a.out.adobe file: %x\n",
|
||||
bfd_get_filename (abfd), ext->e_type[0]);
|
||||
goto no_more_sections;
|
||||
}
|
||||
|
||||
/* First one is called ".text" or whatever; subsequent ones are
|
||||
".text1", ".text2", ... */
|
||||
|
||||
bfd_set_error (bfd_error_no_error);
|
||||
sect = bfd_make_section (abfd, section_name);
|
||||
trynum = 0;
|
||||
while (!sect) {
|
||||
if (bfd_get_error () != bfd_error_no_error)
|
||||
return 0; /* Some other error -- slide into the sunset */
|
||||
sprintf (try_again, "%s%d", section_name, ++trynum);
|
||||
sect = bfd_make_section (abfd, try_again);
|
||||
}
|
||||
|
||||
/* Fix the name, if it is a sprintf'd name. */
|
||||
if (sect->name == try_again) {
|
||||
newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
|
||||
if (newname == NULL)
|
||||
return 0;
|
||||
strcpy (newname, sect->name);
|
||||
sect->name = newname;
|
||||
}
|
||||
|
||||
/* Now set the section's attributes. */
|
||||
bfd_set_section_flags (abfd, sect, flags);
|
||||
sect->_raw_size = ((ext->e_size[0] << 8) /* Assumed big-endian */
|
||||
| ext->e_size[1] << 8)
|
||||
| ext->e_size[2];
|
||||
sect->_cooked_size = sect->_raw_size;
|
||||
sect->vma = bfd_h_get_32 (abfd, ext->e_virtbase);
|
||||
sect->filepos = bfd_h_get_32 (abfd, ext->e_filebase);
|
||||
/* FIXME XXX alignment? */
|
||||
|
||||
/* Set relocation information for first section of each type. */
|
||||
if (trynum == 0) switch (ext->e_type[0]) {
|
||||
case N_TEXT:
|
||||
sect->rel_filepos = N_TRELOFF (*execp);
|
||||
sect->reloc_count = execp->a_trsize;
|
||||
break;
|
||||
|
||||
case N_DATA:
|
||||
sect->rel_filepos = N_DRELOFF (*execp);
|
||||
sect->reloc_count = execp->a_drsize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
no_more_sections:
|
||||
|
||||
adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||
adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||
adata(abfd).page_size = 1; /* Not applicable. */
|
||||
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
struct bout_data_struct {
|
||||
struct aoutdata a;
|
||||
struct internal_exec e;
|
||||
};
|
||||
|
||||
static boolean
|
||||
aout_adobe_mkobject (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bout_data_struct *rawptr;
|
||||
|
||||
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
|
||||
if (rawptr == NULL)
|
||||
return false;
|
||||
|
||||
abfd->tdata.bout_data = rawptr;
|
||||
exec_hdr (abfd) = &rawptr->e;
|
||||
|
||||
adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||
adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||
adata(abfd).page_size = 1; /* Not applicable. */
|
||||
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static boolean
|
||||
aout_adobe_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec swapped_hdr;
|
||||
static struct external_segdesc sentinel[1]; /* Initialized to zero */
|
||||
asection *sect;
|
||||
|
||||
exec_hdr (abfd)->a_info = ZMAGIC;
|
||||
|
||||
/* Calculate text size as total of text sections, etc. */
|
||||
|
||||
exec_hdr (abfd)->a_text = 0;
|
||||
exec_hdr (abfd)->a_data = 0;
|
||||
exec_hdr (abfd)->a_bss = 0;
|
||||
exec_hdr (abfd)->a_trsize = 0;
|
||||
exec_hdr (abfd)->a_drsize = 0;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
exec_hdr (abfd)->a_text += sect->_raw_size;
|
||||
exec_hdr (abfd)->a_trsize += sect->reloc_count *
|
||||
sizeof (struct reloc_std_external);
|
||||
} else if (sect->flags & SEC_DATA) {
|
||||
exec_hdr (abfd)->a_data += sect->_raw_size;
|
||||
exec_hdr (abfd)->a_drsize += sect->reloc_count *
|
||||
sizeof (struct reloc_std_external);
|
||||
} else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) {
|
||||
exec_hdr (abfd)->a_bss += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
|
||||
exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd)
|
||||
* sizeof (struct external_nlist);
|
||||
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
|
||||
|
||||
aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE))
|
||||
return false;
|
||||
|
||||
/* Now write out the section information. Text first, data next, rest
|
||||
afterward. */
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
}
|
||||
}
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_DATA) {
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
}
|
||||
}
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (!(sect->flags & (SEC_CODE|SEC_DATA))) {
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write final `sentinel` section header (with type of 0). */
|
||||
if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
|
||||
!= sizeof (*sentinel))
|
||||
return false;
|
||||
|
||||
/* Now write out reloc info, followed by syms and strings */
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
if (! aout_32_write_syms (abfd))
|
||||
return false;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_DATA) {
|
||||
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
aout_adobe_write_section (abfd, sect)
|
||||
bfd *abfd;
|
||||
sec_ptr sect;
|
||||
{
|
||||
/* FIXME XXX */
|
||||
}
|
||||
|
||||
static boolean
|
||||
aout_adobe_set_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type count;
|
||||
{
|
||||
file_ptr section_start;
|
||||
sec_ptr sect;
|
||||
|
||||
if (abfd->output_has_begun == false) { /* set by bfd.c handler */
|
||||
|
||||
/* Assign file offsets to sections. Text sections are first, and
|
||||
are contiguous. Then data sections. Everything else at the end. */
|
||||
|
||||
section_start = N_TXTOFF (ignore<-->me);
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment */
|
||||
section_start += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_DATA) {
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment */
|
||||
section_start += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_HAS_CONTENTS &&
|
||||
!(sect->flags & (SEC_CODE|SEC_DATA))) {
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment */
|
||||
section_start += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* regardless, once we know what we're doing, we might as well get going */
|
||||
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
if (count != 0) {
|
||||
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
aout_adobe_set_arch_mach (abfd, arch, machine)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
if (! bfd_default_set_arch_mach (abfd, arch, machine))
|
||||
return false;
|
||||
|
||||
if (arch == bfd_arch_unknown
|
||||
|| arch == bfd_arch_m68k)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
aout_adobe_sizeof_headers (ignore_abfd, ignore)
|
||||
bfd *ignore_abfd;
|
||||
boolean ignore;
|
||||
{
|
||||
return sizeof(struct internal_exec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Build the transfer vector for Adobe A.Out files. */
|
||||
|
||||
#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
|
||||
|
||||
#define aout_32_bfd_make_debug_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
|
||||
|
||||
#define aout_32_bfd_reloc_type_lookup \
|
||||
((reloc_howto_type *(*) \
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
|
||||
|
||||
#define aout_32_set_arch_mach aout_adobe_set_arch_mach
|
||||
#define aout_32_set_section_contents aout_adobe_set_section_contents
|
||||
|
||||
#define aout_32_sizeof_headers aout_adobe_sizeof_headers
|
||||
#define aout_32_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
||||
#define aout_32_bfd_relax_section bfd_generic_relax_section
|
||||
#define aout_32_bfd_link_hash_table_create \
|
||||
_bfd_generic_link_hash_table_create
|
||||
#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define aout_32_bfd_final_link _bfd_generic_final_link
|
||||
#define aout_32_bfd_link_split_section _bfd_generic_link_split_section
|
||||
|
||||
const bfd_target a_out_adobe_vec =
|
||||
{
|
||||
"a.out.adobe", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is unknown (big assumed) */
|
||||
BFD_ENDIAN_BIG, /* hdr byte order is big */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
/* section flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC),
|
||||
'_', /* symbol leading char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
{_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, aout_adobe_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, aout_adobe_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (aout_32),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
|
||||
BFD_JUMP_TABLE_SYMBOLS (aout_32),
|
||||
BFD_JUMP_TABLE_RELOCS (aout_32),
|
||||
BFD_JUMP_TABLE_WRITE (aout_32),
|
||||
BFD_JUMP_TABLE_LINK (aout_32),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0
|
||||
};
|
@ -1,548 +0,0 @@
|
||||
/* BFD back-end for raw ARM a.out binaries.
|
||||
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#define N_TXTADDR(x) \
|
||||
((N_MAGIC(x) == NMAGIC) ? 0x8000 : \
|
||||
(N_MAGIC(x) != ZMAGIC) ? 0 : \
|
||||
(N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \
|
||||
TEXT_START_ADDR)
|
||||
|
||||
#define TEXT_START_ADDR 0x8000
|
||||
#define TARGET_PAGE_SIZE 0x8000
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define DEFAULT_ARCH bfd_arch_arm
|
||||
|
||||
#define MY(OP) CAT(aoutarm_,OP)
|
||||
#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
|
||||
(((x).a_info & ~006000) != OMAGIC) && \
|
||||
((x).a_info != NMAGIC))
|
||||
#define N_MAGIC(x) ((x).a_info & ~07200)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "assert.h"
|
||||
|
||||
#define MYARM(OP) CAT(aoutarm_,OP)
|
||||
reloc_howto_type *MYARM(bfd_reloc_type_lookup)
|
||||
PARAMS((bfd *, bfd_reloc_code_real_type));
|
||||
static boolean MYARM(write_object_contents) PARAMS((bfd *));
|
||||
|
||||
/* Avoid multiple defininitions from aoutx if supporting standarad a.out
|
||||
as well as our own. */
|
||||
#define NAME(x,y) CAT3(aoutarm,_32_,y)
|
||||
|
||||
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
|
||||
|
||||
#include "libaout.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
|
||||
arelent *, asymbol **,
|
||||
bfd_size_type));
|
||||
void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *,
|
||||
struct reloc_std_external *));
|
||||
|
||||
reloc_howto_type MY(howto_table)[] =
|
||||
{
|
||||
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask
|
||||
pcdone */
|
||||
HOWTO (0, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true,
|
||||
0x000000ff, 0x000000ff, false),
|
||||
HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true,
|
||||
0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (2, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true,
|
||||
0xffffffff, 0xffffffff, false),
|
||||
HOWTO (3, 2, 2, 26, true, 0, complain_overflow_signed, MY(fix_pcrel_26),
|
||||
"ARM26", true, 0x00ffffff, 0x00ffffff, true),
|
||||
HOWTO (4, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true,
|
||||
0x000000ff, 0x000000ff, true),
|
||||
HOWTO (5, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true,
|
||||
0x0000ffff, 0x0000ffff, true),
|
||||
HOWTO (6, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true,
|
||||
0xffffffff, 0xffffffff, true),
|
||||
HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed,
|
||||
MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0,
|
||||
false),
|
||||
{-1},
|
||||
HOWTO (9, 0, -1, 16, false, 0, complain_overflow_bitfield, 0, "NEG16", true,
|
||||
0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (10, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "NEG32", true,
|
||||
0xffffffff, 0xffffffff, false)
|
||||
};
|
||||
|
||||
#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
|
||||
#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
|
||||
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *rel;
|
||||
int *r_index;
|
||||
int *r_extern;
|
||||
int *r_pcrel;
|
||||
{
|
||||
unsigned int r_length;
|
||||
unsigned int r_pcrel_done;
|
||||
unsigned int r_neg;
|
||||
int index;
|
||||
|
||||
*r_pcrel = 0;
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
*r_index = ((rel->r_index[0] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[2]);
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
|
||||
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
|
||||
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_BIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
*r_index = ((rel->r_index[2] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[0]);
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
}
|
||||
index = r_length + 4 * r_pcrel_done + 8 * r_neg;
|
||||
if (index == 3)
|
||||
*r_pcrel = 1;
|
||||
|
||||
return MY(howto_table) + index;
|
||||
}
|
||||
|
||||
#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
|
||||
MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
|
||||
|
||||
void
|
||||
MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
|
||||
bfd *abfd;
|
||||
int r_extern;
|
||||
int r_index;
|
||||
long value;
|
||||
reloc_howto_type *howto;
|
||||
struct reloc_std_external *reloc;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_neg;
|
||||
|
||||
PUT_WORD (abfd, value, reloc->r_address);
|
||||
r_length = howto->size ; /* Size as a power of two */
|
||||
|
||||
/* Special case for branch relocations. */
|
||||
if (howto->type == 3 || howto->type == 7)
|
||||
r_length = 3;
|
||||
|
||||
r_pcrel = howto->type & 4; /* PC Relative done? */
|
||||
r_neg = howto->type & 8; /* Negative relocation */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
reloc->r_index[0] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[2] = r_index;
|
||||
reloc->r_type[0] =
|
||||
((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
reloc->r_index[2] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[0] = r_index;
|
||||
reloc->r_type[0] =
|
||||
((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||
MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||
|
||||
void
|
||||
MY(relocatable_reloc)(howto, abfd, reloc, amount, r_addr)
|
||||
reloc_howto_type *howto;
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *reloc;
|
||||
bfd_vma *amount;
|
||||
bfd_vma r_addr;
|
||||
{
|
||||
if (howto->type == 3)
|
||||
{
|
||||
if (reloc->r_type[0]
|
||||
& (bfd_header_big_endian (abfd)
|
||||
? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE))
|
||||
{
|
||||
/* The reloc is still external, so don't modify anything. */
|
||||
*amount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*amount -= r_addr;
|
||||
/* Change the r_pcrel value -- on the ARM, this bit is set once the
|
||||
relocation is done. */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG;
|
||||
else
|
||||
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE;
|
||||
}
|
||||
}
|
||||
else if (howto->type == 7)
|
||||
*amount = 0;
|
||||
}
|
||||
|
||||
#define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \
|
||||
MY(relocatable_reloc)(HOW, BFD, REL, &(AMOUNT), ADDR)
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26_done) (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* This is dead simple at present. */
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||
|
||||
/* If this is an undefined symbol, return error */
|
||||
if (symbol->section == &bfd_und_section
|
||||
&& (symbol->flags & BSF_WEAK) == 0)
|
||||
return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
|
||||
|
||||
/* If the sections are different, and we are doing a partial relocation,
|
||||
just ignore it for now. */
|
||||
if (symbol->section->name != input_section->name
|
||||
&& output_bfd != (bfd *)NULL)
|
||||
return bfd_reloc_ok;
|
||||
|
||||
relocation = (target & 0x00ffffff) << 2;
|
||||
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
|
||||
relocation += symbol->value;
|
||||
relocation += symbol->section->output_section->vma;
|
||||
relocation += symbol->section->output_offset;
|
||||
relocation += reloc_entry->addend;
|
||||
relocation -= input_section->output_section->vma;
|
||||
relocation -= input_section->output_offset;
|
||||
relocation -= addr;
|
||||
if (relocation & 3)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
/* Check for overflow */
|
||||
if (relocation & 0x02000000)
|
||||
{
|
||||
if ((relocation & ~0x03ffffff) != ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else if (relocation & ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
|
||||
target &= ~0x00ffffff;
|
||||
target |= (relocation >> 2) & 0x00ffffff;
|
||||
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||
|
||||
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||
Strictly this is only necessary if we are doing a partial relocation. */
|
||||
reloc_entry->howto = &MY(howto_table)[7];
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
MY(bfd_reloc_type_lookup)(abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
#define ASTD(i,j) case i: return &MY(howto_table)[j]
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
ASTD (BFD_RELOC_16, 1);
|
||||
ASTD (BFD_RELOC_32, 2);
|
||||
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||
#define MY_get_section_contents _bfd_generic_get_section_contents
|
||||
/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create */
|
||||
/* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols */
|
||||
/* #define MY_bfd_final_link _bfd_generic_final_link */
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||
|
||||
cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
|
||||
|
||||
MOVE_ADDRESS (0);
|
||||
}
|
||||
|
||||
void
|
||||
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
int r_length;
|
||||
int r_pcrel;
|
||||
int r_neg = 0; /* Negative relocs use the BASEREL bit. */
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD(abfd, g->address, natptr->r_address);
|
||||
|
||||
r_length = g->howto->size ; /* Size as a power of two */
|
||||
if (r_length < 0)
|
||||
{
|
||||
r_length = -r_length;
|
||||
r_neg = 1;
|
||||
}
|
||||
|
||||
r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
|
||||
|
||||
/* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
|
||||
relocation has been done already (Only for the 26-bit one I think)???!!!
|
||||
*/
|
||||
|
||||
if (g->howto->type == 3)
|
||||
{
|
||||
r_length = 3;
|
||||
r_pcrel = 0;
|
||||
}
|
||||
else if (g->howto->type == 7)
|
||||
{
|
||||
r_length = 3;
|
||||
r_pcrel = 1;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* For a standard reloc, the addend is in the object file. */
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
#endif
|
||||
|
||||
/* name was clobbered by aout_write_syms to be symbol index */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here
|
||||
*/
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| output_section == &bfd_abs_section
|
||||
|| output_section == &bfd_und_section)
|
||||
{
|
||||
if (bfd_abs_section.symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol */
|
||||
r_extern = 1;
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
/* now the fun stuff */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
natptr->r_index[0] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[2] = r_index;
|
||||
natptr->r_type[0] =
|
||||
( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_BFD_TARGET
|
||||
|
||||
#include "aout-target.h"
|
||||
|
||||
const bfd_target aout_arm_little_vec =
|
||||
{
|
||||
"a.out-arm-little", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* target byte order (little) */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
(PTR) MY_backend_data,
|
||||
};
|
||||
|
||||
const bfd_target aout_arm_big_vec =
|
||||
{
|
||||
"a.out-arm-big", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order (big) */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order (big) */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
(PTR) MY_backend_data,
|
||||
};
|
@ -1,236 +0,0 @@
|
||||
/* BFD back-end for a.out files encapsulated with COFF headers.
|
||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */
|
||||
|
||||
#if 0
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define TEXT_START_ADDR 0
|
||||
#define BYTES_IN_WORD 4
|
||||
#endif
|
||||
|
||||
#include "bfd.h"
|
||||
#include <sysdep.h>
|
||||
#include "libbfd.h"
|
||||
#include <aout/aout64.h>
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
const bfd_target *encap_real_callback ();
|
||||
|
||||
const bfd_target *
|
||||
encap_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
|
||||
unsigned long magic; /* Swapped magic number */
|
||||
short coff_magic;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec exec;
|
||||
|
||||
if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
|
||||
sizeof (magicbuf))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
coff_magic = bfd_h_get_16 (abfd, magicbuf);
|
||||
if (coff_magic != COFF_MAGIC)
|
||||
return 0; /* Not an encap coff file */
|
||||
|
||||
__header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
|
||||
(fseek ((f), HEADER_OFFSET((f)), 1))
|
||||
|
||||
magic = bfd_h_get_32 (abfd, magicbuf);
|
||||
|
||||
if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
|
||||
|
||||
struct external_exec exec_bytes;
|
||||
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE) {
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
|
||||
|
||||
return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
|
||||
}
|
||||
|
||||
/* Finish up the reading of a encapsulated-coff a.out file header */
|
||||
const bfd_target *
|
||||
encap_real_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
MY(callback)(abfd, execp);
|
||||
|
||||
/* If we have a coff header, it can give us better values for
|
||||
text_start and exec_data_start. This is particularly useful
|
||||
for remote debugging of embedded systems. */
|
||||
if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
|
||||
{
|
||||
struct coffheader ch;
|
||||
int val;
|
||||
val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
|
||||
if (val == -1)
|
||||
perror_with_name (filename);
|
||||
val = myread (execchan, &ch, sizeof (ch));
|
||||
if (val < 0)
|
||||
perror_with_name (filename);
|
||||
text_start = ch.text_start;
|
||||
exec_data_start = ch.data_start;
|
||||
} else
|
||||
{
|
||||
text_start =
|
||||
IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
|
||||
exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
|
||||
? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
|
||||
}
|
||||
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
/* Write an object file in Encapsulated COFF format.
|
||||
Section contents have already been written. We write the
|
||||
file header, symbols, and relocation. */
|
||||
|
||||
boolean
|
||||
encap_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
bfd_size_type data_pad = 0;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/****** FIXME: Fragments from the old GNU LD program for dealing with
|
||||
encap coff. */
|
||||
struct coffheader coffheader;
|
||||
int need_coff_header;
|
||||
|
||||
/* Determine whether to count the header as part of
|
||||
the text size, and initialize the text size accordingly.
|
||||
This depends on the kind of system and on the output format selected. */
|
||||
|
||||
N_SET_MAGIC (outheader, magic);
|
||||
#ifdef INITIALIZE_HEADER
|
||||
INITIALIZE_HEADER;
|
||||
#endif
|
||||
|
||||
text_size = sizeof (struct exec);
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (relocatable_output == 0 && file_table[0].just_syms_flag == 0)
|
||||
{
|
||||
need_coff_header = 1;
|
||||
/* set this flag now, since it will change the values of N_TXTOFF, etc */
|
||||
N_SET_FLAGS (outheader, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
text_size += sizeof (struct coffheader);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (need_coff_header)
|
||||
{
|
||||
/* We are encapsulating BSD format within COFF format. */
|
||||
struct coffscn *tp, *dp, *bp;
|
||||
|
||||
tp = &coffheader.scns[0];
|
||||
dp = &coffheader.scns[1];
|
||||
bp = &coffheader.scns[2];
|
||||
|
||||
strcpy (tp->s_name, ".text");
|
||||
tp->s_paddr = text_start;
|
||||
tp->s_vaddr = text_start;
|
||||
tp->s_size = text_size;
|
||||
tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec);
|
||||
tp->s_relptr = 0;
|
||||
tp->s_lnnoptr = 0;
|
||||
tp->s_nreloc = 0;
|
||||
tp->s_nlnno = 0;
|
||||
tp->s_flags = 0x20;
|
||||
strcpy (dp->s_name, ".data");
|
||||
dp->s_paddr = data_start;
|
||||
dp->s_vaddr = data_start;
|
||||
dp->s_size = data_size;
|
||||
dp->s_scnptr = tp->s_scnptr + tp->s_size;
|
||||
dp->s_relptr = 0;
|
||||
dp->s_lnnoptr = 0;
|
||||
dp->s_nreloc = 0;
|
||||
dp->s_nlnno = 0;
|
||||
dp->s_flags = 0x40;
|
||||
strcpy (bp->s_name, ".bss");
|
||||
bp->s_paddr = dp->s_vaddr + dp->s_size;
|
||||
bp->s_vaddr = bp->s_paddr;
|
||||
bp->s_size = bss_size;
|
||||
bp->s_scnptr = 0;
|
||||
bp->s_relptr = 0;
|
||||
bp->s_lnnoptr = 0;
|
||||
bp->s_nreloc = 0;
|
||||
bp->s_nlnno = 0;
|
||||
bp->s_flags = 0x80;
|
||||
|
||||
coffheader.f_magic = COFF_MAGIC;
|
||||
coffheader.f_nscns = 3;
|
||||
/* store an unlikely time so programs can
|
||||
* tell that there is a bsd header
|
||||
*/
|
||||
coffheader.f_timdat = 1;
|
||||
coffheader.f_symptr = 0;
|
||||
coffheader.f_nsyms = 0;
|
||||
coffheader.f_opthdr = 28;
|
||||
coffheader.f_flags = 0x103;
|
||||
/* aouthdr */
|
||||
coffheader.magic = ZMAGIC;
|
||||
coffheader.vstamp = 0;
|
||||
coffheader.tsize = tp->s_size;
|
||||
coffheader.dsize = dp->s_size;
|
||||
coffheader.bsize = bp->s_size;
|
||||
coffheader.entry = outheader.a_entry;
|
||||
coffheader.text_start = tp->s_vaddr;
|
||||
coffheader.data_start = dp->s_vaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (need_coff_header)
|
||||
mywrite (&coffheader, sizeof coffheader, 1, outdesc);
|
||||
#endif
|
||||
|
||||
#ifndef COFF_ENCAPSULATE
|
||||
padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc);
|
||||
#endif
|
||||
|
||||
text_size -= N_TXTOFF (outheader);
|
||||
WRITE_HEADERS(abfd, execp);
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MY_write_object_content encap_write_object_contents
|
||||
#define MY_object_p encap_object_p
|
||||
#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
|
||||
|
||||
#include "aout-target.h"
|
@ -1,399 +0,0 @@
|
||||
/* BFD back-end for ns32k a.out-ish binaries.
|
||||
Copyright (C) 1990, 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
|
||||
Contributed by Ian Dall (idall@eleceng.adelaide.edu.au).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
|
||||
#include "bfd.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
#define MYNS(OP) CAT(ns32kaout_,OP)
|
||||
reloc_howto_type *
|
||||
MYNS(bfd_reloc_type_lookup)
|
||||
PARAMS((bfd *abfd AND
|
||||
bfd_reloc_code_real_type code));
|
||||
|
||||
boolean
|
||||
MYNS(write_object_contents)
|
||||
PARAMS((bfd *abfd));
|
||||
|
||||
/* Avoid multiple definitions from aoutx if supporting standard a.out format(s)
|
||||
* as well as this one
|
||||
*/
|
||||
#define NAME(x,y) CAT3(ns32kaout,_32_,y)
|
||||
|
||||
void bfd_ns32k_arch PARAMS ((void));
|
||||
long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||
int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||
long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||
int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
|
||||
struct symbol_cache_entry *symbol,
|
||||
PTR data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message));
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_imm PARAMS ((bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
struct symbol_cache_entry *symbol,
|
||||
PTR data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message));
|
||||
bfd_reloc_status_type
|
||||
ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
asection *input_section,
|
||||
bfd_byte *contents,
|
||||
bfd_vma address,
|
||||
bfd_vma value,
|
||||
bfd_vma addend ));
|
||||
bfd_reloc_status_type
|
||||
ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
bfd_vma relocation,
|
||||
bfd_byte *location));
|
||||
|
||||
#include "libaout.h"
|
||||
|
||||
#define MY(OP) MYNS(OP)
|
||||
|
||||
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes,
|
||||
arelent *cache_ptr, asymbol **symbols,
|
||||
bfd_size_type symcount));
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g,
|
||||
struct reloc_std_external *natptr));
|
||||
|
||||
/* The ns32k series is ah, unusual, when it comes to relocation.
|
||||
* There are three storage methods for relocateable objects. There
|
||||
* are displacements, immediate operands and ordinary twos complement
|
||||
* data. Of these, only the last fits into the standard relocation
|
||||
* scheme. Immediate operands are stored huffman encoded and
|
||||
* immediate operands are stored big endian (where as the natural byte
|
||||
* order is little endian for this achitecture).
|
||||
|
||||
* Note that the ns32k displacement storage method is orthogonal to
|
||||
* whether the relocation is pc relative or not. The "displacement"
|
||||
* storage scheme is used for essentially all address constants. The
|
||||
* displacement can be relative to zero (absolute displacement),
|
||||
* relative to the pc (pc relative), the stack pointer, the frame
|
||||
* pointer, the static base register and general purpose register etc.
|
||||
|
||||
* For example:
|
||||
*
|
||||
* sym1: .long . # pc relative 2's complement
|
||||
* sym1: .long foo # 2's complement not pc relative
|
||||
*
|
||||
* self: movd @self, r0 # pc relative displacement
|
||||
* movd foo, r0 # non pc relative displacement
|
||||
*
|
||||
* self: movd self, r0 # pc relative immediate
|
||||
* movd foo, r0 # non pc relative immediate
|
||||
*
|
||||
* In addition, for historical reasons the encoding of the relocation types
|
||||
* in the a.out format relocation entries is such that even the relocation
|
||||
* methods which are standard are not encoded the standard way.
|
||||
*
|
||||
*/
|
||||
|
||||
reloc_howto_type MY(howto_table)[] =
|
||||
{
|
||||
/* ns32k immediate operands */
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true,
|
||||
ns32k_reloc_imm, "NS32K_IMM_8",
|
||||
true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true,
|
||||
ns32k_reloc_imm, "NS32K_IMM_16",
|
||||
true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true,
|
||||
ns32k_reloc_imm, "NS32K_IMM_32",
|
||||
true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false,
|
||||
ns32k_reloc_imm, "PCREL_NS32K_IMM_8",
|
||||
true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false,
|
||||
ns32k_reloc_imm, "PCREL_NS32K_IMM_16",
|
||||
true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false,
|
||||
ns32k_reloc_imm, "PCREL_NS32K_IMM_32",
|
||||
true, 0xffffffff,0xffffffff, false),
|
||||
|
||||
/* ns32k displacements */
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true,
|
||||
ns32k_reloc_disp, "NS32K_DISP_8",
|
||||
true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true,
|
||||
ns32k_reloc_disp, "NS32K_DISP_16",
|
||||
true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true,
|
||||
ns32k_reloc_disp, "NS32K_DISP_32",
|
||||
true, 0xffffffff, 0xffffffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false,
|
||||
ns32k_reloc_disp, "PCREL_NS32K_DISP_8",
|
||||
true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false,
|
||||
ns32k_reloc_disp, "PCREL_NS32K_DISP_16",
|
||||
true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false,
|
||||
ns32k_reloc_disp, "PCREL_NS32K_DISP_32",
|
||||
true, 0xffffffff,0xffffffff, false),
|
||||
|
||||
/* Normal 2's complement */
|
||||
HOWTO(BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,
|
||||
"8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,
|
||||
"16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,
|
||||
"32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0,
|
||||
"PCREL_8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0,
|
||||
"PCREL_16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0,
|
||||
"PCREL_32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
|
||||
|
||||
#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14)
|
||||
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_BIG 0x06
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_LITTLE 0x60
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_SH_BIG 1
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE 5
|
||||
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *rel;
|
||||
int *r_index;
|
||||
int *r_extern;
|
||||
int *r_pcrel;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_ns32k_type;
|
||||
/* BFD_ASSERT(bfd_header_little_endian (abfd)); */
|
||||
*r_index = ((rel->r_index[2] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[0] );
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||
*r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
r_ns32k_type = ((rel->r_type[0] & RELOC_STD_BITS_NS32K_TYPE_LITTLE)
|
||||
>> RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||
return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
|
||||
}
|
||||
|
||||
#define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto)(BFD, REL, &IN, &EX, &PC)
|
||||
|
||||
void
|
||||
MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
|
||||
bfd *abfd;
|
||||
int r_extern;
|
||||
int r_index;
|
||||
long value;
|
||||
reloc_howto_type *howto;
|
||||
struct reloc_std_external *reloc;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_ns32k_type;
|
||||
PUT_WORD (abfd, value, reloc->r_address);
|
||||
r_length = howto->size ; /* Size as a power of two */
|
||||
r_pcrel = (int) howto->pc_relative; /* Relative to PC? */
|
||||
r_ns32k_type = (howto - MY(howto_table) )/6;
|
||||
/* BFD_ASSERT (bfd_header_little_endian (abfd)); */
|
||||
reloc->r_index[2] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[0] = r_index;
|
||||
reloc->r_type[0] =
|
||||
(r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||
| (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)
|
||||
| (r_ns32k_type << RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||
}
|
||||
|
||||
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||
MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||
|
||||
#define STAT_FOR_EXEC
|
||||
|
||||
#define MY_final_link_relocate ns32k_final_link_relocate
|
||||
#define MY_relocate_contents ns32k_relocate_contents
|
||||
|
||||
#include <aoutx.h>
|
||||
|
||||
reloc_howto_type *
|
||||
MY(bfd_reloc_type_lookup)(abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
|
||||
#define ENTRY(i,j) case i: return &MY(howto_table)[j]
|
||||
|
||||
int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
|
||||
|
||||
BFD_ASSERT(ext == 0);
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
}
|
||||
switch (code)
|
||||
{
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_8, 0);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_16, 1);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_32, 2);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_8_PCREL, 3);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_16_PCREL, 4);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_32_PCREL, 5);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_8, 6);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_16, 7);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_32, 8);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_8_PCREL, 9);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_16_PCREL, 10);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_32_PCREL, 11);
|
||||
ENTRY(BFD_RELOC_8, 12);
|
||||
ENTRY(BFD_RELOC_16, 13);
|
||||
ENTRY(BFD_RELOC_32, 14);
|
||||
ENTRY(BFD_RELOC_8_PCREL, 15);
|
||||
ENTRY(BFD_RELOC_16_PCREL, 16);
|
||||
ENTRY(BFD_RELOC_32_PCREL, 17);
|
||||
default: return (reloc_howto_type *) NULL;
|
||||
}
|
||||
#undef ENTRY
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||
|
||||
/* now the fun stuff */
|
||||
|
||||
cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel);
|
||||
|
||||
MOVE_ADDRESS(0);
|
||||
}
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
unsigned int r_addend;
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
/* name was clobbered by aout_write_syms to be symbol index */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
Check for that here. */
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| output_section == &bfd_abs_section
|
||||
|| output_section == &bfd_und_section)
|
||||
{
|
||||
if (bfd_abs_section.symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol */
|
||||
r_extern = 1;
|
||||
#undef KEEPIT
|
||||
#define KEEPIT udata.i
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
#undef KEEPIT
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
MY_put_reloc (abfd, r_extern, r_index, g->address, g->howto, natptr);
|
||||
}
|
||||
|
||||
bfd_reloc_status_type
|
||||
ns32k_relocate_contents (howto, input_bfd, relocation, location)
|
||||
reloc_howto_type *howto;
|
||||
bfd *input_bfd;
|
||||
bfd_vma relocation;
|
||||
bfd_byte *location;
|
||||
{
|
||||
int r_ns32k_type = (howto - MY(howto_table)) / 6;
|
||||
long (*get_data)();
|
||||
int (*put_data)();
|
||||
|
||||
switch (r_ns32k_type)
|
||||
{
|
||||
case 0:
|
||||
get_data = ns32k_get_immediate;
|
||||
put_data = ns32k_put_immediate;
|
||||
break;
|
||||
case 1:
|
||||
get_data = ns32k_get_displacement;
|
||||
put_data = ns32k_put_displacement;
|
||||
break;
|
||||
case 2:
|
||||
return _bfd_relocate_contents (howto, input_bfd, relocation,
|
||||
location);
|
||||
/* NOT REACHED */
|
||||
break;
|
||||
}
|
||||
return do_ns32k_reloc_contents (howto, input_bfd, relocation,
|
||||
location, get_data, put_data);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/* BFD backend for SunOS style a.out with flags set to 0
|
||||
Copyright (C) 1990, 91, 92, 93, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGETNAME "a.out-zero-big"
|
||||
#define MY(OP) CAT(aout0_big_,OP)
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
#define MY_exec_hdr_flags 0
|
||||
|
||||
#define MACHTYPE_OK(mtype) \
|
||||
((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020)
|
||||
|
||||
/* Include the usual a.out support. */
|
||||
#include "aoutf1.h"
|
@ -1,31 +0,0 @@
|
||||
/* BFD back-end for 64-bit a.out files.
|
||||
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 64
|
||||
|
||||
/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
|
||||
#ifndef BMAGIC
|
||||
#define BMAGIC 0
|
||||
#endif
|
||||
#ifndef QMAGIC
|
||||
#define QMAGIC 0
|
||||
#endif
|
||||
|
||||
#include "aoutx.h"
|
@ -1,788 +0,0 @@
|
||||
/* A.out "format 1" file handling code for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "aout/sun4.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
|
||||
/* This is needed to reject a NewsOS file, e.g. in
|
||||
gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
|
||||
I needed to add M_UNKNOWN to recognize a 68000 object, so this will
|
||||
probably no longer reject a NewsOS object. <ian@cygnus.com>. */
|
||||
#ifndef MACHTYPE_OK
|
||||
#define MACHTYPE_OK(mtype) \
|
||||
(((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
|
||||
|| (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
|
||||
&& bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
|
||||
#endif
|
||||
|
||||
/*
|
||||
The file @code{aoutf1.h} contains the code for BFD's
|
||||
a.out back end. Control over the generated back end is given by these
|
||||
two preprocessor names:
|
||||
@table @code
|
||||
@item ARCH_SIZE
|
||||
This value should be either 32 or 64, depending upon the size of an
|
||||
int in the target format. It changes the sizes of the structs which
|
||||
perform the memory/disk mapping of structures.
|
||||
|
||||
The 64 bit backend may only be used if the host compiler supports 64
|
||||
ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
|
||||
With this name defined, @emph{all} bfd operations are performed with 64bit
|
||||
arithmetic, not just those to a 64bit target.
|
||||
|
||||
@item TARGETNAME
|
||||
The name put into the target vector.
|
||||
@item
|
||||
@end table
|
||||
|
||||
*/
|
||||
|
||||
/*SUPPRESS558*/
|
||||
/*SUPPRESS529*/
|
||||
|
||||
static void
|
||||
#if ARCH_SIZE == 64
|
||||
sunos_64_set_arch_mach
|
||||
#else
|
||||
sunos_32_set_arch_mach
|
||||
#endif
|
||||
(abfd, machtype)
|
||||
bfd *abfd;
|
||||
int machtype;
|
||||
{
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
enum bfd_architecture arch;
|
||||
long machine;
|
||||
switch (machtype)
|
||||
{
|
||||
|
||||
case M_UNKNOWN:
|
||||
/* Some Sun3s make magic numbers without cpu types in them, so
|
||||
we'll default to the 68000. */
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 68000;
|
||||
break;
|
||||
|
||||
case M_68010:
|
||||
case M_HP200:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 68010;
|
||||
break;
|
||||
|
||||
case M_68020:
|
||||
case M_HP300:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 68020;
|
||||
break;
|
||||
|
||||
case M_SPARC:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_386:
|
||||
case M_386_DYNIX:
|
||||
arch = bfd_arch_i386;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_29K:
|
||||
arch = bfd_arch_a29k;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_HPUX:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
arch = bfd_arch_obscure;
|
||||
machine = 0;
|
||||
break;
|
||||
}
|
||||
bfd_set_arch_mach (abfd, arch, machine);
|
||||
}
|
||||
|
||||
#define SET_ARCH_MACH(ABFD, EXEC) \
|
||||
NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
|
||||
choose_reloc_size(ABFD);
|
||||
|
||||
/* Determine the size of a relocation entry, based on the architecture */
|
||||
static void
|
||||
choose_reloc_size (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_sparc:
|
||||
case bfd_arch_a29k:
|
||||
obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
|
||||
break;
|
||||
default:
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write an object file in SunOS format.
|
||||
Section contents have already been written. We write the
|
||||
file header, symbols, and relocation. */
|
||||
|
||||
static boolean
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_sunos4_write_object_contents
|
||||
#else
|
||||
aout_32_sunos4_write_object_contents
|
||||
#endif
|
||||
(abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* Magic number, maestro, please! */
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_m68k:
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
case 68000:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
break;
|
||||
case 68010:
|
||||
N_SET_MACHTYPE (*execp, M_68010);
|
||||
break;
|
||||
default:
|
||||
case 68020:
|
||||
N_SET_MACHTYPE (*execp, M_68020);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case bfd_arch_sparc:
|
||||
N_SET_MACHTYPE (*execp, M_SPARC);
|
||||
break;
|
||||
case bfd_arch_i386:
|
||||
N_SET_MACHTYPE (*execp, M_386);
|
||||
break;
|
||||
case bfd_arch_a29k:
|
||||
N_SET_MACHTYPE (*execp, M_29K);
|
||||
break;
|
||||
default:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
}
|
||||
|
||||
choose_reloc_size (abfd);
|
||||
|
||||
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
|
||||
N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
|
||||
|
||||
WRITE_HEADERS (abfd, execp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* core files */
|
||||
|
||||
#define CORE_MAGIC 0x080456
|
||||
#define CORE_NAMELEN 16
|
||||
|
||||
/* The core structure is taken from the Sun documentation.
|
||||
Unfortunately, they don't document the FPA structure, or at least I
|
||||
can't find it easily. Fortunately the core header contains its own
|
||||
length. So this shouldn't cause problems, except for c_ucode, which
|
||||
so far we don't use but is easy to find with a little arithmetic. */
|
||||
|
||||
/* But the reg structure can be gotten from the SPARC processor handbook.
|
||||
This really should be in a GNU include file though so that gdb can use
|
||||
the same info. */
|
||||
struct regs
|
||||
{
|
||||
int r_psr;
|
||||
int r_pc;
|
||||
int r_npc;
|
||||
int r_y;
|
||||
int r_g1;
|
||||
int r_g2;
|
||||
int r_g3;
|
||||
int r_g4;
|
||||
int r_g5;
|
||||
int r_g6;
|
||||
int r_g7;
|
||||
int r_o0;
|
||||
int r_o1;
|
||||
int r_o2;
|
||||
int r_o3;
|
||||
int r_o4;
|
||||
int r_o5;
|
||||
int r_o6;
|
||||
int r_o7;
|
||||
};
|
||||
|
||||
/* Taken from Sun documentation: */
|
||||
|
||||
/* FIXME: It's worse than we expect. This struct contains TWO substructs
|
||||
neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
|
||||
even portably access the stuff in between! */
|
||||
|
||||
struct external_sparc_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SPARC_CORE_LEN 432
|
||||
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||
struct external_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
/* Core files generated by the BCP (the part of Solaris which allows
|
||||
it to run SunOS4 a.out files). */
|
||||
struct external_solaris_bcp_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SOLARIS_BCP_CORE_LEN 456
|
||||
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||
int c_exdata_vp; /* exdata structure */
|
||||
int c_exdata_tsize;
|
||||
int c_exdata_dsize;
|
||||
int c_exdata_bsize;
|
||||
int c_exdata_lsize;
|
||||
int c_exdata_nshlibs;
|
||||
short c_exdata_mach;
|
||||
short c_exdata_mag;
|
||||
int c_exdata_toffset;
|
||||
int c_exdata_doffset;
|
||||
int c_exdata_loffset;
|
||||
int c_exdata_txtorg;
|
||||
int c_exdata_datorg;
|
||||
int c_exdata_entloc;
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
struct external_sun3_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
|
||||
int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
|
||||
struct external_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
struct internal_sunos_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
long c_regs_pos; /* file offset of General purpose registers */
|
||||
int c_regs_size; /* size of General purpose registers */
|
||||
struct internal_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
bfd_vma c_data_addr; /* Data start (address) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
bfd_vma c_stacktop; /* Stack top (address) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
long fp_stuff_pos; /* file offset of external FPU state (regs) */
|
||||
int fp_stuff_size; /* Size of it */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
};
|
||||
|
||||
/* byte-swap in the Sun-3 core structure */
|
||||
static void
|
||||
swapcore_sun3 (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
|
||||
|
||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_swap_exec_header_in
|
||||
#else
|
||||
aout_32_swap_exec_header_in
|
||||
#endif
|
||||
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode =
|
||||
bfd_h_get_32 (abfd,
|
||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||
intcore->c_stacktop = 0x0E000000; /* By experimentation */
|
||||
}
|
||||
|
||||
|
||||
/* byte-swap in the Sparc core structure */
|
||||
static void
|
||||
swapcore_sparc (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
|
||||
|
||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_swap_exec_header_in
|
||||
#else
|
||||
aout_32_swap_exec_header_in
|
||||
#endif
|
||||
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode =
|
||||
bfd_h_get_32 (abfd,
|
||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||
|
||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||
Presuming that this remains true, this definition will work. */
|
||||
/* Now sun has provided us with another challenge. The value is different
|
||||
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||
the other based on the current value of the stack pointer. This
|
||||
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||
is larger than 128 megabytes.
|
||||
|
||||
It's times like these you're glad they're switching to ELF.
|
||||
|
||||
Note that using include files or nlist on /vmunix would be wrong,
|
||||
because we want the value for this core file, no matter what kind of
|
||||
machine we were compiled on or are running on. */
|
||||
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||
{
|
||||
bfd_vma sp = bfd_h_get_32
|
||||
(abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||
if (sp < SPARC_USRSTACK_SPARC10)
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||
else
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||
}
|
||||
}
|
||||
|
||||
/* byte-swap in the Solaris BCP core structure */
|
||||
static void
|
||||
swapcore_solaris_bcp (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_solaris_bcp_core *extcore =
|
||||
(struct external_solaris_bcp_core *) ext;
|
||||
|
||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
|
||||
/* The Solaris BCP exdata structure does not contain an a_syms field,
|
||||
so we are unable to synthesize an internal exec header.
|
||||
Luckily we are able to figure out the start address of the data section,
|
||||
which is the only thing needed from the internal exec header,
|
||||
from the exdata structure.
|
||||
|
||||
As of Solaris 2.3, BCP core files for statically linked executables
|
||||
are buggy. The exdata structure is not properly filled in, and
|
||||
the data section is written from address zero instead of the data
|
||||
start address. */
|
||||
memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
|
||||
intcore->c_data_addr =
|
||||
bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
|
||||
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos =
|
||||
(long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode =
|
||||
bfd_h_get_32 (abfd,
|
||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||
|
||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||
Presuming that this remains true, this definition will work. */
|
||||
/* Now sun has provided us with another challenge. The value is different
|
||||
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||
the other based on the current value of the stack pointer. This
|
||||
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||
is larger than 128 megabytes.
|
||||
|
||||
It's times like these you're glad they're switching to ELF.
|
||||
|
||||
Note that using include files or nlist on /vmunix would be wrong,
|
||||
because we want the value for this core file, no matter what kind of
|
||||
machine we were compiled on or are running on. */
|
||||
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||
{
|
||||
bfd_vma sp = bfd_h_get_32
|
||||
(abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||
if (sp < SPARC_USRSTACK_SPARC10)
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||
else
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||
}
|
||||
}
|
||||
|
||||
/* need this cast because ptr is really void * */
|
||||
#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
|
||||
#define core_datasec(bfd) (core_hdr(bfd)->data_section)
|
||||
#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
|
||||
#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
|
||||
#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
struct sun_core_struct
|
||||
{
|
||||
struct internal_sunos_core *hdr; /* core file header */
|
||||
asection *data_section;
|
||||
asection *stack_section;
|
||||
asection *reg_section;
|
||||
asection *reg2_section;
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
sunos4_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
bfd_size_type core_size;
|
||||
unsigned long core_mag;
|
||||
struct internal_sunos_core *core;
|
||||
char *extcore;
|
||||
struct mergem
|
||||
{
|
||||
struct sun_core_struct suncoredata;
|
||||
struct internal_sunos_core internal_sunos_core;
|
||||
char external_core[1];
|
||||
}
|
||||
*mergem;
|
||||
|
||||
if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
|
||||
sizeof (longbuf))
|
||||
return 0;
|
||||
core_mag = bfd_h_get_32 (abfd, longbuf);
|
||||
|
||||
if (core_mag != CORE_MAGIC)
|
||||
return 0;
|
||||
|
||||
/* SunOS core headers can vary in length; second word is size; */
|
||||
if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
|
||||
sizeof (longbuf))
|
||||
return 0;
|
||||
core_size = bfd_h_get_32 (abfd, longbuf);
|
||||
/* Sanity check */
|
||||
if (core_size > 20000)
|
||||
return 0;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
|
||||
return 0;
|
||||
|
||||
mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
extcore = mergem->external_core;
|
||||
|
||||
if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
|
||||
{
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate that it's a core file we know how to handle, due to sun
|
||||
botching the positioning of registers and other fields in a machine
|
||||
dependent way. */
|
||||
core = &mergem->internal_sunos_core;
|
||||
switch (core_size)
|
||||
{
|
||||
case SPARC_CORE_LEN:
|
||||
swapcore_sparc (abfd, extcore, core);
|
||||
break;
|
||||
case SUN3_CORE_LEN:
|
||||
swapcore_sun3 (abfd, extcore, core);
|
||||
break;
|
||||
case SOLARIS_BCP_CORE_LEN:
|
||||
swapcore_solaris_bcp (abfd, extcore, core);
|
||||
break;
|
||||
default:
|
||||
bfd_set_error (bfd_error_system_call); /* FIXME */
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
abfd->tdata.sun_core_data = &mergem->suncoredata;
|
||||
abfd->tdata.sun_core_data->hdr = core;
|
||||
|
||||
/* create the sections. This is raunchy, but bfd_close wants to reclaim
|
||||
them */
|
||||
core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_stacksec (abfd) == NULL)
|
||||
{
|
||||
loser:
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
return 0;
|
||||
}
|
||||
core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_datasec (abfd) == NULL)
|
||||
{
|
||||
loser1:
|
||||
bfd_release (abfd, core_stacksec (abfd));
|
||||
goto loser;
|
||||
}
|
||||
core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_regsec (abfd) == NULL)
|
||||
{
|
||||
loser2:
|
||||
bfd_release (abfd, core_datasec (abfd));
|
||||
goto loser1;
|
||||
}
|
||||
core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
{
|
||||
bfd_release (abfd, core_regsec (abfd));
|
||||
goto loser2;
|
||||
}
|
||||
|
||||
core_stacksec (abfd)->name = ".stack";
|
||||
core_datasec (abfd)->name = ".data";
|
||||
core_regsec (abfd)->name = ".reg";
|
||||
core_reg2sec (abfd)->name = ".reg2";
|
||||
|
||||
core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
|
||||
core_stacksec (abfd)->_raw_size = core->c_ssize;
|
||||
core_datasec (abfd)->_raw_size = core->c_dsize;
|
||||
core_regsec (abfd)->_raw_size = core->c_regs_size;
|
||||
core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
|
||||
|
||||
core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
|
||||
core_datasec (abfd)->vma = core->c_data_addr;
|
||||
core_regsec (abfd)->vma = 0;
|
||||
core_reg2sec (abfd)->vma = 0;
|
||||
|
||||
core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
|
||||
core_datasec (abfd)->filepos = core->c_len;
|
||||
/* We'll access the regs afresh in the core file, like any section: */
|
||||
core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
|
||||
core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;
|
||||
|
||||
/* Align to word at least */
|
||||
core_stacksec (abfd)->alignment_power = 2;
|
||||
core_datasec (abfd)->alignment_power = 2;
|
||||
core_regsec (abfd)->alignment_power = 2;
|
||||
core_reg2sec (abfd)->alignment_power = 2;
|
||||
|
||||
abfd->sections = core_stacksec (abfd);
|
||||
core_stacksec (abfd)->next = core_datasec (abfd);
|
||||
core_datasec (abfd)->next = core_regsec (abfd);
|
||||
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||
|
||||
abfd->section_count = 4;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
sunos4_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_cmdname;
|
||||
}
|
||||
|
||||
static int
|
||||
sunos4_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_signo;
|
||||
}
|
||||
|
||||
static boolean
|
||||
sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
if (core_bfd->xvec != exec_bfd->xvec)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Solaris core files do not include an aouthdr. */
|
||||
if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
|
||||
return true;
|
||||
|
||||
return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
|
||||
(char *) exec_hdr (exec_bfd),
|
||||
sizeof (struct internal_exec)) == 0) ? true : false;
|
||||
}
|
||||
|
||||
#define MY_set_sizes sunos4_set_sizes
|
||||
static boolean
|
||||
sunos4_set_sizes (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
default:
|
||||
return false;
|
||||
case bfd_arch_sparc:
|
||||
adata (abfd).page_size = 0x2000;
|
||||
adata (abfd).segment_size = 0x2000;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return true;
|
||||
case bfd_arch_m68k:
|
||||
adata (abfd).page_size = 0x2000;
|
||||
adata (abfd).segment_size = 0x20000;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* We default to setting the toolversion field to 1, as is required by
|
||||
SunOS. */
|
||||
#ifndef MY_exec_hdr_flags
|
||||
#define MY_exec_hdr_flags 1
|
||||
#endif
|
||||
|
||||
#ifndef MY_add_dynamic_symbols
|
||||
#define MY_add_dynamic_symbols 0
|
||||
#endif
|
||||
#ifndef MY_add_one_symbol
|
||||
#define MY_add_one_symbol 0
|
||||
#endif
|
||||
#ifndef MY_link_dynamic_object
|
||||
#define MY_link_dynamic_object 0
|
||||
#endif
|
||||
#ifndef MY_write_dynamic_symbol
|
||||
#define MY_write_dynamic_symbol 0
|
||||
#endif
|
||||
#ifndef MY_check_dynamic_reloc
|
||||
#define MY_check_dynamic_reloc 0
|
||||
#endif
|
||||
#ifndef MY_finish_dynamic_link
|
||||
#define MY_finish_dynamic_link 0
|
||||
#endif
|
||||
|
||||
static CONST struct aout_backend_data sunos4_aout_backend =
|
||||
{
|
||||
0, /* zmagic files are not contiguous */
|
||||
1, /* text includes header */
|
||||
MY_exec_hdr_flags,
|
||||
0, /* default text vma */
|
||||
sunos4_set_sizes,
|
||||
0, /* header is counted in zmagic text */
|
||||
MY_add_dynamic_symbols,
|
||||
MY_add_one_symbol,
|
||||
MY_link_dynamic_object,
|
||||
MY_write_dynamic_symbol,
|
||||
MY_check_dynamic_reloc,
|
||||
MY_finish_dynamic_link
|
||||
};
|
||||
|
||||
#define MY_core_file_failing_command sunos4_core_file_failing_command
|
||||
#define MY_core_file_failing_signal sunos4_core_file_failing_signal
|
||||
#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
|
||||
|
||||
#define MY_bfd_debug_info_start bfd_void
|
||||
#define MY_bfd_debug_info_end bfd_void
|
||||
#define MY_bfd_debug_info_accumulate \
|
||||
(void (*) PARAMS ((bfd *, struct sec *))) bfd_void
|
||||
#define MY_core_file_p sunos4_core_file_p
|
||||
#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
|
||||
#define MY_backend_data &sunos4_aout_backend
|
||||
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
|
||||
#include "aout-target.h"
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@
|
||||
/* BFD back-end for Intel 386 COFF LynxOS files.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#define TARGET_SYM i386lynx_coff_vec
|
||||
#define TARGET_NAME "coff-i386-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-i386.c"
|
@ -1,223 +0,0 @@
|
||||
/* BFD back-end for Motorola M68K COFF LynxOS files.
|
||||
Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68klynx_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table
|
||||
#define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto
|
||||
#define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype
|
||||
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup
|
||||
|
||||
#define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
struct internal_reloc;
|
||||
struct coff_link_hash_entry;
|
||||
struct internal_syment;
|
||||
#endif
|
||||
|
||||
static bfd_reloc_status_type _bfd_m68klynx_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_m68k_lynx_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
/* For some reason when using m68k COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||
for I386 COFF). */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
/* 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
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||
|| reloc.r_type == R_PCRWORD \
|
||||
|| reloc.r_type == R_PCRLONG)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto
|
||||
|
||||
#include "coff-m68k.c"
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols.
|
||||
|
||||
We can't define this function until after we have included
|
||||
coff-m68k.c, because it uses RTYPE2HOWTO. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static reloc_howto_type *
|
||||
coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
BFD_ASSERT (h != NULL);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/* BFD back-end for Sparc COFF LynxOS files.
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM sparclynx_coff_vec
|
||||
#define TARGET_NAME "coff-sparc-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-sparc.c"
|
@ -1,313 +0,0 @@
|
||||
/* BFD back-end for CISCO crash dumps.
|
||||
|
||||
Copyright 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
/* core_file_failing_signal returns a host signal (this probably should
|
||||
be fixed). */
|
||||
#include <signal.h>
|
||||
|
||||
#define CRASH_INFO (0xffc)
|
||||
#define CRASH_MAGIC 0xdead1234
|
||||
|
||||
typedef enum {
|
||||
CRASH_REASON_NOTCRASHED = 0,
|
||||
CRASH_REASON_EXCEPTION = 1,
|
||||
CRASH_REASON_CORRUPT = 2,
|
||||
} crashreason;
|
||||
|
||||
struct crashinfo_external
|
||||
{
|
||||
char magic[4]; /* Magic number */
|
||||
char version[4]; /* Version number */
|
||||
char reason[4]; /* Crash reason */
|
||||
char cpu_vector[4]; /* CPU vector for exceptions */
|
||||
char registers[4]; /* Pointer to saved registers */
|
||||
char rambase[4]; /* Base of RAM (not in V1 crash info) */
|
||||
};
|
||||
|
||||
struct cisco_core_struct
|
||||
{
|
||||
int sig;
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
cisco_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
char buf[4];
|
||||
unsigned int crashinfo_offset;
|
||||
struct crashinfo_external crashinfo;
|
||||
int nread;
|
||||
unsigned int rambase;
|
||||
sec_ptr asect;
|
||||
struct stat statbuf;
|
||||
|
||||
if (bfd_seek (abfd, CRASH_INFO, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
nread = bfd_read (buf, 1, 4, abfd);
|
||||
if (nread != 4)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
crashinfo_offset = bfd_get_32 (abfd, buf);
|
||||
|
||||
if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
|
||||
if (nread != sizeof (crashinfo))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bfd_stat (abfd, &statbuf) < 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bfd_get_32 (abfd, crashinfo.magic) != CRASH_MAGIC)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (bfd_get_32 (abfd, crashinfo.version))
|
||||
{
|
||||
case 0:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
case 1:
|
||||
rambase = 0;
|
||||
break;
|
||||
default:
|
||||
case 2:
|
||||
rambase = bfd_get_32 (abfd, crashinfo.rambase);
|
||||
break;
|
||||
}
|
||||
|
||||
/* OK, we believe you. You're a core file. */
|
||||
|
||||
abfd->tdata.cisco_core_data =
|
||||
((struct cisco_core_struct *)
|
||||
bfd_zmalloc (sizeof (struct cisco_core_struct)));
|
||||
if (abfd->tdata.cisco_core_data == NULL)
|
||||
return NULL;
|
||||
|
||||
switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
|
||||
{
|
||||
case CRASH_REASON_NOTCRASHED:
|
||||
/* Crash file probably came from write core. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
case CRASH_REASON_CORRUPT:
|
||||
/* The crash context area was corrupt -- proceed with caution.
|
||||
We have no way of passing this information back to the caller. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
case CRASH_REASON_EXCEPTION:
|
||||
/* Crash occured due to CPU exception. */
|
||||
|
||||
/* This is 68k-specific; for MIPS we'll need to interpret
|
||||
cpu_vector differently based on the target configuration
|
||||
(since CISCO core files don't seem to have the processor
|
||||
encoded in them). */
|
||||
|
||||
switch (bfd_get_32 (abfd, crashinfo.cpu_vector))
|
||||
{
|
||||
/* bus error */
|
||||
case 2 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||
/* address error */
|
||||
case 3 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||
/* illegal instruction */
|
||||
case 4 : abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||
/* zero divide */
|
||||
case 5 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* chk instruction */
|
||||
case 6 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* trapv instruction */
|
||||
case 7 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* privilege violation */
|
||||
case 8 : abfd->tdata.cisco_core_data->sig = SIGSEGV; break;
|
||||
/* trace trap */
|
||||
case 9 : abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
|
||||
/* line 1010 emulator */
|
||||
case 10: abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||
/* line 1111 emulator */
|
||||
case 11: abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||
|
||||
/* Coprocessor protocol violation. Using a standard MMU or FPU
|
||||
this cannot be triggered by software. Call it a SIGBUS. */
|
||||
case 13: abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||
|
||||
/* interrupt */
|
||||
case 31: abfd->tdata.cisco_core_data->sig = SIGINT; break;
|
||||
/* breakpoint */
|
||||
case 33: abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
|
||||
|
||||
/* floating point err */
|
||||
case 48: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* floating point err */
|
||||
case 49: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* zero divide */
|
||||
case 50: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* underflow */
|
||||
case 51: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* operand error */
|
||||
case 52: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* overflow */
|
||||
case 53: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* NAN */
|
||||
case 54: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
default:
|
||||
/* "software generated"*/
|
||||
abfd->tdata.cisco_core_data->sig = SIGEMT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Unknown crash reason. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
abfd->sections = NULL;
|
||||
abfd->section_count = 0;
|
||||
|
||||
asect = (asection *) bfd_zmalloc (sizeof (asection));
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->name = ".reg";
|
||||
asect->flags = SEC_HAS_CONTENTS;
|
||||
/* This can be bigger than the real size. Set it to the size of the whole
|
||||
core file. */
|
||||
asect->_raw_size = statbuf.st_size;
|
||||
asect->vma = 0;
|
||||
asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
|
||||
asect->next = abfd->sections;
|
||||
abfd->sections = asect;
|
||||
++abfd->section_count;
|
||||
|
||||
/* There is only one section containing data from the target system's RAM.
|
||||
We call it .data. */
|
||||
asect = (asection *) bfd_zmalloc (sizeof (asection));
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->name = ".data";
|
||||
asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
/* The size of memory is the size of the core file itself. */
|
||||
asect->_raw_size = statbuf.st_size;
|
||||
asect->vma = rambase;
|
||||
asect->filepos = 0;
|
||||
asect->next = abfd->sections;
|
||||
abfd->sections = asect;
|
||||
++abfd->section_count;
|
||||
|
||||
return abfd->xvec;
|
||||
|
||||
error_return:
|
||||
{
|
||||
sec_ptr nextsect;
|
||||
for (asect = abfd->sections; asect != NULL;)
|
||||
{
|
||||
nextsect = asect->next;
|
||||
free (asect);
|
||||
asect = nextsect;
|
||||
}
|
||||
free (abfd->tdata.cisco_core_data);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
cisco_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
cisco_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->tdata.cisco_core_data->sig;
|
||||
}
|
||||
|
||||
boolean
|
||||
cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const bfd_target cisco_core_vec =
|
||||
{
|
||||
"trad-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
cisco_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (cisco),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
@ -1,641 +0,0 @@
|
||||
/* BFD back-end for AMD 29000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by David Wood at New York University 7/8/91.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define A29K 1
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/a29k.h"
|
||||
#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 **));
|
||||
static boolean coff_a29k_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static boolean coff_a29k_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, boolean *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#define INSERT_HWORD(WORD,HWORD) \
|
||||
(((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff))
|
||||
#define EXTRACT_HWORD(WORD) \
|
||||
((((WORD) & 0x00ff0000) >> 8) | ((WORD)& 0xff))
|
||||
#define SIGN_EXTEND_HWORD(HWORD) \
|
||||
((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
|
||||
|
||||
/* Provided the symbol, returns the value reffed */
|
||||
static long
|
||||
get_symbol_value (symbol)
|
||||
asymbol *symbol;
|
||||
{
|
||||
long relocation = 0;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
relocation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
relocation = symbol->value +
|
||||
symbol->section->output_section->vma +
|
||||
symbol->section->output_offset;
|
||||
}
|
||||
|
||||
return(relocation);
|
||||
}
|
||||
|
||||
/* this function is in charge of performing all the 29k relocations */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
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 */
|
||||
static boolean part1_consth_active = false;
|
||||
static unsigned long part1_consth_value;
|
||||
|
||||
unsigned long insn;
|
||||
unsigned long sym_value;
|
||||
unsigned long unsigned_value;
|
||||
unsigned short r_type;
|
||||
long signed_value;
|
||||
|
||||
unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
|
||||
bfd_byte *hit_data =addr + (bfd_byte *)(data);
|
||||
|
||||
r_type = reloc_entry->howto->type;
|
||||
|
||||
if (output_bfd) {
|
||||
/* Partial linking - do nothing */
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
|
||||
}
|
||||
|
||||
if (symbol_in != NULL
|
||||
&& bfd_is_und_section (symbol_in->section))
|
||||
{
|
||||
/* Keep the state machine happy in case we're called again */
|
||||
if (r_type == R_IHIHALF)
|
||||
{
|
||||
part1_consth_active = true;
|
||||
part1_consth_value = 0;
|
||||
}
|
||||
return(bfd_reloc_undefined);
|
||||
}
|
||||
|
||||
if ((part1_consth_active) && (r_type != R_IHCONST))
|
||||
{
|
||||
part1_consth_active = false;
|
||||
*error_message = (char *) "Missing IHCONST";
|
||||
return(bfd_reloc_dangerous);
|
||||
}
|
||||
|
||||
|
||||
sym_value = get_symbol_value(symbol_in);
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
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);
|
||||
signed_value = SIGN_EXTEND_HWORD(signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* See the note on the R_IREL reloc in coff_a29k_relocate_section. */
|
||||
if (signed_value == - (long) reloc_entry->address)
|
||||
signed_value = 0;
|
||||
|
||||
signed_value += sym_value + reloc_entry->addend;
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{ /* Absolute jmp/call */
|
||||
insn |= (1<<24); /* Make it absolute */
|
||||
/* FIXME: Should we change r_type to R_IABS */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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);
|
||||
if (signed_value>0x1ffff || signed_value<-0x20000)
|
||||
return(bfd_reloc_overflow);
|
||||
}
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_HWORD(insn, signed_value);
|
||||
bfd_put_32(abfd, insn ,hit_data);
|
||||
break;
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
unsigned_value = EXTRACT_HWORD(insn);
|
||||
unsigned_value += sym_value + reloc_entry->addend;
|
||||
insn = INSERT_HWORD(insn, unsigned_value);
|
||||
bfd_put_32(abfd, insn, hit_data);
|
||||
break;
|
||||
case R_IHIHALF:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
/* consth, part 1
|
||||
Just get the symbol value that is referenced */
|
||||
part1_consth_active = true;
|
||||
part1_consth_value = sym_value + reloc_entry->addend;
|
||||
/* Don't modify insn until R_IHCONST */
|
||||
break;
|
||||
case R_IHCONST:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
/* consth, part 2
|
||||
Now relocate the reference */
|
||||
if (part1_consth_active == false) {
|
||||
*error_message = (char *) "Missing IHIHALF";
|
||||
return(bfd_reloc_dangerous);
|
||||
}
|
||||
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
|
||||
unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
|
||||
unsigned_value += reloc_entry->addend; /* r_symndx */
|
||||
unsigned_value += part1_consth_value;
|
||||
unsigned_value = unsigned_value >> 16;
|
||||
insn = INSERT_HWORD(insn, unsigned_value);
|
||||
part1_consth_active = false;
|
||||
bfd_put_32(abfd, insn, hit_data);
|
||||
break;
|
||||
case R_BYTE:
|
||||
insn = bfd_get_8(abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffffff00)
|
||||
return(bfd_reloc_overflow);
|
||||
bfd_put_8(abfd, unsigned_value, hit_data);
|
||||
break;
|
||||
case R_HWORD:
|
||||
insn = bfd_get_16(abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffff0000)
|
||||
return(bfd_reloc_overflow);
|
||||
bfd_put_16(abfd, insn, hit_data);
|
||||
break;
|
||||
case R_WORD:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
insn += sym_value + reloc_entry->addend;
|
||||
bfd_put_32(abfd, insn, hit_data);
|
||||
break;
|
||||
default:
|
||||
*error_message = "Unrecognized reloc";
|
||||
return (bfd_reloc_dangerous);
|
||||
}
|
||||
|
||||
|
||||
return(bfd_reloc_ok);
|
||||
}
|
||||
|
||||
/* type rightshift
|
||||
size
|
||||
bitsize
|
||||
pc-relative
|
||||
bitpos
|
||||
absolute
|
||||
complain_on_overflow
|
||||
special_function
|
||||
relocation name
|
||||
partial_inplace
|
||||
src_mask
|
||||
*/
|
||||
|
||||
/*FIXME: I'm not real sure about this table */
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{R_ABS, 0, 3, 32, false, 0, complain_overflow_bitfield,a29k_reloc,"ABS", true, 0xffffffff,0xffffffff, false},
|
||||
{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10},
|
||||
{11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20},
|
||||
{21}, {22}, {23},
|
||||
{R_IREL, 0, 3, 32, true, 0, complain_overflow_signed,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false},
|
||||
{R_IABS, 0, 3, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false},
|
||||
{R_ILOHALF, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false},
|
||||
{R_IHIHALF, 0, 3, 16, true, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false},
|
||||
{R_IHCONST, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false},
|
||||
{R_BYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false},
|
||||
{R_HWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false},
|
||||
{R_WORD, 0, 2, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false},
|
||||
};
|
||||
|
||||
#define BADMAG(x) A29KBADMAG(x)
|
||||
|
||||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent,reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
relent->howto = howto_table + reloc->r_type;
|
||||
if (reloc->r_type == R_IHCONST)
|
||||
{
|
||||
/* The address of an R_IHCONST should always be the address of
|
||||
the immediately preceding R_IHIHALF. relocs generated by gas
|
||||
are correct, but relocs generated by High C are different (I
|
||||
can't figure out what the address means for High C). We can
|
||||
handle both gas and High C by ignoring the address here, and
|
||||
simply reusing the address saved for R_IHIHALF. */
|
||||
if (ihihalf_vaddr == (bfd_vma) -1)
|
||||
abort ();
|
||||
relent->address = ihihalf_vaddr;
|
||||
ihihalf_vaddr = (bfd_vma) -1;
|
||||
relent->addend = reloc->r_symndx;
|
||||
relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
asymbol *ptr;
|
||||
relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx];
|
||||
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
|
||||
if (ptr
|
||||
&& bfd_asymbol_bfd(ptr) == abfd
|
||||
|
||||
&& ((ptr->flags & BSF_OLD_COMMON)== 0))
|
||||
{
|
||||
relent->addend = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->addend = 0;
|
||||
}
|
||||
relent->address-= section->vma;
|
||||
if (reloc->r_type == R_IHIHALF)
|
||||
ihihalf_vaddr = relent->address;
|
||||
else if (ihihalf_vaddr != (bfd_vma) -1)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static boolean
|
||||
coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocateable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocateable)
|
||||
return true;
|
||||
|
||||
hihalf = false;
|
||||
hihalf_val = 0;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
bfd_byte *loc;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
asection *sec;
|
||||
bfd_vma val;
|
||||
boolean overflow;
|
||||
unsigned long insn;
|
||||
long signed_value;
|
||||
unsigned long unsigned_value;
|
||||
bfd_reloc_status_type rstat;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
loc = contents + rel->r_vaddr - input_section->vma;
|
||||
|
||||
if (symndx == -1)
|
||||
h = NULL;
|
||||
else
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
|
||||
sym = NULL;
|
||||
sec = NULL;
|
||||
val = 0;
|
||||
|
||||
/* An R_IHCONST reloc does not have a symbol. Instead, the
|
||||
symbol index is an addend. R_IHCONST is always used in
|
||||
conjunction with R_IHHALF. */
|
||||
if (rel->r_type != R_IHCONST)
|
||||
{
|
||||
if (h == NULL)
|
||||
{
|
||||
if (symndx == -1)
|
||||
sec = bfd_abs_section_ptr;
|
||||
else
|
||||
{
|
||||
sym = syms + symndx;
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, "missing IHCONST reloc", input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
hihalf = false;
|
||||
}
|
||||
}
|
||||
|
||||
overflow = false;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
|
||||
case R_IREL:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
|
||||
/* Extract the addend. */
|
||||
signed_value = EXTRACT_HWORD (insn);
|
||||
signed_value = SIGN_EXTEND_HWORD (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* Unfortunately, there are two different versions of COFF
|
||||
a29k. In the original AMD version, the value stored in
|
||||
the field for the R_IREL reloc is a simple addend. In
|
||||
the GNU version, the value is the negative of the address
|
||||
of the reloc within section. We try to cope here by
|
||||
assuming the AMD version, unless the addend is exactly
|
||||
the negative of the address; in the latter case we assume
|
||||
the GNU version. This means that something like
|
||||
.text
|
||||
nop
|
||||
jmp i-4
|
||||
will fail, because the addend of -4 will happen to equal
|
||||
the negative of the address within the section. The
|
||||
compiler will never generate code like this.
|
||||
|
||||
At some point in the future we may want to take out this
|
||||
check. */
|
||||
|
||||
if (signed_value == - (long) (rel->r_vaddr - input_section->vma))
|
||||
signed_value = 0;
|
||||
|
||||
/* Determine the destination of the jump. */
|
||||
signed_value += val;
|
||||
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{
|
||||
/* We can use an absolute jump. */
|
||||
insn |= (1 << 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make the destination PC relative. */
|
||||
signed_value -= (input_section->output_section->vma
|
||||
+ input_section->output_offset
|
||||
+ (rel->r_vaddr - input_section->vma));
|
||||
if (signed_value > 0x1ffff || signed_value < - 0x20000)
|
||||
{
|
||||
overflow = true;
|
||||
signed_value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Put the adjusted value back into the instruction. */
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_HWORD (insn, signed_value);
|
||||
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
|
||||
break;
|
||||
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = EXTRACT_HWORD (insn);
|
||||
unsigned_value += val;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, insn, loc);
|
||||
break;
|
||||
|
||||
case R_IHIHALF:
|
||||
/* Save the value for the R_IHCONST reloc. */
|
||||
hihalf = true;
|
||||
hihalf_val = val;
|
||||
break;
|
||||
|
||||
case R_IHCONST:
|
||||
if (! hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, "missing IHIHALF reloc", input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
hihalf_val = 0;
|
||||
}
|
||||
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = rel->r_symndx + hihalf_val;
|
||||
unsigned_value >>= 16;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
|
||||
hihalf = false;
|
||||
|
||||
break;
|
||||
|
||||
case R_BYTE:
|
||||
case R_HWORD:
|
||||
case R_WORD:
|
||||
rstat = _bfd_relocate_contents (howto_table + rel->r_type,
|
||||
input_bfd, val, loc);
|
||||
if (rstat == bfd_reloc_overflow)
|
||||
overflow = true;
|
||||
else if (rstat != bfd_reloc_ok)
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else if (sym == NULL)
|
||||
name = "*unknown*";
|
||||
else if (sym->_n._n_n._n_zeroes == 0
|
||||
&& sym->_n._n_n._n_offset != 0)
|
||||
name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||
else
|
||||
{
|
||||
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||
buf[SYMNMLEN] = '\0';
|
||||
name = buf;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_a29k_relocate_section
|
||||
|
||||
/* We don't want to change the symndx of a R_IHCONST reloc, since it
|
||||
is actually an addend, not a symbol index at all. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static boolean
|
||||
coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *ibfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *irel;
|
||||
boolean *adjustedp;
|
||||
{
|
||||
if (irel->r_type == R_IHCONST)
|
||||
*adjustedp = true;
|
||||
else
|
||||
*adjustedp = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#define coff_adjust_symndx coff_a29k_adjust_symndx
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target a29kcoff_big_vec =
|
||||
{
|
||||
"coff-a29k-big", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */
|
||||
| SEC_LOAD | SEC_RELOC
|
||||
| SEC_READONLY ),
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
/* data */
|
||||
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 */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
||||
{
|
||||
|
||||
_bfd_dummy_target,
|
||||
coff_object_p,
|
||||
bfd_generic_archive_p,
|
||||
_bfd_dummy_target
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
coff_mkobject,
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
coff_write_object_contents,
|
||||
_bfd_write_archive_contents,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,162 +0,0 @@
|
||||
/* BFD back-end for Apollo 68000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
By Troy Rollo (troy@cbme.unsw.edu.au)
|
||||
Based on m68k standard COFF version Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/apollo.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type apollocoff_howto_table[];
|
||||
#else
|
||||
reloc_howto_type apollocoff_howto_table[] =
|
||||
{
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "-32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) M68KBADMAG(x)
|
||||
#endif
|
||||
#define APOLLO_M68 1 /* Customize coffcode.h */
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern void apollo_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||
extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
#else
|
||||
void
|
||||
apollo_rtype2howto(internal, relocentry)
|
||||
arelent *internal;
|
||||
int relocentry;
|
||||
{
|
||||
switch (relocentry)
|
||||
{
|
||||
case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
|
||||
case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
|
||||
case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
|
||||
case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
|
||||
case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
|
||||
case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
|
||||
case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
apollo_howto2rtype (internal)
|
||||
reloc_howto_type *internal;
|
||||
{
|
||||
if (internal->pc_relative)
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_PCRLONG;
|
||||
case 16: return R_PCRWORD;
|
||||
case 8: return R_PCRBYTE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_RELLONG;
|
||||
case 16: return R_RELWORD;
|
||||
case 8: return R_RELBYTE;
|
||||
}
|
||||
}
|
||||
return R_RELLONG;
|
||||
}
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
apollo_rtype2howto(internal, (relocentry)->r_type)
|
||||
|
||||
#define SELECT_RELOC(external, internal) \
|
||||
external.r_type = apollo_howto2rtype(internal);
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
apollocoff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"apollo-m68k", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
'_',
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
@ -1,537 +0,0 @@
|
||||
/* BFD back-end for ARM COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
|
||||
#include "coff/arm.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
#include "coff/pe.h"
|
||||
#endif
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
|
||||
static bfd_reloc_status_type coff_arm_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
|
||||
|
||||
/* Used by the assembler. */
|
||||
static bfd_reloc_status_type
|
||||
coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
diff = reloc_entry->addend;
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET true
|
||||
#endif
|
||||
|
||||
static reloc_howto_type aoutarm_std_reloc_howto[] =
|
||||
{
|
||||
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
|
||||
HOWTO(0, /* type */
|
||||
0, /* rs */
|
||||
0, /* size */
|
||||
8, /* bsz */
|
||||
false, /* pcrel */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* ovf */
|
||||
coff_arm_reloc, /* sf */
|
||||
"8", /*name */
|
||||
true, /* partial */
|
||||
0x000000ff, /*read mask */
|
||||
0x000000ff, /* setmask */
|
||||
PCRELOFFSET /* pcdone */),
|
||||
HOWTO(1,
|
||||
0,
|
||||
1,
|
||||
16,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"16",
|
||||
true,
|
||||
0x0000ffff,
|
||||
0x0000ffff,
|
||||
PCRELOFFSET),
|
||||
HOWTO( 2,
|
||||
0,
|
||||
2,
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
PCRELOFFSET),
|
||||
HOWTO( 3,
|
||||
2,
|
||||
2,
|
||||
26,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
aoutarm_fix_pcrel_26 ,
|
||||
"ARM26",
|
||||
false,
|
||||
0x00ffffff,
|
||||
0x00ffffff,
|
||||
PCRELOFFSET),
|
||||
HOWTO( 4,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
coff_arm_reloc,
|
||||
"DISP8",
|
||||
true,
|
||||
0x000000ff,
|
||||
0x000000ff,
|
||||
true),
|
||||
HOWTO( 5,
|
||||
0,
|
||||
1,
|
||||
16,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
coff_arm_reloc,
|
||||
"DISP16",
|
||||
true,
|
||||
0x0000ffff,
|
||||
0x0000ffff,
|
||||
true),
|
||||
HOWTO( 6,
|
||||
0,
|
||||
2,
|
||||
32,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
coff_arm_reloc,
|
||||
"DISP32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
true),
|
||||
HOWTO( 7,
|
||||
2,
|
||||
2,
|
||||
26,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
aoutarm_fix_pcrel_26_done,
|
||||
"ARM26D",
|
||||
true,
|
||||
0x00ffffff,
|
||||
0x00ffffff,
|
||||
false),
|
||||
{-1},
|
||||
HOWTO( 9,
|
||||
0,
|
||||
-1,
|
||||
16,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"NEG16",
|
||||
true,
|
||||
0x0000ffff,
|
||||
0x0000ffff,
|
||||
false),
|
||||
HOWTO( 10,
|
||||
0,
|
||||
-2,
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"NEG32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
false),
|
||||
HOWTO( 11,
|
||||
0,
|
||||
2,
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"rva32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
PCRELOFFSET),
|
||||
};
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Return true if this relocation should
|
||||
appear in the output .reloc section. */
|
||||
|
||||
static boolean in_reloc_p (abfd, howto)
|
||||
bfd * abfd;
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return !howto->pc_relative && howto->type != 11;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
|
||||
|
||||
#define coff_rtype_to_howto coff_arm_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
reloc_howto_type *howto;
|
||||
|
||||
howto = aoutarm_std_reloc_howto + rel->r_type;
|
||||
|
||||
if (rel->r_type == 11)
|
||||
{
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
return howto;
|
||||
|
||||
}
|
||||
/* Used by the assembler. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* This is dead simple at present. */
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* Used by the assembler. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||
|
||||
/* If this is an undefined symbol, return error */
|
||||
if (symbol->section == &bfd_und_section
|
||||
&& (symbol->flags & BSF_WEAK) == 0)
|
||||
return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
|
||||
|
||||
/* If the sections are different, and we are doing a partial relocation,
|
||||
just ignore it for now. */
|
||||
if (symbol->section->name != input_section->name
|
||||
&& output_bfd != (bfd *)NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
relocation = (target & 0x00ffffff) << 2;
|
||||
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
|
||||
relocation += symbol->value;
|
||||
relocation += symbol->section->output_section->vma;
|
||||
relocation += symbol->section->output_offset;
|
||||
relocation += reloc_entry->addend;
|
||||
relocation -= input_section->output_section->vma;
|
||||
relocation -= input_section->output_offset;
|
||||
relocation -= addr;
|
||||
if (relocation & 3)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
/* Check for overflow */
|
||||
if (relocation & 0x02000000)
|
||||
{
|
||||
if ((relocation & ~0x03ffffff) != ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else if (relocation & ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
|
||||
target &= ~0x00ffffff;
|
||||
target |= (relocation >> 2) & 0x00ffffff;
|
||||
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||
|
||||
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||
Strictly this is only necessary if we are doing a partial relocation. */
|
||||
reloc_entry->howto = &aoutarm_std_reloc_howto[7];
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
static CONST struct reloc_howto_struct *
|
||||
arm_reloc_type_lookup(abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
#define ASTD(i,j) case i: return &aoutarm_std_reloc_howto[j]
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
ASTD (BFD_RELOC_16, 1);
|
||||
ASTD (BFD_RELOC_32, 2);
|
||||
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||
ASTD (BFD_RELOC_RVA, 11);
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define coff_bfd_reloc_type_lookup arm_reloc_type_lookup
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) ARMBADMAG(x)
|
||||
#define ARM 1 /* Customize coffcode.h */
|
||||
|
||||
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_LITTLE_SYM
|
||||
TARGET_LITTLE_SYM =
|
||||
#else
|
||||
armcoff_little_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_LITTLE_NAME
|
||||
TARGET_LITTLE_NAME,
|
||||
#else
|
||||
"coff-arm-little",
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_BIG_SYM
|
||||
TARGET_BIG_SYM =
|
||||
#else
|
||||
armcoff_big_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_BIG_NAME
|
||||
TARGET_BIG_NAME,
|
||||
#else
|
||||
"coff-arm-big",
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,332 +0,0 @@
|
||||
/* BFD back-end for Apple M68K COFF A/UX 3.x files.
|
||||
Copyright 1996 Free Software Foundation, Inc.
|
||||
Portions written by Richard Henderson <rth@tamu.edu>,
|
||||
COMMON symbol munging cribbed from cf-m68klynx.c which was
|
||||
written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68kaux_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-aux"
|
||||
|
||||
#ifndef TARG_AUX
|
||||
#define TARG_AUX
|
||||
#endif
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
/* 4k pages */
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
#define _bfd_m68kcoff_howto_table _bfd_m68kaux_howto_table
|
||||
#define _bfd_m68kcoff_rtype2howto _bfd_m68kaux_rtype2howto
|
||||
#define _bfd_m68kcoff_howto2rtype _bfd_m68kaux_howto2rtype
|
||||
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68kaux_reloc_type_lookup
|
||||
|
||||
/* Rather than change names lots of places, reuse the same hack */
|
||||
#define LYNX_SPECIAL_FN _bfd_m68kaux_special_fn
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
struct internal_reloc;
|
||||
struct coff_link_hash_entry;
|
||||
struct internal_syment;
|
||||
#endif
|
||||
|
||||
|
||||
static bfd_reloc_status_type _bfd_m68kaux_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_m68k_aux_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
static boolean coff_m68k_aux_link_add_one_symbol
|
||||
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
|
||||
asection *, bfd_vma, const char *, boolean, boolean,
|
||||
struct bfd_link_hash_entry **));
|
||||
|
||||
|
||||
#define coff_rtype_to_howto coff_m68k_aux_rtype_to_howto
|
||||
#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
|
||||
|
||||
|
||||
/* 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
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||
|| reloc.r_type == R_PCRWORD \
|
||||
|| reloc.r_type == R_PCRLONG)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
|
||||
#include "coff-m68k.c"
|
||||
|
||||
|
||||
|
||||
/* For some reason when using m68k COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||
for I386 COFF). */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
_bfd_m68kaux_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | \
|
||||
(((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static reloc_howto_type *
|
||||
coff_m68k_aux_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
BFD_ASSERT (h != NULL);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
|
||||
/* We need non-absolute symbols to override absolute symbols. This
|
||||
mirrors Apple's "solution" to let a static library symbol override
|
||||
a shared library symbol. On the whole not a good thing, given how
|
||||
shared libraries work here, but can work if you are careful with
|
||||
what you include in the shared object. */
|
||||
|
||||
boolean
|
||||
coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||
string, copy, collect, hashp)
|
||||
struct bfd_link_info *info;
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
flagword flags;
|
||||
asection *section;
|
||||
bfd_vma value;
|
||||
const char *string;
|
||||
boolean copy;
|
||||
boolean collect;
|
||||
struct bfd_link_hash_entry **hashp;
|
||||
{
|
||||
struct bfd_link_hash_entry *h;
|
||||
|
||||
if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
|
||||
!bfd_is_und_section (section) &&
|
||||
!bfd_is_com_section (section))
|
||||
{
|
||||
/* The new symbol is a definition or an indirect definition */
|
||||
|
||||
/* This bit copied from linker.c */
|
||||
if (hashp != NULL && *hashp != NULL)
|
||||
{
|
||||
h = *hashp;
|
||||
BFD_ASSERT (strcmp (h->root.string, name) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
|
||||
if (h == NULL)
|
||||
{
|
||||
if (hashp != NULL)
|
||||
*hashp = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->notice_hash != (struct bfd_hash_table *) NULL
|
||||
&& (bfd_hash_lookup (info->notice_hash, name, false, false)
|
||||
!= (struct bfd_hash_entry *) NULL))
|
||||
{
|
||||
if (! (*info->callbacks->notice) (info, name, abfd, section, value))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hashp != (struct bfd_link_hash_entry **) NULL)
|
||||
*hashp = h;
|
||||
/* end duplication from linker.c */
|
||||
|
||||
if (h->type == bfd_link_hash_defined
|
||||
|| h->type == bfd_link_hash_indirect)
|
||||
{
|
||||
asection *msec;
|
||||
|
||||
if (h->type == bfd_link_hash_defined)
|
||||
msec = h->u.def.section;
|
||||
else
|
||||
msec = bfd_ind_section_ptr;
|
||||
|
||||
if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
|
||||
{
|
||||
h->u.def.section = section;
|
||||
h->u.def.value = value;
|
||||
return true;
|
||||
}
|
||||
else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't exit early, finish processing in the generic routine */
|
||||
return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
|
||||
value, string, copy, collect,
|
||||
hashp);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/* BFD back-end for Intel 386 COFF files (go32 variant).
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by DJ Delorie.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM go32coff_vec
|
||||
#define TARGET_NAME "coff-go32"
|
||||
#define TARGET_UNDERSCORE '_'
|
||||
|
||||
#include "coff-i386.c"
|
@ -1,650 +0,0 @@
|
||||
/* BFD back-end for Hitachi H8/300 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "genlink.h"
|
||||
#include "coff/h8300.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
|
||||
/* special handling for H8/300 relocs.
|
||||
We only come here for pcrel stuff and return normally if not an -r link.
|
||||
When doing -r, we can't do any arithmetic for the pcrel stuff, because
|
||||
the code in reloc.c assumes that we can manipulate the targets of
|
||||
the pcrel branches. This isn't so, since the H8/300 can do relaxing,
|
||||
which means that the gap after the instruction may not be enough to
|
||||
contain the offset required for the branch, so we have to use the only
|
||||
the addend until the final link */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
|
||||
HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true),
|
||||
HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true),
|
||||
HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true),
|
||||
HOWTO (R_MOVB1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/8", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_MOVB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/16", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
|
||||
HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false),
|
||||
HOWTO (R_JMPL_B8, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
HOWTO (R_MOVLB1, 0, 1, 16, false, 0, complain_overflow_bitfield,special, "24/8", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_MOVLB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/24", false, 0x0000ffff, 0x0000ffff, false),
|
||||
|
||||
/* An indirect reference to a function. This causes the function's address
|
||||
to be added to the function vector in lo-mem and puts the address of
|
||||
the function vector's entry in the jsr instruction. */
|
||||
HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#define SELECT_RELOC(x,howto) \
|
||||
{ x.r_type = select_reloc(howto); }
|
||||
|
||||
#define BADMAG(x) (H8300BADMAG(x)&& H8300HBADMAG(x))
|
||||
#define H8300 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
|
||||
static int
|
||||
select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
case R_RELBYTE:
|
||||
internal->howto = howto_table + 0;
|
||||
break;
|
||||
case R_RELWORD:
|
||||
internal->howto = howto_table + 1;
|
||||
break;
|
||||
case R_RELLONG:
|
||||
internal->howto = howto_table + 2;
|
||||
break;
|
||||
case R_PCRBYTE:
|
||||
internal->howto = howto_table + 3;
|
||||
break;
|
||||
case R_PCRWORD:
|
||||
internal->howto = howto_table + 4;
|
||||
break;
|
||||
case R_PCRLONG:
|
||||
internal->howto = howto_table + 5;
|
||||
break;
|
||||
case R_MOVB1:
|
||||
internal->howto = howto_table + 6;
|
||||
break;
|
||||
case R_MOVB2:
|
||||
internal->howto = howto_table + 7;
|
||||
break;
|
||||
case R_JMP1:
|
||||
internal->howto = howto_table + 8;
|
||||
break;
|
||||
case R_JMP2:
|
||||
internal->howto = howto_table + 9;
|
||||
break;
|
||||
case R_JMPL1:
|
||||
internal->howto = howto_table + 10;
|
||||
break;
|
||||
case R_JMPL_B8:
|
||||
internal->howto = howto_table + 11;
|
||||
break;
|
||||
case R_MOVLB1:
|
||||
internal->howto = howto_table + 12;
|
||||
break;
|
||||
case R_MOVLB2:
|
||||
internal->howto = howto_table + 13;
|
||||
break;
|
||||
case R_MEM_INDIRECT:
|
||||
internal->howto = howto_table + 14;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, 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;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
|
||||
bfd *abfd;
|
||||
asection *input_section;
|
||||
arelent *reloc;
|
||||
unsigned int shrink;
|
||||
struct bfd_link_info *link_info;
|
||||
{
|
||||
bfd_vma value;
|
||||
bfd_vma dot;
|
||||
bfd_vma gap;
|
||||
|
||||
/* The address of the thing to be relocated will have moved back by
|
||||
the size of the shrink - but we don't change reloc->address here,
|
||||
since we need it to know where the relocation lives in the source
|
||||
uncooked section */
|
||||
|
||||
/* reloc->address -= shrink; conceptual */
|
||||
|
||||
bfd_vma address = reloc->address - shrink;
|
||||
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_MOVB2:
|
||||
case R_JMP2:
|
||||
shrink+=2;
|
||||
break;
|
||||
|
||||
/* Thing is a move one byte */
|
||||
case R_MOVB1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
if (value >= 0xff00)
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
|
||||
break;
|
||||
/* This is the 24 bit branch which could become an 8 bitter,
|
||||
the relocation points to the first byte of the insn, not the
|
||||
actual data */
|
||||
|
||||
case R_JMPL1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - dot ;
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||
possible 32 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMP1:
|
||||
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - (dot - shrink);
|
||||
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return shrink;
|
||||
}
|
||||
|
||||
|
||||
/* First phase of a relaxing link */
|
||||
|
||||
/* Reloc types
|
||||
large small
|
||||
R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
|
||||
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||
R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||
dst_ptr)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
unsigned int src_address = *src_ptr;
|
||||
unsigned int dst_address = *dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
/* A 24 bit branch which could be a 8 bit pcrel, really pointing to
|
||||
the byte before the 24bit hole, so we can treat it as a 32bit pointer */
|
||||
case R_PCRBYTE:
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot);
|
||||
if (gap > 127 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
gap &= ~1;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address++;
|
||||
src_address++;
|
||||
|
||||
break;
|
||||
}
|
||||
case R_PCRWORD:
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot) - 1;
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address+=2;
|
||||
src_address+=2;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case R_MEM_INDIRECT: /* Temporary */
|
||||
case R_RELBYTE:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
if (gap < 0xff
|
||||
|| (gap >= 0x0000ff00
|
||||
&& gap <= 0x0000ffff)
|
||||
|| ( gap >= 0x00ffff00
|
||||
&& gap <= 0x00ffffff)
|
||||
|| ( gap >= 0xffffff00
|
||||
&& gap <= 0xffffffff))
|
||||
{
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R_JMP1:
|
||||
/* A relword which would have like to have been a pcrel */
|
||||
case R_MOVB1:
|
||||
/* A relword which would like to have been modified but
|
||||
didn't make it */
|
||||
case R_RELWORD:
|
||||
bfd_put_16 (abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
break;
|
||||
case R_RELLONG:
|
||||
bfd_put_32 (abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + dst_address);
|
||||
dst_address += 4;
|
||||
src_address += 4;
|
||||
break;
|
||||
|
||||
case R_MOVB2:
|
||||
/* Special relaxed type, there will be a gap between where we
|
||||
get stuff from and where we put stuff to now
|
||||
|
||||
for a mov.b @aa:16 -> mov.b @aa:8
|
||||
opcode 0x6a 0x0y offset
|
||||
-> 0x2y off
|
||||
*/
|
||||
if (data[dst_address - 1] != 0x6a)
|
||||
abort ();
|
||||
switch (data[src_address] & 0xf0)
|
||||
{
|
||||
case 0x00:
|
||||
/* Src is memory */
|
||||
data[dst_address - 1] = (data[src_address] & 0xf) | 0x20;
|
||||
break;
|
||||
case 0x80:
|
||||
/* Src is reg */
|
||||
data[dst_address - 1] = (data[src_address] & 0xf) | 0x30;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* the offset must fit ! after all, what was all the relaxing
|
||||
about ? */
|
||||
|
||||
bfd_put_8 (abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + dst_address);
|
||||
|
||||
/* Note the magic - src goes up by two bytes, but dst by only
|
||||
one */
|
||||
dst_address += 1;
|
||||
src_address += 3;
|
||||
|
||||
break;
|
||||
|
||||
case R_JMP2:
|
||||
|
||||
/* Speciial relaxed type */
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot - 1);
|
||||
|
||||
if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
|
||||
abort ();
|
||||
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
|
||||
switch (data[dst_address - 1])
|
||||
{
|
||||
case 0x5e:
|
||||
/* jsr -> bsr */
|
||||
bfd_put_8 (abfd, 0x55, data + dst_address - 1);
|
||||
break;
|
||||
case 0x5a:
|
||||
/* jmp ->bra */
|
||||
bfd_put_8 (abfd, 0x40, data + dst_address - 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
dst_address++;
|
||||
src_address += 3;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMPL_B8: /* 24 bit branch which is now 8 bits */
|
||||
|
||||
/* Speciial relaxed type */
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot - 2);
|
||||
|
||||
if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
|
||||
abort ();
|
||||
|
||||
switch (data[src_address])
|
||||
{
|
||||
case 0x5e:
|
||||
/* jsr -> bsr */
|
||||
bfd_put_8 (abfd, 0x55, data + dst_address);
|
||||
break;
|
||||
case 0x5a:
|
||||
/* jmp ->bra */
|
||||
bfd_put_8 (abfd, 0x40, data + dst_address);
|
||||
break;
|
||||
|
||||
default:
|
||||
bfd_put_8 (abfd, 0xde, data + dst_address);
|
||||
break;
|
||||
}
|
||||
|
||||
bfd_put_8 (abfd, gap, data + dst_address + 1);
|
||||
dst_address += 2;
|
||||
src_address += 4;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case R_JMPL1:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
int o = bfd_get_32 (abfd, data + src_address);
|
||||
v = (v & 0x00ffffff) | (o & 0xff000000);
|
||||
bfd_put_32 (abfd, v, data + dst_address);
|
||||
dst_address += 4;
|
||||
src_address += 4;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/* A 24 bit mov which could be an 8 bit move, really pointing to
|
||||
the byte before the 24bit hole, so we can treat it as a 32bit pointer */
|
||||
case R_MOVLB1:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
int o = bfd_get_32 (abfd, data + dst_address);
|
||||
v = (v & 0x00ffffff) | (o & 0xff000000);
|
||||
bfd_put_32 (abfd, v, data + dst_address);
|
||||
dst_address += 4;
|
||||
src_address += 4;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
abort ();
|
||||
break;
|
||||
|
||||
}
|
||||
*src_ptr = src_address;
|
||||
*dst_ptr = dst_address;
|
||||
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
|
||||
#define coff_reloc16_estimate h8300_reloc16_estimate
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
|
||||
|
||||
const bfd_target h8300coff_vec =
|
||||
{
|
||||
"coff-h8300", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,355 +0,0 @@
|
||||
/* BFD back-end for Hitachi H8/500 COFF binaries.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/h8500.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
static reloc_howto_type r_imm8 =
|
||||
HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
|
||||
|
||||
static reloc_howto_type r_imm16 =
|
||||
HOWTO (R_H8500_IMM16, 0, 1, 16, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm16", true, 0x0000ffff, 0x0000ffff, false);
|
||||
|
||||
static reloc_howto_type r_imm24 =
|
||||
HOWTO (R_H8500_IMM24, 0, 1, 24, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm24", true, 0x00ffffff, 0x00ffffff, false);
|
||||
|
||||
static reloc_howto_type r_imm32 =
|
||||
HOWTO (R_H8500_IMM32, 0, 1, 32, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff, 0xffffffff, false);
|
||||
|
||||
|
||||
static reloc_howto_type r_high8 =
|
||||
HOWTO (R_H8500_HIGH8, 0, 1, 8, false, 0,
|
||||
complain_overflow_dont, 0, "r_high8", true, 0x000000ff, 0x000000ff, false);
|
||||
|
||||
static reloc_howto_type r_low16 =
|
||||
HOWTO (R_H8500_LOW16, 0, 1, 16, false, 0,
|
||||
complain_overflow_dont, 0, "r_low16", true, 0x0000ffff, 0x0000ffff, false);
|
||||
|
||||
static reloc_howto_type r_pcrel8 =
|
||||
HOWTO (R_H8500_PCREL8, 0, 1, 8, true, 0, complain_overflow_signed, 0, "r_pcrel8", true, 0, 0, true);
|
||||
|
||||
|
||||
static reloc_howto_type r_pcrel16 =
|
||||
HOWTO (R_H8500_PCREL16, 0, 1, 16, true, 0, complain_overflow_signed, 0, "r_pcrel16", true, 0, 0, true);
|
||||
|
||||
static reloc_howto_type r_high16 =
|
||||
HOWTO (R_H8500_HIGH16, 0, 1, 8, false, 0,
|
||||
complain_overflow_dont, 0, "r_high16", true, 0x000ffff, 0x0000ffff, false);
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
static int
|
||||
coff_h8500_select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_h8500_select_reloc(howto)
|
||||
|
||||
|
||||
#define BADMAG(x) H8500BADMAG(x)
|
||||
#define H8500 1 /* Customize coffcode.h */
|
||||
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto(internal, dst)
|
||||
arelent * internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
case R_H8500_IMM8:
|
||||
internal->howto = &r_imm8;
|
||||
break;
|
||||
case R_H8500_IMM16:
|
||||
internal->howto = &r_imm16;
|
||||
break;
|
||||
case R_H8500_IMM24:
|
||||
internal->howto = &r_imm24;
|
||||
break;
|
||||
case R_H8500_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_H8500_PCREL8:
|
||||
internal->howto = &r_pcrel8;
|
||||
break;
|
||||
case R_H8500_PCREL16:
|
||||
internal->howto = &r_pcrel16;
|
||||
break;
|
||||
case R_H8500_HIGH8:
|
||||
internal->howto = &r_high8;
|
||||
break;
|
||||
case R_H8500_HIGH16:
|
||||
internal->howto = &r_high16;
|
||||
break;
|
||||
case R_H8500_LOW16:
|
||||
internal->howto = &r_low16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, 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;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (reloc->r_symndx > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
static void
|
||||
extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
|
||||
bfd *in_abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
bfd_byte *d = data+*dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_H8500_IMM8:
|
||||
bfd_put_8 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_H8500_HIGH8:
|
||||
bfd_put_8 (in_abfd,
|
||||
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
>> 16),
|
||||
d );
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_H8500_IMM16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d );
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_LOW16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_HIGH16:
|
||||
bfd_put_16 (in_abfd,
|
||||
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
>>16),
|
||||
d);
|
||||
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_IMM24:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
int o = bfd_get_32(in_abfd, data+ *dst_ptr -1);
|
||||
v = (v & 0x00ffffff) | (o & 0xff00000);
|
||||
bfd_put_32 (in_abfd, v, data + *dst_ptr -1);
|
||||
(*dst_ptr) +=3;
|
||||
(*src_ptr)+=3;;
|
||||
}
|
||||
break;
|
||||
case R_H8500_IMM32:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
bfd_put_32 (in_abfd, v, data + *dst_ptr);
|
||||
(*dst_ptr) +=4;
|
||||
(*src_ptr)+=4;;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case R_H8500_PCREL8:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ *dst_ptr
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented */
|
||||
|
||||
if (gap > 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
case R_H8500_PCREL16:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ *dst_ptr
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented */
|
||||
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_16 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)+=2;
|
||||
(*src_ptr)+=2;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
const bfd_target h8500coff_vec =
|
||||
{
|
||||
"coff-h8500", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,423 +0,0 @@
|
||||
/* BFD back-end for Intel 860 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Created mostly by substituting "860" for "386" in coff-i386.c
|
||||
Harry Dolan <dolan@ssd.intel.com>, October 1995
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
|
||||
#include "coff/i860.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type coff_i860_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i860_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using i860 COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. Ian Taylor, Cygnus Support. */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 860
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET false
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{0},
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
{4},
|
||||
{5},
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
/* {7}, */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
{010},
|
||||
{011},
|
||||
{012},
|
||||
{013},
|
||||
{014},
|
||||
{015},
|
||||
{016},
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"8", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"16", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP8", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP16", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) I860BADMAG(x)
|
||||
#define I860 1 /* Customize coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
/* For 860 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
STYP_NOLOAD. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
/* 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
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && howto_table[reloc.r_type].pc_relative) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i860_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
|
||||
reloc_howto_type *howto;
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
|
||||
BFD_ASSERT (h != NULL);
|
||||
|
||||
|
||||
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||
parameters get the wrong relcation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map */
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_i860_rtype_to_howto
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *
|
||||
i3coff_object_p(a)
|
||||
bfd *a;
|
||||
{
|
||||
return coff_object_p(a);
|
||||
}
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
i860coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-i860", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, i3coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,683 +0,0 @@
|
||||
/* BFD back-end for Intel 960 COFF files.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define I960 1
|
||||
#define BADMAG(x) I960BADMAG(x)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/i960.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h" /* to allow easier abstraction-breaking */
|
||||
|
||||
static bfd_reloc_status_type optcall_callback
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type coff_i960_relocate
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i960_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static boolean coff_i960_start_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean coff_i960_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static boolean coff_i960_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, boolean *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
|
||||
arbitrarily small. */
|
||||
#define COFF_PAGE_SIZE 1
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
/* This is just like the usual CALC_ADDEND, but it includes the
|
||||
section VMA for PC relative relocs. */
|
||||
#ifndef CALC_ADDEND
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = 0; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CALLS 0x66003800 /* Template for 'calls' instruction */
|
||||
#define BAL 0x0b000000 /* Template for 'bal' instruction */
|
||||
#define BAL_MASK 0x00ffffff
|
||||
|
||||
static bfd_reloc_status_type
|
||||
optcall_callback (abfd, reloc_entry, symbol_in, data,
|
||||
input_section, ignore_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *ignore_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* This item has already been relocated correctly, but we may be
|
||||
* able to patch in yet better code - done by digging out the
|
||||
* correct info on this symbol */
|
||||
bfd_reloc_status_type result;
|
||||
coff_symbol_type *cs = coffsymbol(symbol_in);
|
||||
|
||||
/* Don't do anything with symbols which aren't tied up yet,
|
||||
except move the reloc. */
|
||||
if (bfd_is_und_section (cs->symbol.section)) {
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* So the target symbol has to be of coff type, and the symbol
|
||||
has to have the correct native information within it */
|
||||
if ((bfd_asymbol_flavour(&cs->symbol) != bfd_target_coff_flavour)
|
||||
|| (cs->native == (combined_entry_type *)NULL))
|
||||
{
|
||||
/* This is interesting, consider the case where we're outputting coff
|
||||
from a mix n match input, linking from coff to a symbol defined in a
|
||||
bout file will cause this match to be true. Should I complain? This
|
||||
will only work if the bout symbol is non leaf. */
|
||||
*error_message =
|
||||
(char *) "uncertain calling convention for non-COFF symbol";
|
||||
result = bfd_reloc_dangerous;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cs->native->u.syment.n_sclass)
|
||||
{
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure, replace instruction with a bal
|
||||
to the correct location. */
|
||||
{
|
||||
union internal_auxent *aux = &((cs->native+2)->u.auxent);
|
||||
int word = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
||||
int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
|
||||
BFD_ASSERT(cs->native->u.syment.n_numaux==2);
|
||||
|
||||
/* We replace the original call instruction with a bal to
|
||||
the bal entry point - the offset of which is described in
|
||||
the 2nd auxent of the original symbol. We keep the native
|
||||
sym and auxents untouched, so the delta between the two
|
||||
is the offset of the bal entry point. */
|
||||
word = ((word + olf) & BAL_MASK) | BAL;
|
||||
bfd_put_32(abfd, word, (bfd_byte *) data + reloc_entry->address);
|
||||
}
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
case C_SCALL:
|
||||
/* This is a call to a system call, replace with a calls to # */
|
||||
BFD_ASSERT(0);
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
default:
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||
appear to correctly handle a reloc against a symbol defined in the
|
||||
same object file. It appears to simply discard such relocs, rather
|
||||
than adding their values into the object file. We handle this here
|
||||
by converting all relocs against defined symbols into relocs
|
||||
against the section symbol, when generating a relocateable output
|
||||
file.
|
||||
|
||||
Note that this function is only called if we are not using the COFF
|
||||
specific backend linker. It only does something when doing a
|
||||
relocateable link, which will almost certainly fail when not
|
||||
generating COFF i960 output, so this function is actually no longer
|
||||
useful. It was used before this target was converted to use the
|
||||
COFF specific backend linker. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
asection *osec;
|
||||
|
||||
if (output_bfd == NULL)
|
||||
{
|
||||
/* Not generating relocateable output file. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
if (bfd_is_und_section (bfd_get_section (symbol)))
|
||||
{
|
||||
/* Symbol is not defined, so no need to worry about it. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (bfd_get_section (symbol)))
|
||||
{
|
||||
/* I don't really know what the right action is for a common
|
||||
symbol. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Convert the reloc to use the section symbol. FIXME: This method
|
||||
is ridiculous. */
|
||||
osec = bfd_get_section (symbol)->output_section;
|
||||
if (coff_section_data (output_bfd, osec) != NULL
|
||||
&& coff_section_data (output_bfd, osec)->tdata != NULL)
|
||||
reloc_entry->sym_ptr_ptr =
|
||||
(asymbol **) coff_section_data (output_bfd, osec)->tdata;
|
||||
else
|
||||
{
|
||||
const char *sec_name;
|
||||
asymbol **syms, **sym_end;
|
||||
|
||||
sec_name = bfd_get_section_name (output_bfd, osec);
|
||||
syms = bfd_get_outsymbols (output_bfd);
|
||||
sym_end = syms + bfd_get_symcount (output_bfd);
|
||||
for (; syms < sym_end; syms++)
|
||||
{
|
||||
if (bfd_asymbol_name (*syms) != NULL
|
||||
&& (*syms)->value == 0
|
||||
&& strcmp ((*syms)->section->output_section->name,
|
||||
sec_name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (syms >= sym_end)
|
||||
abort ();
|
||||
|
||||
reloc_entry->sym_ptr_ptr = syms;
|
||||
|
||||
if (coff_section_data (output_bfd, osec) == NULL)
|
||||
{
|
||||
osec->used_by_bfd =
|
||||
((PTR) bfd_zalloc (abfd,
|
||||
sizeof (struct coff_section_tdata)));
|
||||
if (osec->used_by_bfd == NULL)
|
||||
return bfd_reloc_overflow;
|
||||
}
|
||||
coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
|
||||
}
|
||||
|
||||
/* Let bfd_perform_relocation do its thing, which will include
|
||||
stuffing the symbol addend into the object file. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_rellong =
|
||||
HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,false, 0,
|
||||
complain_overflow_bitfield, coff_i960_relocate,"rellong", true,
|
||||
0xffffffff, 0xffffffff, 0);
|
||||
static reloc_howto_type howto_iprmed =
|
||||
HOWTO (R_IPRMED, 0, 2, 24,true,0, complain_overflow_signed,
|
||||
coff_i960_relocate, "iprmed ", true, 0x00ffffff, 0x00ffffff, 0);
|
||||
static reloc_howto_type howto_optcall =
|
||||
HOWTO (R_OPTCALL, 0,2,24,true,0, complain_overflow_signed,
|
||||
optcall_callback, "optcall", true, 0x00ffffff, 0x00ffffff, 0);
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i960_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case BFD_RELOC_I960_CALLJ:
|
||||
return &howto_optcall;
|
||||
case BFD_RELOC_32:
|
||||
case BFD_RELOC_CTOR:
|
||||
return &howto_rellong;
|
||||
case BFD_RELOC_24_PCREL:
|
||||
return &howto_iprmed;
|
||||
}
|
||||
}
|
||||
|
||||
/* The real code is in coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
{ \
|
||||
reloc_howto_type *howto_ptr; \
|
||||
switch ((dst)->r_type) { \
|
||||
case 17: howto_ptr = &howto_rellong; break; \
|
||||
case 25: howto_ptr = &howto_iprmed; break; \
|
||||
case 27: howto_ptr = &howto_optcall; break; \
|
||||
default: howto_ptr = 0; break; \
|
||||
} \
|
||||
(cache_ptr)->howto = howto_ptr; \
|
||||
}
|
||||
|
||||
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||
appear to correctly handle a reloc against a symbol defined in the
|
||||
same object file. It appears to simply discard such relocs, rather
|
||||
than adding their values into the object file. We handle this by
|
||||
converting all relocs against global symbols into relocs against
|
||||
internal symbols at the start of the section. This routine is
|
||||
called at the start of the linking process, and it creates the
|
||||
necessary symbols. */
|
||||
|
||||
static boolean
|
||||
coff_i960_start_final_link (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
bfd_size_type symesz = bfd_coff_symesz (abfd);
|
||||
asection *o;
|
||||
bfd_byte *esym;
|
||||
|
||||
if (! info->relocateable)
|
||||
return true;
|
||||
|
||||
esym = (bfd_byte *) bfd_malloc (symesz);
|
||||
if (esym == NULL)
|
||||
return false;
|
||||
|
||||
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
for (o = abfd->sections; o != NULL; o = o->next)
|
||||
{
|
||||
struct internal_syment isym;
|
||||
|
||||
strncpy (isym._n._n_name, o->name, SYMNMLEN);
|
||||
isym.n_value = 0;
|
||||
isym.n_scnum = o->target_index;
|
||||
isym.n_type = T_NULL;
|
||||
isym.n_sclass = C_STAT;
|
||||
isym.n_numaux = 0;
|
||||
|
||||
bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
|
||||
|
||||
if (bfd_write (esym, symesz, 1, abfd) != symesz)
|
||||
{
|
||||
free (esym);
|
||||
return false;
|
||||
}
|
||||
|
||||
obj_raw_syment_count (abfd) += 1;
|
||||
}
|
||||
|
||||
free (esym);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static boolean
|
||||
coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma addend;
|
||||
bfd_vma val;
|
||||
reloc_howto_type *howto;
|
||||
bfd_reloc_status_type rstat = bfd_reloc_ok;
|
||||
boolean done;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
addend = - sym->n_value;
|
||||
else
|
||||
addend = 0;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
case 17: howto = &howto_rellong; break;
|
||||
case 25: howto = &howto_iprmed; break;
|
||||
case 27: howto = &howto_optcall; break;
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
sec = bfd_abs_section_ptr;
|
||||
val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else if (! info->relocateable)
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
done = false;
|
||||
|
||||
if (howto->type == R_OPTCALL && ! info->relocateable && symndx != -1)
|
||||
{
|
||||
int class;
|
||||
|
||||
if (h != NULL)
|
||||
class = h->class;
|
||||
else
|
||||
class = sym->n_sclass;
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case C_NULL:
|
||||
/* This symbol is apparently not from a COFF input file.
|
||||
We warn, and then assume that it is not a leaf
|
||||
function. */
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info,
|
||||
"uncertain calling convention for non-COFF symbol",
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
break;
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure; use the bal
|
||||
instruction. */
|
||||
{
|
||||
long olf;
|
||||
unsigned long word;
|
||||
|
||||
if (h != NULL)
|
||||
{
|
||||
BFD_ASSERT (h->numaux == 2);
|
||||
olf = h->aux[1].x_bal.x_balntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_byte *esyms;
|
||||
union internal_auxent aux;
|
||||
|
||||
BFD_ASSERT (sym->n_numaux == 2);
|
||||
esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
|
||||
esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
|
||||
bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
|
||||
sym->n_sclass, 1, sym->n_numaux,
|
||||
(PTR) &aux);
|
||||
olf = aux.x_bal.x_balntry;
|
||||
}
|
||||
|
||||
word = bfd_get_32 (input_bfd,
|
||||
(contents
|
||||
+ (rel->r_vaddr - input_section->vma)));
|
||||
word = ((word + olf - val) & BAL_MASK) | BAL;
|
||||
bfd_put_32 (input_bfd,
|
||||
word,
|
||||
(contents
|
||||
+ (rel->r_vaddr - input_section->vma)));
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
case C_SCALL:
|
||||
BFD_ASSERT (0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! done)
|
||||
{
|
||||
if (howto->pc_relative)
|
||||
addend += input_section->vma;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents,
|
||||
rel->r_vaddr - input_section->vma,
|
||||
val, addend);
|
||||
}
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||
if (name == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto->name, (bfd_vma) 0, input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Adjust the symbol index of any reloc against a global symbol to
|
||||
instead be a reloc against the internal symbol we created specially
|
||||
for the section. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static boolean
|
||||
coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *ibfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *irel;
|
||||
boolean *adjustedp;
|
||||
{
|
||||
struct coff_link_hash_entry *h;
|
||||
|
||||
*adjustedp = false;
|
||||
|
||||
h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
|
||||
if (h == NULL
|
||||
|| (h->root.type != bfd_link_hash_defined
|
||||
&& h->root.type != bfd_link_hash_defweak))
|
||||
return true;
|
||||
|
||||
irel->r_symndx = h->root.u.def.section->output_section->target_index - 1;
|
||||
*adjustedp = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define coff_start_final_link coff_i960_start_final_link
|
||||
|
||||
#define coff_relocate_section coff_i960_relocate_section
|
||||
|
||||
#define coff_adjust_symndx coff_i960_adjust_symndx
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_i960_reloc_type_lookup
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target icoff_little_vec =
|
||||
{
|
||||
"coff-Intel-little", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
|
||||
|
||||
const bfd_target icoff_big_vec =
|
||||
{
|
||||
"coff-Intel-big", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,203 +0,0 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries.
|
||||
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/m68k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#ifndef LYNX_SPECIAL_FN
|
||||
#define LYNX_SPECIAL_FN 0
|
||||
#endif
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#ifndef COFF_PAGE_SIZE
|
||||
/* The page size is a guess based on ELF. */
|
||||
#define COFF_PAGE_SIZE 0x2000
|
||||
#endif
|
||||
|
||||
/* Clean up namespace. */
|
||||
#define m68kcoff_howto_table _bfd_m68kcoff_howto_table
|
||||
#define m68k_rtype2howto _bfd_m68kcoff_rtype2howto
|
||||
#define m68k_howto2rtype _bfd_m68kcoff_howto2rtype
|
||||
#define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type m68kcoff_howto_table[];
|
||||
#else
|
||||
reloc_howto_type m68kcoff_howto_table[] =
|
||||
{
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) M68KBADMAG(x)
|
||||
#endif
|
||||
#define M68 1 /* Customize coffcode.h */
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||
extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
extern reloc_howto_type *m68k_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
#else
|
||||
void
|
||||
m68k_rtype2howto(internal, relocentry)
|
||||
arelent *internal;
|
||||
int relocentry;
|
||||
{
|
||||
switch (relocentry)
|
||||
{
|
||||
case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
|
||||
case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
|
||||
case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
|
||||
case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
|
||||
case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
|
||||
case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
|
||||
case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
m68k_howto2rtype (internal)
|
||||
reloc_howto_type *internal;
|
||||
{
|
||||
if (internal->pc_relative)
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_PCRLONG;
|
||||
case 16: return R_PCRWORD;
|
||||
case 8: return R_PCRBYTE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_RELLONG;
|
||||
case 16: return R_RELWORD;
|
||||
case 8: return R_RELBYTE;
|
||||
}
|
||||
}
|
||||
return R_RELLONG;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
m68k_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default: return NULL;
|
||||
case BFD_RELOC_8: return m68kcoff_howto_table + 0;
|
||||
case BFD_RELOC_16: return m68kcoff_howto_table + 1;
|
||||
case BFD_RELOC_CTOR:
|
||||
case BFD_RELOC_32: return m68kcoff_howto_table + 2;
|
||||
case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
|
||||
case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4;
|
||||
case BFD_RELOC_32_PCREL: return m68kcoff_howto_table + 5;
|
||||
/* FIXME: There doesn't seem to be a code for R_RELLONG_NEG. */
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
m68k_rtype2howto(internal, (relocentry)->r_type)
|
||||
|
||||
#define SELECT_RELOC(external, internal) \
|
||||
external.r_type = m68k_howto2rtype(internal);
|
||||
|
||||
#define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
m68kcoff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-m68k", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
'_',
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
@ -1,311 +0,0 @@
|
||||
/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define M88 1 /* Customize various include files */
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/m88k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type m88k_special_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
static bfd_reloc_status_type
|
||||
m88k_special_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
|
||||
switch (howto->type)
|
||||
{
|
||||
case R_HVRT16:
|
||||
case R_LVRT16:
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_vma output_base = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||
asection *reloc_target_output_section;
|
||||
long relocation = 0;
|
||||
|
||||
/* Work out which section the relocation is targetted at and the
|
||||
initial relocation command value. */
|
||||
|
||||
/* Get symbol value. (Common symbols are special.) */
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value;
|
||||
|
||||
reloc_target_output_section = symbol->section->output_section;
|
||||
|
||||
/* Convert input-section-relative symbol value to absolute. */
|
||||
if (output_bfd)
|
||||
output_base = 0;
|
||||
else
|
||||
output_base = reloc_target_output_section->vma;
|
||||
|
||||
relocation += output_base + symbol->section->output_offset;
|
||||
|
||||
/* Add in supplied addend. */
|
||||
relocation += ((reloc_entry->addend << howto->bitsize) + x);
|
||||
|
||||
reloc_entry->addend = 0;
|
||||
|
||||
relocation >>= (bfd_vma) howto->rightshift;
|
||||
|
||||
/* Shift everything up to where it's going to be used */
|
||||
|
||||
relocation <<= (bfd_vma) howto->bitpos;
|
||||
|
||||
if (relocation)
|
||||
bfd_put_16 (abfd, relocation, (unsigned char *) data + addr);
|
||||
}
|
||||
|
||||
return bfd_reloc_ok;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_PCR16L, /* type */
|
||||
02, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"PCR16L", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PCR26L, /* type */
|
||||
02, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
26, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"PCR26L", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x03ffffff, /* src_mask */
|
||||
0x03ffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_VRT16, /* type */
|
||||
00, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"VRT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_HVRT16, /* type */
|
||||
16, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"HVRT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LVRT16, /* type */
|
||||
00, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"LVRT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_VRT32, /* type */
|
||||
00, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"VRT32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Code to turn an external r_type into a pointer to an entry in the
|
||||
above howto table. */
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
|
||||
{
|
||||
cache_ptr->howto = howto_table + dst->r_type - R_PCR16L;
|
||||
}
|
||||
else
|
||||
{
|
||||
BFD_ASSERT (0);
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
|
||||
|
||||
|
||||
/* Code to swap in the reloc offset */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, 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;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
#define BADMAG(x) MC88BADMAG(x)
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_write_armap
|
||||
|
||||
const bfd_target m88kbcs_vec =
|
||||
{
|
||||
"coff-m88kbcs", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
||||
/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
|
||||
Copyright 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM pmac_xcoff_vec
|
||||
#define TARGET_NAME "xcoff-powermac"
|
||||
|
||||
/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
|
||||
|
||||
#define POWERMAC
|
||||
|
||||
#include "coff-rs6000.c"
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,278 +0,0 @@
|
||||
/* BFD back-end for Sparc COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/sparc.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
|
||||
|
||||
/* The page size is a guess based on ELF. */
|
||||
#define COFF_PAGE_SIZE 0x10000
|
||||
|
||||
enum reloc_type
|
||||
{
|
||||
R_SPARC_NONE = 0,
|
||||
R_SPARC_8, R_SPARC_16, R_SPARC_32,
|
||||
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
|
||||
R_SPARC_WDISP30, R_SPARC_WDISP22,
|
||||
R_SPARC_HI22, R_SPARC_22,
|
||||
R_SPARC_13, R_SPARC_LO10,
|
||||
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
|
||||
R_SPARC_PC10, R_SPARC_PC22,
|
||||
R_SPARC_WPLT30,
|
||||
R_SPARC_COPY,
|
||||
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
|
||||
R_SPARC_RELATIVE,
|
||||
R_SPARC_UA32,
|
||||
R_SPARC_max
|
||||
};
|
||||
|
||||
#if 0
|
||||
static CONST char *CONST reloc_type_names[] =
|
||||
{
|
||||
"R_SPARC_NONE",
|
||||
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
|
||||
"R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
|
||||
"R_SPARC_WDISP30", "R_SPARC_WDISP22",
|
||||
"R_SPARC_HI22", "R_SPARC_22",
|
||||
"R_SPARC_13", "R_SPARC_LO10",
|
||||
"R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
|
||||
"R_SPARC_PC10", "R_SPARC_PC22",
|
||||
"R_SPARC_WPLT30",
|
||||
"R_SPARC_COPY",
|
||||
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
|
||||
"R_SPARC_RELATIVE",
|
||||
"R_SPARC_UA32",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* This is stolen pretty directly from elf.c. */
|
||||
static bfd_reloc_status_type
|
||||
bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL
|
||||
&& (symbol->flags & BSF_SECTION_SYM) == 0
|
||||
&& reloc_entry->addend == 0)
|
||||
{
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
static reloc_howto_type coff_sparc_howto_table[] =
|
||||
{
|
||||
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", false,0,0x000000ff,true),
|
||||
HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,true),
|
||||
HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", false,0,0xffffffff,true),
|
||||
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,true),
|
||||
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,true),
|
||||
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,true),
|
||||
HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
|
||||
HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", false,0,0x00001fff,true),
|
||||
HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,true),
|
||||
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,true),
|
||||
};
|
||||
|
||||
struct coff_reloc_map {
|
||||
unsigned char bfd_reloc_val;
|
||||
unsigned char coff_reloc_val;
|
||||
};
|
||||
|
||||
static CONST struct coff_reloc_map sparc_reloc_map[] =
|
||||
{
|
||||
{ BFD_RELOC_NONE, R_SPARC_NONE, },
|
||||
{ BFD_RELOC_16, R_SPARC_16, },
|
||||
{ BFD_RELOC_8, R_SPARC_8 },
|
||||
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
|
||||
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
|
||||
{ BFD_RELOC_32, R_SPARC_32 },
|
||||
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
|
||||
{ BFD_RELOC_HI22, R_SPARC_HI22 },
|
||||
{ BFD_RELOC_LO10, R_SPARC_LO10, },
|
||||
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
|
||||
{ BFD_RELOC_SPARC22, R_SPARC_22 },
|
||||
{ BFD_RELOC_SPARC13, R_SPARC_13 },
|
||||
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
|
||||
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
|
||||
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
|
||||
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
|
||||
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
|
||||
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
|
||||
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
|
||||
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
|
||||
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
|
||||
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
|
||||
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
|
||||
/* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
|
||||
};
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_sparc_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
|
||||
{
|
||||
if (sparc_reloc_map[i].bfd_reloc_val == code)
|
||||
return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
|
||||
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
|
||||
cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
/* This is just like the standard one, except that we don't set up an
|
||||
addend for relocs against global symbols (otherwise linking objects
|
||||
created by -r fails), and we add in the reloc offset at the end. */
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = 0; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL \
|
||||
&& (ptr->flags & BSF_GLOBAL) == 0) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
cache_ptr->addend += reloc.r_offset; \
|
||||
}
|
||||
|
||||
/* Clear the r_spare field in relocs. */
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
||||
do { \
|
||||
dst->r_spare[0] = 0; \
|
||||
dst->r_spare[1] = 0; \
|
||||
} while (0)
|
||||
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Enable Sparc-specific hacks in coffcode.h. */
|
||||
|
||||
#define COFF_SPARC
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
sparccoff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-sparc", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,35 +0,0 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
|
||||
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68kcoffun_vec
|
||||
#define TARGET_NAME "coff-m68k-un"
|
||||
|
||||
#define NAMES_HAVE_UNDERSCORE
|
||||
|
||||
/* define this to not have multiple copy of m68k_rtype2howto
|
||||
in the executable file */
|
||||
#define ONLY_DECLARE_RELOCS
|
||||
|
||||
/* This magic number indicates that the names have underscores.
|
||||
Other 68k magic numbers indicate that the names do not have
|
||||
underscores. */
|
||||
#define BADMAG(x) ((x).f_magic != MC68KBCSMAGIC)
|
||||
|
||||
#include "coff-m68k.c"
|
@ -1,446 +0,0 @@
|
||||
/* BFD back-end for WDC 65816 COFF binaries.
|
||||
Copyright 1995 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/w65.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_W65_ABS8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "abs8", true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_W65_ABS16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_W65_ABS24, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs24", true, 0x00ffffff, 0x00ffffff, false),
|
||||
HOWTO (R_W65_ABS8S8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, ">abs8", true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_W65_ABS8S16, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "^abs8", true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_W65_ABS16S8, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, ">abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_W65_ABS16S16,1, 0, 16, false, 0, complain_overflow_bitfield, 0, "^abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_W65_PCR8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pcrel8", true, 0x000000ff, 0x000000ff, true),
|
||||
HOWTO (R_W65_PCR16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, true),
|
||||
HOWTO (R_W65_DP, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "dp", true, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#define SELECT_RELOC(x,howto) \
|
||||
{ x.r_type = select_reloc(howto); }
|
||||
|
||||
#define BADMAG(x) (W65BADMAG(x))
|
||||
#define W65 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
|
||||
static int
|
||||
select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type ;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
internal->howto = howto_table + dst->r_type - 1;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, 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;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = (asymbol **)&(bfd_abs_symbol);
|
||||
}
|
||||
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
|
||||
bfd *abfd;
|
||||
asection *input_section;
|
||||
arelent *reloc;
|
||||
unsigned int shrink;
|
||||
struct bfd_link_info *link_info;
|
||||
{
|
||||
bfd_vma value;
|
||||
bfd_vma dot;
|
||||
bfd_vma gap;
|
||||
|
||||
/* The address of the thing to be relocated will have moved back by
|
||||
the size of the shrink - but we don't change reloc->address here,
|
||||
since we need it to know where the relocation lives in the source
|
||||
uncooked section */
|
||||
|
||||
/* reloc->address -= shrink; conceptual */
|
||||
|
||||
bfd_vma address = reloc->address - shrink;
|
||||
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_MOVB2:
|
||||
case R_JMP2:
|
||||
shrink+=2;
|
||||
break;
|
||||
|
||||
/* Thing is a move one byte */
|
||||
case R_MOVB1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
if (value >= 0xff00)
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
|
||||
break;
|
||||
/* This is the 24 bit branch which could become an 8 bitter,
|
||||
the relocation points to the first byte of the insn, not the
|
||||
actual data */
|
||||
|
||||
case R_JMPL1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - dot ;
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||
possible 32 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMP1:
|
||||
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - (dot - shrink);
|
||||
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return shrink;
|
||||
}
|
||||
|
||||
|
||||
/* First phase of a relaxing link */
|
||||
|
||||
/* Reloc types
|
||||
large small
|
||||
R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
|
||||
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||
R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||
dst_ptr)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
unsigned int src_address = *src_ptr;
|
||||
unsigned int dst_address = *dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_W65_ABS8:
|
||||
case R_W65_DP:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS8S8:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 8;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS8S16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>=16;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
case R_W65_ABS16S8:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 8;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
case R_W65_ABS16S16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 16;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS24:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
bfd_put_8 (abfd, gap>>16, data+dst_address+2);
|
||||
dst_address += 3;
|
||||
src_address += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_PCR8:
|
||||
{
|
||||
int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
gap -= dot + 1;
|
||||
if (gap < -128 || gap > 127) {
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort();
|
||||
}
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_PCR16:
|
||||
{
|
||||
bfd_vma gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
|
||||
/* This wraps within the page, so ignore the relativeness, look at the
|
||||
high part */
|
||||
if ((gap & 0xf0000) != (dot & 0xf0000)) {
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort();
|
||||
}
|
||||
|
||||
gap -= dot + 2;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("ignoring reloc %s\n", reloc->howto->name);
|
||||
break;
|
||||
|
||||
}
|
||||
*src_ptr = src_address;
|
||||
*dst_ptr = dst_address;
|
||||
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
|
||||
#define coff_reloc16_estimate h8300_reloc16_estimate
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
|
||||
|
||||
bfd_target w65_vec =
|
||||
{
|
||||
"coff-w65", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,110 +0,0 @@
|
||||
/* BFD back-end for we32k COFF files.
|
||||
Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by Brendan Kehoe (brendan@cs.widener.edu).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/we32k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{0},
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
{4},
|
||||
{5},
|
||||
HOWTO(R_DIR32, 0, 2, 32, false, 0,complain_overflow_bitfield, 0, "dir32", true, 0xffffffff,0xffffffff, false),
|
||||
{7},
|
||||
{010},
|
||||
{011},
|
||||
{012},
|
||||
{013},
|
||||
{014},
|
||||
{015},
|
||||
{016},
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) WE32KBADMAG(x)
|
||||
#define WE32K 1
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#define coff_write_armap bsd_write_armap
|
||||
|
||||
const bfd_target we32kcoff_vec =
|
||||
{
|
||||
"coff-we32k", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
@ -1,281 +0,0 @@
|
||||
/* BFD back-end for Zilog Z800n COFF binaries.
|
||||
Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/z8k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
static reloc_howto_type r_imm32 =
|
||||
HOWTO (R_IMM32, 0, 1, 32, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
|
||||
0xffffffff, false);
|
||||
|
||||
static reloc_howto_type r_imm4l =
|
||||
HOWTO (R_IMM4L, 0, 1, 4, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);
|
||||
|
||||
static reloc_howto_type r_da =
|
||||
HOWTO (R_IMM16, 0, 1, 16, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_da", true, 0x0000ffff, 0x0000ffff,
|
||||
false);
|
||||
|
||||
static reloc_howto_type r_imm8 =
|
||||
HOWTO (R_IMM8, 0, 1, 8, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,
|
||||
false);
|
||||
|
||||
static reloc_howto_type r_jr =
|
||||
HOWTO (R_JR, 0, 1, 8, true, 0, complain_overflow_signed, 0,
|
||||
"r_jr", true, 0, 0, true);
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
static int
|
||||
coff_z8k_select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_z8k_select_reloc(howto)
|
||||
|
||||
|
||||
#define BADMAG(x) Z8KBADMAG(x)
|
||||
#define Z8K 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent * internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
case R_IMM8:
|
||||
internal->howto = &r_imm8;
|
||||
break;
|
||||
case R_IMM16:
|
||||
internal->howto = &r_da;
|
||||
break;
|
||||
case R_JR:
|
||||
internal->howto = &r_jr;
|
||||
break;
|
||||
case R_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_IMM4L:
|
||||
internal->howto = &r_imm4l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, 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;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (reloc->r_symndx > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
static void
|
||||
extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
|
||||
bfd *in_abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_IMM8:
|
||||
bfd_put_8 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_IMM32:
|
||||
bfd_put_32 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr) += 4;
|
||||
(*src_ptr) += 4;
|
||||
break;
|
||||
|
||||
case R_IMM4L:
|
||||
bfd_put_8 (in_abfd,
|
||||
((bfd_get_8 (in_abfd, data + *dst_ptr) & 0xf0)
|
||||
| (0x0f
|
||||
& bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section))),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_IMM16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + *dst_ptr);
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_JR:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = (link_order->offset
|
||||
+ *dst_ptr
|
||||
+ input_section->output_section->vma);
|
||||
int gap = dst - dot - 1;/* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented */
|
||||
|
||||
if (gap & 1)
|
||||
abort ();
|
||||
gap /= 2;
|
||||
if (gap > 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
const bfd_target z8kcoff_vec =
|
||||
{
|
||||
"coff-z8k", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
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 */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
||||
@echo off
|
||||
if "%1" == "h8/300" goto h8300
|
||||
|
||||
echo Configuring bfd for go32
|
||||
update hosts\go32.h sysdep.h
|
||||
update Makefile.dos Makefile
|
||||
echo s/@WORDSIZE@/32/g>config.sed
|
||||
sed -e s/^/s\/@VERSION@\// -e s/$/\/g/g version >>config.sed
|
||||
sed -f config.sed < bfd-in2.h > bfd.h2
|
||||
update bfd.h2 bfd.h
|
||||
goto exit
|
||||
|
||||
:h8300
|
||||
echo Configuring bfd for H8/300
|
||||
update hosts\h-go32.h sysdep.h
|
||||
update Makefile.dos Makefile
|
||||
|
||||
:exit
|
@ -1,39 +0,0 @@
|
||||
/* BFD support for the AMD 29000 architecture.
|
||||
Copyright 1992 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_a29k_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_a29k,
|
||||
0, /* only 1 machine */
|
||||
"a29k",
|
||||
"a29k",
|
||||
4,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,38 +0,0 @@
|
||||
/* BFD support for the Alpha architecture.
|
||||
Copyright 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_alpha_arch =
|
||||
{
|
||||
64, /* 32 bits in a word */
|
||||
64, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_alpha,
|
||||
0, /* only 1 machine */
|
||||
"alpha",
|
||||
"alpha",
|
||||
3,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,39 +0,0 @@
|
||||
/* BFD support for the ARM processor
|
||||
Copyright 1994 Free Software Foundation, Inc.
|
||||
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_arm_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_arm,
|
||||
0, /* only 1 machine */
|
||||
"arm",
|
||||
"arm",
|
||||
4,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,246 +0,0 @@
|
||||
/* BFD library support routines for the Hitachi H8/300 architecture.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#if 0 /* not used currently */
|
||||
/*
|
||||
Relocations for the H8
|
||||
|
||||
*/
|
||||
static bfd_reloc_status_type
|
||||
howto16_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd * abfd;
|
||||
arelent * reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection * ignore_input_section;
|
||||
bfd * ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd * abfd;
|
||||
arelent * reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection * ignore_input_section;
|
||||
bfd * ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd * abfd;
|
||||
arelent * reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection * ignore_input_section;
|
||||
bfd * ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
|
||||
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||
abort ();
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd * abfd;
|
||||
arelent * reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection * ignore_input_section;
|
||||
bfd * ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||
abort ();
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_16
|
||||
= NEWHOWTO (howto16_callback, "abs16", 1, false, false);
|
||||
static reloc_howto_type howto_8
|
||||
= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
|
||||
|
||||
static reloc_howto_type howto_8_FFnn
|
||||
= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
|
||||
|
||||
static reloc_howto_type howto_8_pcrel
|
||||
= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
|
||||
|
||||
static reloc_howto_type *
|
||||
local_bfd_reloc_type_lookup (arch, code)
|
||||
const struct bfd_arch_info *arch;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_16:
|
||||
return &howto_16;
|
||||
case BFD_RELOC_8_FFnn:
|
||||
return &howto_8_FFnn;
|
||||
case BFD_RELOC_8:
|
||||
return &howto_8;
|
||||
case BFD_RELOC_8_PCREL:
|
||||
return &howto_8_pcrel;
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int bfd_default_scan_num_mach ();
|
||||
|
||||
static boolean
|
||||
h8300_scan (info, string)
|
||||
const struct bfd_arch_info *info;
|
||||
const char *string;
|
||||
{
|
||||
if (*string != 'h' && *string != 'H')
|
||||
return false;
|
||||
|
||||
string++;
|
||||
if (*string != '8')
|
||||
return false;
|
||||
|
||||
string++;
|
||||
if (*string == '/')
|
||||
string++;
|
||||
|
||||
if (*string != '3')
|
||||
return false;
|
||||
string++;
|
||||
if (*string != '0')
|
||||
return false;
|
||||
string++;
|
||||
if (*string != '0')
|
||||
return false;
|
||||
string++;
|
||||
if (*string == '-')
|
||||
string++;
|
||||
if (*string == 'h' || *string == 'H')
|
||||
{
|
||||
return (info->mach == bfd_mach_h8300h);
|
||||
}
|
||||
else
|
||||
{
|
||||
return info->mach == bfd_mach_h8300;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* This routine is provided two arch_infos and works out the
|
||||
machine which would be compatible with both and returns a pointer
|
||||
to its info structure */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (in, out)
|
||||
const bfd_arch_info_type * in;
|
||||
const bfd_arch_info_type * out;
|
||||
{
|
||||
/* If the output is non-H and the input is -H, that's bad */
|
||||
if (in->mach == bfd_mach_h8300h &&
|
||||
out->mach == bfd_mach_h8300)
|
||||
return 0;
|
||||
|
||||
/* If either is an -H, the answer is -H */
|
||||
if (in->mach == bfd_mach_h8300h)
|
||||
return in;
|
||||
return out;
|
||||
}
|
||||
|
||||
static const bfd_arch_info_type h8300_info_struct =
|
||||
{
|
||||
16, /* 16 bits in a word */
|
||||
16, /* 16 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_h8300,
|
||||
bfd_mach_h8300,
|
||||
"h8300", /* arch_name */
|
||||
"h8300", /* printable name */
|
||||
1,
|
||||
true, /* the default machine */
|
||||
compatible,
|
||||
h8300_scan,
|
||||
/* local_bfd_reloc_type_lookup, */
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
const bfd_arch_info_type bfd_h8300_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_h8300,
|
||||
bfd_mach_h8300h,
|
||||
"h8300h", /* arch_name */
|
||||
"h8300h", /* printable name */
|
||||
1,
|
||||
false, /* the default machine */
|
||||
compatible,
|
||||
h8300_scan,
|
||||
/* local_bfd_reloc_type_lookup, */
|
||||
&h8300_info_struct,
|
||||
};
|
@ -1,199 +0,0 @@
|
||||
/* BFD library support routines for the H8/500 architecture.
|
||||
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
Relocations for the Z8K
|
||||
|
||||
*/
|
||||
static bfd_reloc_status_type
|
||||
howto16_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
|
||||
|
||||
HOWTO_PREPARE(relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_16(abfd, x, (bfd_byte *)data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
|
||||
|
||||
HOWTO_PREPARE(relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8(abfd, x, (bfd_byte *)data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
|
||||
long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
|
||||
abort();
|
||||
HOWTO_PREPARE(relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8(abfd, x, (bfd_byte *)data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
|
||||
abort();
|
||||
HOWTO_PREPARE(relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8(abfd, x, (bfd_byte *)data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static reloc_howto_type howto_16
|
||||
= NEWHOWTO(howto16_callback,"abs16",1,false,false);
|
||||
static reloc_howto_type howto_8
|
||||
= NEWHOWTO(howto8_callback,"abs8",0,false,false);
|
||||
|
||||
static reloc_howto_type howto_8_FFnn
|
||||
= NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
|
||||
|
||||
static reloc_howto_type howto_8_pcrel
|
||||
= NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
|
||||
|
||||
|
||||
static reloc_howto_type *
|
||||
local_bfd_reloc_type_lookup (arch, code)
|
||||
const struct bfd_arch_info *arch;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code) {
|
||||
case BFD_RELOC_16:
|
||||
return &howto_16;
|
||||
case BFD_RELOC_8_FFnn:
|
||||
return &howto_8_FFnn;
|
||||
case BFD_RELOC_8:
|
||||
return &howto_8;
|
||||
case BFD_RELOC_8_PCREL:
|
||||
return &howto_8_pcrel;
|
||||
}
|
||||
return (reloc_howto_type *)NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int bfd_default_scan_num_mach();
|
||||
|
||||
static boolean
|
||||
scan_mach (info, string)
|
||||
const struct bfd_arch_info *info;
|
||||
const char *string;
|
||||
{
|
||||
if (strcmp(string,"h8/500") == 0) return true;
|
||||
if (strcmp(string,"H8/500") == 0) return true;
|
||||
if (strcmp(string,"h8500") == 0) return true;
|
||||
if (strcmp(string,"H8500") == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if 0 /* not used currently */
|
||||
/* This routine is provided two arch_infos and returns whether
|
||||
they'd be compatible */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (a,b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
if (a->arch != b->arch || a->mach != b->mach)
|
||||
return NULL;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
const bfd_arch_info_type bfd_h8500_arch =
|
||||
{
|
||||
16, /* 16 bits in a word */
|
||||
24, /* 24 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_h8500,
|
||||
0, /* only 1 machine */
|
||||
"h8500", /* arch_name */
|
||||
"h8500", /* printable name */
|
||||
1,
|
||||
true, /* the default machine */
|
||||
bfd_default_compatible,
|
||||
scan_mach,
|
||||
0,
|
||||
};
|
@ -1,54 +0,0 @@
|
||||
/* BFD support for the HP Precision Architecture architecture.
|
||||
Copyright 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
static const bfd_arch_info_type bfd_hppa10_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_hppa,
|
||||
10, /* By convention PA1.0 = 10 */
|
||||
"hppa",
|
||||
"hppa1.0",
|
||||
3,
|
||||
true, /* Unless we use 1.1 specific features */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_hppa_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_hppa,
|
||||
11, /* By convention PA1.1 = 11 */
|
||||
"hppa",
|
||||
"hppa1.1",
|
||||
3,
|
||||
false, /* 1.1 specific features used */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
&bfd_hppa10_arch,
|
||||
};
|
@ -1,40 +0,0 @@
|
||||
/* BFD support for the Intel 860 architecture.
|
||||
Copyright 1992, 1995 Free Software Foundation, Inc.
|
||||
Created mostly by substituting "860" for "386" in cpu-i386.c
|
||||
Harry Dolan <dolan@ssd.intel.com>, October 1995
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_i860_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_i860,
|
||||
0, /* only 1 machine */
|
||||
"i860",
|
||||
"i860",
|
||||
3,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,162 +0,0 @@
|
||||
/* BFD library support routines for the i960 architecture.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
/* This routine is provided a string, and tries to work out if it
|
||||
could possibly refer to the i960 machine pointed at in the
|
||||
info_struct pointer */
|
||||
|
||||
static boolean
|
||||
scan_960_mach (ap, string)
|
||||
const bfd_arch_info_type *ap;
|
||||
const char *string;
|
||||
{
|
||||
unsigned long machine;
|
||||
|
||||
/* Look for the string i960, or somesuch at the front of the string */
|
||||
|
||||
if (strncmp("i960",string,4) == 0) {
|
||||
string+=4;
|
||||
}
|
||||
else {
|
||||
/* no match, can be us */
|
||||
return false;
|
||||
}
|
||||
if (string[0] == 0) {
|
||||
/* i960 on it's own means core to us*/
|
||||
if (ap->mach == bfd_mach_i960_core) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string[0] != ':') {
|
||||
return false;
|
||||
}
|
||||
string++;
|
||||
if (string[0] == '\0')
|
||||
return false;
|
||||
if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
|
||||
string[3] == 'e' && string[4] == '\0')
|
||||
machine = bfd_mach_i960_core;
|
||||
else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char */
|
||||
return false;
|
||||
else if (string[0] == 'k' && string[1] == 'b')
|
||||
machine = bfd_mach_i960_kb_sb;
|
||||
else if (string[0] == 's' && string[1] == 'b')
|
||||
machine = bfd_mach_i960_kb_sb;
|
||||
else if (string[0] == 'm' && string[1] == 'c')
|
||||
machine = bfd_mach_i960_mc;
|
||||
else if (string[0] == 'x' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_xa;
|
||||
else if (string[0] == 'c' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_ca;
|
||||
else if (string[0] == 'k' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_ka_sa;
|
||||
else if (string[0] == 's' && string[1] == 'a')
|
||||
machine = bfd_mach_i960_ka_sa;
|
||||
else if (string[0] == 'j' && string[1] == 'x')
|
||||
machine = bfd_mach_i960_jx;
|
||||
else if (string[0] == 'h' && string[1] == 'x')
|
||||
machine = bfd_mach_i960_hx;
|
||||
else
|
||||
return false;
|
||||
if (machine == ap->mach) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* This routine is provided two arch_infos and works out the i960
|
||||
machine which would be compatible with both and returns a pointer
|
||||
to its info structure */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (a,b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
|
||||
/* The i960 has distinct subspecies which may not interbreed:
|
||||
CORE CA
|
||||
CORE KA KB MC XA
|
||||
CORE HX JX
|
||||
Any architecture on the same line is compatible, the one on
|
||||
the right is the least restrictive.
|
||||
|
||||
We represent this information in an array, each machine to a side */
|
||||
|
||||
#define ERROR 0
|
||||
#define CORE bfd_mach_i960_core /*1*/
|
||||
#define KA bfd_mach_i960_ka_sa /*2*/
|
||||
#define KB bfd_mach_i960_kb_sb /*3*/
|
||||
#define MC bfd_mach_i960_mc /*4*/
|
||||
#define XA bfd_mach_i960_xa /*5*/
|
||||
#define CA bfd_mach_i960_ca /*6*/
|
||||
#define JX bfd_mach_i960_jx /*7*/
|
||||
#define HX bfd_mach_i960_hx /*8*/
|
||||
#define MAX_ARCH ((int)HX)
|
||||
|
||||
static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
|
||||
{
|
||||
{ ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
|
||||
{ CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
|
||||
{ KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
|
||||
{ KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
|
||||
{ MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
|
||||
{ XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
|
||||
{ CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
|
||||
{ JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
|
||||
{ HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
|
||||
};
|
||||
|
||||
|
||||
if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (a->mach == matrix[a->mach][b->mach]) ? a : b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int bfd_default_scan_num_mach();
|
||||
#define N(a,b,d,n) \
|
||||
{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
N(bfd_mach_i960_ka_sa,"i960:ka_sa",false, &arch_info_struct[1]),
|
||||
N(bfd_mach_i960_kb_sb,"i960:kb_sb",false, &arch_info_struct[2]),
|
||||
N(bfd_mach_i960_mc, "i960:mc", false, &arch_info_struct[3]),
|
||||
N(bfd_mach_i960_xa, "i960:xa", false, &arch_info_struct[4]),
|
||||
N(bfd_mach_i960_ca, "i960:ca", false, &arch_info_struct[5]),
|
||||
N(bfd_mach_i960_jx, "i960:jx", false, &arch_info_struct[6]),
|
||||
N(bfd_mach_i960_hx, "i960:hx", false, 0),
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_i960_arch =
|
||||
N(bfd_mach_i960_core, "i960:core", true, &arch_info_struct[0]);
|
@ -1,42 +0,0 @@
|
||||
/* BFD library support routines for architectures.
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
int bfd_default_scan_num_mach();
|
||||
|
||||
|
||||
#define N(name, print,d,next) \
|
||||
{ 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_default_compatible,bfd_default_scan, next, }
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
N(68008,"m68k:68008",false, &arch_info_struct[1]),
|
||||
N(68010,"m68k:68010",false, &arch_info_struct[2]),
|
||||
N(68020,"m68k:68020",true, &arch_info_struct[3]),
|
||||
N(68030,"m68k:68030",false, &arch_info_struct[4]),
|
||||
N(68040,"m68k:68040",false, &arch_info_struct[5]),
|
||||
N(68070,"m68k:68070",false, 0),
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_m68k_arch =
|
||||
N(68000,"m68k:68000",false, &arch_info_struct[0]);
|
@ -1,42 +0,0 @@
|
||||
/* bfd back-end for m88k support
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
|
||||
|
||||
const bfd_arch_info_type bfd_m88k_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_m88k,
|
||||
88100, /* only 1 machine */
|
||||
"m88k",
|
||||
"m88k:88100",
|
||||
3,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,85 +0,0 @@
|
||||
/* bfd back-end for mips support
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_mips,
|
||||
6000,
|
||||
"mips",
|
||||
"mips:6000",
|
||||
3,
|
||||
false,
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[1],
|
||||
},
|
||||
{
|
||||
64, /* 64 bits in a word */
|
||||
64, /* 64 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_mips,
|
||||
4000,
|
||||
"mips",
|
||||
"mips:4000",
|
||||
3,
|
||||
false,
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
&arch_info_struct[2],
|
||||
},
|
||||
{
|
||||
64, /* 64 bits in a word */
|
||||
64, /* 64 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_mips,
|
||||
8000,
|
||||
"mips",
|
||||
"mips:8000",
|
||||
3,
|
||||
false,
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
}
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_mips_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_mips,
|
||||
3000,
|
||||
"mips",
|
||||
"mips:3000",
|
||||
3,
|
||||
true,
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[0],
|
||||
};
|
@ -1,868 +0,0 @@
|
||||
/* BFD support for the ns32k architecture.
|
||||
Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
|
||||
Almost totally rewritten by Ian Dall from initial work
|
||||
by Andrew Cagney.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||
int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||
long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||
int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
|
||||
struct symbol_cache_entry *symbol,
|
||||
PTR data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message));
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_imm PARAMS ((bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
struct symbol_cache_entry *symbol,
|
||||
PTR data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message));
|
||||
bfd_reloc_status_type ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
asection *input_section,
|
||||
bfd_byte *contents,
|
||||
bfd_vma address,
|
||||
bfd_vma value,
|
||||
bfd_vma addend ));
|
||||
bfd_reloc_status_type ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
bfd_vma relocation,
|
||||
bfd_byte *location));
|
||||
|
||||
int bfd_default_scan_num_mach();
|
||||
|
||||
#define N(machine, printable, d, next) \
|
||||
{ 32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d,bfd_default_compatible,bfd_default_scan, next, }
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
N(32532,"ns32k:32532",true, 0), /* the word ns32k will match this too */
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_ns32k_arch =
|
||||
N(32032,"ns32k:32032",false, &arch_info_struct[0]);
|
||||
|
||||
static long
|
||||
ns32k_sign_extend(value, bits)
|
||||
int value;
|
||||
int bits;
|
||||
{
|
||||
value = value & ((1 << bits) - 1);
|
||||
return (value & (1 << (bits-1))
|
||||
? value | (~((1 << bits) - 1))
|
||||
: value);
|
||||
}
|
||||
|
||||
long
|
||||
ns32k_get_displacement(buffer, offset, size)
|
||||
bfd_byte *buffer;
|
||||
long offset;
|
||||
long size;
|
||||
{
|
||||
long value;
|
||||
buffer += offset;
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
value = ns32k_sign_extend (*buffer, 7);
|
||||
break;
|
||||
case 2:
|
||||
value = ns32k_sign_extend(*buffer++, 6);
|
||||
value = (value << 8) | (0xff & *buffer);
|
||||
break;
|
||||
case 4:
|
||||
value = ns32k_sign_extend(*buffer++, 6);
|
||||
value = (value << 8) | (0xff & *buffer++);
|
||||
value = (value << 8) | (0xff & *buffer++);
|
||||
value = (value << 8) | (0xff & *buffer);
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int
|
||||
ns32k_put_displacement(value, buffer, offset, size)
|
||||
long value;
|
||||
bfd_byte *buffer;
|
||||
long offset;
|
||||
long size;
|
||||
{
|
||||
buffer += offset;
|
||||
switch (size)
|
||||
{
|
||||
case 1:
|
||||
if (value < -64 || value > 63)
|
||||
return -1;
|
||||
value&=0x7f;
|
||||
*buffer++=value;
|
||||
break;
|
||||
case 2:
|
||||
if (value < -8192 || value > 8191)
|
||||
return -1;
|
||||
value&=0x3fff;
|
||||
value|=0x8000;
|
||||
*buffer++=(value>>8);
|
||||
*buffer++=value;
|
||||
break;
|
||||
case 4:
|
||||
if (value < -0x1f000000 || value >= 0x20000000)
|
||||
return -1;
|
||||
value|=0xc0000000;
|
||||
*buffer++=(value>>24);
|
||||
*buffer++=(value>>16);
|
||||
*buffer++=(value>>8);
|
||||
*buffer++=value;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
long
|
||||
ns32k_get_immediate(buffer, offset, size)
|
||||
bfd_byte *buffer;
|
||||
long offset;
|
||||
long size;
|
||||
{
|
||||
long value = 0;
|
||||
buffer += offset;
|
||||
switch (size)
|
||||
{
|
||||
case 4:
|
||||
value = (value << 8) | (*buffer++ & 0xff);
|
||||
case 3:
|
||||
value = (value << 8) | (*buffer++ & 0xff);
|
||||
case 2:
|
||||
value = (value << 8) | (*buffer++ & 0xff);
|
||||
case 1:
|
||||
value = (value << 8) | (*buffer++ & 0xff);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int
|
||||
ns32k_put_immediate (value, buffer, offset, size)
|
||||
long value;
|
||||
bfd_byte *buffer;
|
||||
long offset;
|
||||
long size;
|
||||
{
|
||||
buffer += offset + size - 1;
|
||||
switch (size)
|
||||
{
|
||||
case 4:
|
||||
*buffer-- = (value & 0xff); value >>= 8;
|
||||
case 3:
|
||||
*buffer-- = (value & 0xff); value >>= 8;
|
||||
case 2:
|
||||
*buffer-- = (value & 0xff); value >>= 8;
|
||||
case 1:
|
||||
*buffer-- = (value & 0xff); value >>= 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is just like the standard perform_relocation except we
|
||||
* use get_data and put_data which know about the ns32k
|
||||
* storage methods.
|
||||
* This is probably a lot more complicated than it needs to be!
|
||||
*/
|
||||
static bfd_reloc_status_type
|
||||
do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message, get_data, put_data)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
long (*get_data)();
|
||||
int (*put_data)();
|
||||
{
|
||||
int overflow = 0;
|
||||
bfd_vma relocation;
|
||||
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
bfd_vma output_base = 0;
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
asection *reloc_target_output_section;
|
||||
|
||||
if ((symbol->section == &bfd_abs_section)
|
||||
&& output_bfd != (bfd *) NULL)
|
||||
{
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* If we are not producing relocateable output, return an error if
|
||||
the symbol is not defined. An undefined weak symbol is
|
||||
considered to have a value of zero (SVR4 ABI, p. 4-27). */
|
||||
if (symbol->section == &bfd_und_section
|
||||
&& (symbol->flags & BSF_WEAK) == 0
|
||||
&& output_bfd == (bfd *) NULL)
|
||||
flag = bfd_reloc_undefined;
|
||||
|
||||
|
||||
/* Is the address of the relocation really within the section? */
|
||||
if (reloc_entry->address > input_section->_cooked_size)
|
||||
return bfd_reloc_outofrange;
|
||||
|
||||
/* Work out which section the relocation is targetted at and the
|
||||
initial relocation command value. */
|
||||
|
||||
/* Get symbol value. (Common symbols are special.) */
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value;
|
||||
|
||||
|
||||
reloc_target_output_section = symbol->section->output_section;
|
||||
|
||||
/* Convert input-section-relative symbol value to absolute. */
|
||||
if (output_bfd && howto->partial_inplace == false)
|
||||
output_base = 0;
|
||||
else
|
||||
output_base = reloc_target_output_section->vma;
|
||||
|
||||
relocation += output_base + symbol->section->output_offset;
|
||||
|
||||
/* Add in supplied addend. */
|
||||
relocation += reloc_entry->addend;
|
||||
|
||||
/* Here the variable relocation holds the final address of the
|
||||
symbol we are relocating against, plus any addend. */
|
||||
|
||||
if (howto->pc_relative == true)
|
||||
{
|
||||
/* This is a PC relative relocation. We want to set RELOCATION
|
||||
to the distance between the address of the symbol and the
|
||||
location. RELOCATION is already the address of the symbol.
|
||||
|
||||
We start by subtracting the address of the section containing
|
||||
the location.
|
||||
|
||||
If pcrel_offset is set, we must further subtract the position
|
||||
of the location within the section. Some targets arrange for
|
||||
the addend to be the negative of the position of the location
|
||||
within the section; for example, i386-aout does this. For
|
||||
i386-aout, pcrel_offset is false. Some other targets do not
|
||||
include the position of the location; for example, m88kbcs,
|
||||
or ELF. For those targets, pcrel_offset is true.
|
||||
|
||||
If we are producing relocateable output, then we must ensure
|
||||
that this reloc will be correctly computed when the final
|
||||
relocation is done. If pcrel_offset is false we want to wind
|
||||
up with the negative of the location within the section,
|
||||
which means we must adjust the existing addend by the change
|
||||
in the location within the section. If pcrel_offset is true
|
||||
we do not want to adjust the existing addend at all.
|
||||
|
||||
FIXME: This seems logical to me, but for the case of
|
||||
producing relocateable output it is not what the code
|
||||
actually does. I don't want to change it, because it seems
|
||||
far too likely that something will break. */
|
||||
|
||||
relocation -=
|
||||
input_section->output_section->vma + input_section->output_offset;
|
||||
|
||||
if (howto->pcrel_offset == true)
|
||||
relocation -= reloc_entry->address;
|
||||
}
|
||||
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
if (howto->partial_inplace == false)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the relocation
|
||||
to the reloc entry rather than the raw data. Modify the reloc
|
||||
inplace to reflect what we now know. */
|
||||
reloc_entry->addend = relocation;
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is a partial relocation, but inplace, so modify the
|
||||
reloc record a bit.
|
||||
|
||||
If we've relocated with a symbol with a section, change
|
||||
into a ref to the section belonging to the symbol. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
|
||||
/* WTF?? */
|
||||
if (abfd->xvec->flavour == bfd_target_coff_flavour
|
||||
&& strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0)
|
||||
{
|
||||
#if 1
|
||||
/* For m68k-coff, the addend was being subtracted twice during
|
||||
relocation with -r. Removing the line below this comment
|
||||
fixes that problem; see PR 2953.
|
||||
|
||||
However, Ian wrote the following, regarding removing the line below,
|
||||
which explains why it is still enabled: --djm
|
||||
|
||||
If you put a patch like that into BFD you need to check all the COFF
|
||||
linkers. I am fairly certain that patch will break coff-i386 (e.g.,
|
||||
SCO); see coff_i386_reloc in coff-i386.c where I worked around the
|
||||
problem in a different way. There may very well be a reason that the
|
||||
code works as it does.
|
||||
|
||||
Hmmm. The first obvious point is that bfd_perform_relocation should
|
||||
not have any tests that depend upon the flavour. It's seem like
|
||||
entirely the wrong place for such a thing. The second obvious point
|
||||
is that the current code ignores the reloc addend when producing
|
||||
relocateable output for COFF. That's peculiar. In fact, I really
|
||||
have no idea what the point of the line you want to remove is.
|
||||
|
||||
A typical COFF reloc subtracts the old value of the symbol and adds in
|
||||
the new value to the location in the object file (if it's a pc
|
||||
relative reloc it adds the difference between the symbol value and the
|
||||
location). When relocating we need to preserve that property.
|
||||
|
||||
BFD handles this by setting the addend to the negative of the old
|
||||
value of the symbol. Unfortunately it handles common symbols in a
|
||||
non-standard way (it doesn't subtract the old value) but that's a
|
||||
different story (we can't change it without losing backward
|
||||
compatibility with old object files) (coff-i386 does subtract the old
|
||||
value, to be compatible with existing coff-i386 targets, like SCO).
|
||||
|
||||
So everything works fine when not producing relocateable output. When
|
||||
we are producing relocateable output, logically we should do exactly
|
||||
what we do when not producing relocateable output. Therefore, your
|
||||
patch is correct. In fact, it should probably always just set
|
||||
reloc_entry->addend to 0 for all cases, since it is, in fact, going to
|
||||
add the value into the object file. This won't hurt the COFF code,
|
||||
which doesn't use the addend; I'm not sure what it will do to other
|
||||
formats (the thing to check for would be whether any formats both use
|
||||
the addend and set partial_inplace).
|
||||
|
||||
When I wanted to make coff-i386 produce relocateable output, I ran
|
||||
into the problem that you are running into: I wanted to remove that
|
||||
line. Rather than risk it, I made the coff-i386 relocs use a special
|
||||
function; it's coff_i386_reloc in coff-i386.c. The function
|
||||
specifically adds the addend field into the object file, knowing that
|
||||
bfd_perform_relocation is not going to. If you remove that line, then
|
||||
coff-i386.c will wind up adding the addend field in twice. It's
|
||||
trivial to fix; it just needs to be done.
|
||||
|
||||
The problem with removing the line is just that it may break some
|
||||
working code. With BFD it's hard to be sure of anything. The right
|
||||
way to deal with this is simply to build and test at least all the
|
||||
supported COFF targets. It should be straightforward if time and disk
|
||||
space consuming. For each target:
|
||||
1) build the linker
|
||||
2) generate some executable, and link it using -r (I would
|
||||
probably use paranoia.o and link against newlib/libc.a, which
|
||||
for all the supported targets would be available in
|
||||
/usr/cygnus/progressive/H-host/target/lib/libc.a).
|
||||
3) make the change to reloc.c
|
||||
4) rebuild the linker
|
||||
5) repeat step 2
|
||||
6) if the resulting object files are the same, you have at least
|
||||
made it no worse
|
||||
7) if they are different you have to figure out which version is
|
||||
right
|
||||
*/
|
||||
relocation -= reloc_entry->addend;
|
||||
#endif
|
||||
reloc_entry->addend = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
reloc_entry->addend = relocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reloc_entry->addend = 0;
|
||||
}
|
||||
|
||||
/* FIXME: This overflow checking is incomplete, because the value
|
||||
might have overflowed before we get here. For a correct check we
|
||||
need to compute the value in a size larger than bitsize, but we
|
||||
can't reasonably do that for a reloc the same size as a host
|
||||
machine word.
|
||||
FIXME: We should also do overflow checking on the result after
|
||||
adding in the value contained in the object file. */
|
||||
if (howto->complain_on_overflow != complain_overflow_dont)
|
||||
{
|
||||
bfd_vma check;
|
||||
|
||||
/* Get the value that will be used for the relocation, but
|
||||
starting at bit position zero. */
|
||||
if (howto->rightshift > howto->bitpos)
|
||||
check = relocation >> (howto->rightshift - howto->bitpos);
|
||||
else
|
||||
check = relocation << (howto->bitpos - howto->rightshift);
|
||||
switch (howto->complain_on_overflow)
|
||||
{
|
||||
case complain_overflow_signed:
|
||||
{
|
||||
/* Assumes two's complement. */
|
||||
bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
|
||||
bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
|
||||
|
||||
/* The above right shift is incorrect for a signed value.
|
||||
Fix it up by forcing on the upper bits. */
|
||||
if (howto->rightshift > howto->bitpos
|
||||
&& (bfd_signed_vma) relocation < 0)
|
||||
check |= ((bfd_vma) - 1
|
||||
& ~((bfd_vma) - 1
|
||||
>> (howto->rightshift - howto->bitpos)));
|
||||
if ((bfd_signed_vma) check > reloc_signed_max
|
||||
|| (bfd_signed_vma) check < reloc_signed_min)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
break;
|
||||
case complain_overflow_unsigned:
|
||||
{
|
||||
/* Assumes two's complement. This expression avoids
|
||||
overflow if howto->bitsize is the number of bits in
|
||||
bfd_vma. */
|
||||
bfd_vma reloc_unsigned_max =
|
||||
(((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||
|
||||
if ((bfd_vma) check > reloc_unsigned_max)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
break;
|
||||
case complain_overflow_bitfield:
|
||||
{
|
||||
/* Assumes two's complement. This expression avoids
|
||||
overflow if howto->bitsize is the number of bits in
|
||||
bfd_vma. */
|
||||
bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||
|
||||
if (((bfd_vma) check & ~reloc_bits) != 0
|
||||
&& ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
|
||||
{
|
||||
/* The above right shift is incorrect for a signed
|
||||
value. See if turning on the upper bits fixes the
|
||||
overflow. */
|
||||
if (howto->rightshift > howto->bitpos
|
||||
&& (bfd_signed_vma) relocation < 0)
|
||||
{
|
||||
check |= ((bfd_vma) - 1
|
||||
& ~((bfd_vma) - 1
|
||||
>> (howto->rightshift - howto->bitpos)));
|
||||
if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Either we are relocating all the way, or we don't want to apply
|
||||
the relocation to the reloc entry (probably because there isn't
|
||||
any room in the output format to describe addends to relocs)
|
||||
*/
|
||||
|
||||
/* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
|
||||
(OSF version 1.3, compiler version 3.11). It miscompiles the
|
||||
following program:
|
||||
|
||||
struct str
|
||||
{
|
||||
unsigned int i0;
|
||||
} s = { 0 };
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
unsigned long x;
|
||||
|
||||
x = 0x100000000;
|
||||
x <<= (unsigned long) s.i0;
|
||||
if (x == 0)
|
||||
printf ("failed\n");
|
||||
else
|
||||
printf ("succeeded (%lx)\n", x);
|
||||
}
|
||||
*/
|
||||
|
||||
relocation >>= (bfd_vma) howto->rightshift;
|
||||
|
||||
/* Shift everything up to where it's going to be used */
|
||||
|
||||
relocation <<= (bfd_vma) howto->bitpos;
|
||||
|
||||
/* Wait for the day when all have the mask in them */
|
||||
|
||||
/* What we do:
|
||||
i instruction to be left alone
|
||||
o offset within instruction
|
||||
r relocation offset to apply
|
||||
S src mask
|
||||
D dst mask
|
||||
N ~dst mask
|
||||
A part 1
|
||||
B part 2
|
||||
R result
|
||||
|
||||
Do this:
|
||||
i i i i i o o o o o from bfd_get<size>
|
||||
and S S S S S to get the size offset we want
|
||||
+ r r r r r r r r r r to get the final value to place
|
||||
and D D D D D to chop to right size
|
||||
-----------------------
|
||||
A A A A A
|
||||
And this:
|
||||
... i i i i i o o o o o from bfd_get<size>
|
||||
and N N N N N get instruction
|
||||
-----------------------
|
||||
... B B B B B
|
||||
|
||||
And then:
|
||||
B B B B B
|
||||
or A A A A A
|
||||
-----------------------
|
||||
R R R R R R R R R R put into bfd_put<size>
|
||||
*/
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = get_data (data, addr, 1);
|
||||
DOIT (x);
|
||||
overflow = put_data(x, data, addr, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (relocation)
|
||||
{
|
||||
short x = get_data (data, addr, 2);
|
||||
DOIT (x);
|
||||
overflow = put_data(x, (unsigned char *) data, addr, 2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (relocation)
|
||||
{
|
||||
long x = get_data (data, addr, 4);
|
||||
DOIT (x);
|
||||
overflow = put_data(x, data, addr, 4);
|
||||
}
|
||||
break;
|
||||
case -2:
|
||||
{
|
||||
long x = get_data(data, addr, 4);
|
||||
relocation = -relocation;
|
||||
DOIT(x);
|
||||
overflow = put_data(x, data , addr, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* Do nothing */
|
||||
break;
|
||||
|
||||
case 4:
|
||||
#ifdef BFD64
|
||||
if (relocation)
|
||||
{
|
||||
bfd_vma x = get_data (data, addr, 8);
|
||||
DOIT (x);
|
||||
overflow = put_data(x, data, addr, 8);
|
||||
}
|
||||
#else
|
||||
abort ();
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
return bfd_reloc_other;
|
||||
}
|
||||
if ((howto->complain_on_overflow != complain_overflow_dont) && overflow)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/* Relocate a given location using a given value and howto. */
|
||||
|
||||
bfd_reloc_status_type
|
||||
do_ns32k_reloc_contents ( howto, input_bfd, relocation, location, get_data,
|
||||
put_data)
|
||||
reloc_howto_type *howto;
|
||||
bfd *input_bfd;
|
||||
bfd_vma relocation;
|
||||
bfd_byte *location;
|
||||
long (*get_data)();
|
||||
int (*put_data)();
|
||||
{
|
||||
int size;
|
||||
bfd_vma x;
|
||||
boolean overflow;
|
||||
|
||||
/* If the size is negative, negate RELOCATION. This isn't very
|
||||
general. */
|
||||
if (howto->size < 0)
|
||||
relocation = -relocation;
|
||||
|
||||
/* Get the value we are going to relocate. */
|
||||
size = bfd_get_reloc_size (howto);
|
||||
switch (size)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
abort ();
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
#ifdef BFD64
|
||||
case 8:
|
||||
#endif
|
||||
x = get_data (location, 0, size);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check for overflow. FIXME: We may drop bits during the addition
|
||||
which we don't check for. We must either check at every single
|
||||
operation, which would be tedious, or we must do the computations
|
||||
in a type larger than bfd_vma, which would be inefficient. */
|
||||
overflow = false;
|
||||
if (howto->complain_on_overflow != complain_overflow_dont)
|
||||
{
|
||||
bfd_vma check;
|
||||
bfd_signed_vma signed_check;
|
||||
bfd_vma add;
|
||||
bfd_signed_vma signed_add;
|
||||
|
||||
if (howto->rightshift == 0)
|
||||
{
|
||||
check = relocation;
|
||||
signed_check = (bfd_signed_vma) relocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Drop unwanted bits from the value we are relocating to. */
|
||||
check = relocation >> howto->rightshift;
|
||||
|
||||
/* If this is a signed value, the rightshift just dropped
|
||||
leading 1 bits (assuming twos complement). */
|
||||
if ((bfd_signed_vma) relocation >= 0)
|
||||
signed_check = check;
|
||||
else
|
||||
signed_check = (check
|
||||
| ((bfd_vma) - 1
|
||||
& ~((bfd_vma) - 1 >> howto->rightshift)));
|
||||
}
|
||||
|
||||
/* Get the value from the object file. */
|
||||
add = x & howto->src_mask;
|
||||
|
||||
/* Get the value from the object file with an appropriate sign.
|
||||
The expression involving howto->src_mask isolates the upper
|
||||
bit of src_mask. If that bit is set in the value we are
|
||||
adding, it is negative, and we subtract out that number times
|
||||
two. If src_mask includes the highest possible bit, then we
|
||||
can not get the upper bit, but that does not matter since
|
||||
signed_add needs no adjustment to become negative in that
|
||||
case. */
|
||||
signed_add = add;
|
||||
if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
|
||||
signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
|
||||
|
||||
/* Add the value from the object file, shifted so that it is a
|
||||
straight number. */
|
||||
if (howto->bitpos == 0)
|
||||
{
|
||||
check += add;
|
||||
signed_check += signed_add;
|
||||
}
|
||||
else
|
||||
{
|
||||
check += add >> howto->bitpos;
|
||||
|
||||
/* For the signed case we use ADD, rather than SIGNED_ADD,
|
||||
to avoid warnings from SVR4 cc. This is OK since we
|
||||
explictly handle the sign bits. */
|
||||
if (signed_add >= 0)
|
||||
signed_check += add >> howto->bitpos;
|
||||
else
|
||||
signed_check += ((add >> howto->bitpos)
|
||||
| ((bfd_vma) - 1
|
||||
& ~((bfd_vma) - 1 >> howto->bitpos)));
|
||||
}
|
||||
|
||||
switch (howto->complain_on_overflow)
|
||||
{
|
||||
case complain_overflow_signed:
|
||||
{
|
||||
/* Assumes two's complement. */
|
||||
bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
|
||||
bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
|
||||
|
||||
if (signed_check > reloc_signed_max
|
||||
|| signed_check < reloc_signed_min)
|
||||
overflow = true;
|
||||
}
|
||||
break;
|
||||
case complain_overflow_unsigned:
|
||||
{
|
||||
/* Assumes two's complement. This expression avoids
|
||||
overflow if howto->bitsize is the number of bits in
|
||||
bfd_vma. */
|
||||
bfd_vma reloc_unsigned_max =
|
||||
(((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||
|
||||
if (check > reloc_unsigned_max)
|
||||
overflow = true;
|
||||
}
|
||||
break;
|
||||
case complain_overflow_bitfield:
|
||||
{
|
||||
/* Assumes two's complement. This expression avoids
|
||||
overflow if howto->bitsize is the number of bits in
|
||||
bfd_vma. */
|
||||
bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
|
||||
|
||||
if ((check & ~reloc_bits) != 0
|
||||
&& (((bfd_vma) signed_check & ~reloc_bits)
|
||||
!= (-1 & ~reloc_bits)))
|
||||
overflow = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Put RELOCATION in the right bits. */
|
||||
relocation >>= (bfd_vma) howto->rightshift;
|
||||
relocation <<= (bfd_vma) howto->bitpos;
|
||||
|
||||
/* Add RELOCATION to the right bits of X. */
|
||||
x = ((x & ~howto->dst_mask)
|
||||
| (((x & howto->src_mask) + relocation) & howto->dst_mask));
|
||||
|
||||
/* Put the relocated value back in the object file. */
|
||||
switch (size)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
abort ();
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
#ifdef BFD64
|
||||
case 8:
|
||||
#endif
|
||||
put_data(x, location, 0, size);
|
||||
break;
|
||||
}
|
||||
|
||||
return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
|
||||
}
|
||||
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_disp(abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
return do_ns32k_reloc(abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, ns32k_get_displacement, ns32k_put_displacement);
|
||||
}
|
||||
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_imm (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
return do_ns32k_reloc(abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, ns32k_get_immediate, ns32k_put_immediate);
|
||||
}
|
||||
|
||||
bfd_reloc_status_type
|
||||
ns32k_final_link_relocate (howto, input_bfd, input_section, contents, address, value, addend )
|
||||
reloc_howto_type *howto;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
bfd_vma address;
|
||||
bfd_vma value;
|
||||
bfd_vma addend;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
|
||||
/* Sanity check the address. */
|
||||
if (address > input_section->_cooked_size)
|
||||
return bfd_reloc_outofrange;
|
||||
|
||||
/* This function assumes that we are dealing with a basic relocation
|
||||
against a symbol. We want to compute the value of the symbol to
|
||||
relocate to. This is just VALUE, the value of the symbol, plus
|
||||
ADDEND, any addend associated with the reloc. */
|
||||
relocation = value + addend;
|
||||
|
||||
/* If the relocation is PC relative, we want to set RELOCATION to
|
||||
the distance between the symbol (currently in RELOCATION) and the
|
||||
location we are relocating. Some targets (e.g., i386-aout)
|
||||
arrange for the contents of the section to be the negative of the
|
||||
offset of the location within the section; for such targets
|
||||
pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
|
||||
simply leave the contents of the section as zero; for such
|
||||
targets pcrel_offset is true. If pcrel_offset is false we do not
|
||||
need to subtract out the offset of the location within the
|
||||
section (which is just ADDRESS). */
|
||||
if (howto->pc_relative)
|
||||
{
|
||||
relocation -= (input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
if (howto->pcrel_offset)
|
||||
relocation -= address;
|
||||
}
|
||||
|
||||
return ns32k_relocate_contents (howto, input_bfd, relocation,
|
||||
contents + address);
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
/* BFD PowerPC CPU definition
|
||||
Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
Contributed by Ian Lance Taylor, Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* The common PowerPC architecture is compatible with the RS/6000. */
|
||||
|
||||
static const bfd_arch_info_type *powerpc_compatible
|
||||
PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
powerpc_compatible (a,b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
BFD_ASSERT (a->arch == bfd_arch_powerpc);
|
||||
switch (b->arch)
|
||||
{
|
||||
default:
|
||||
return NULL;
|
||||
case bfd_arch_powerpc:
|
||||
return bfd_default_compatible (a, b);
|
||||
case bfd_arch_rs6000:
|
||||
if (a->mach == 0)
|
||||
return a;
|
||||
return NULL;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_powerpc,
|
||||
603, /* for the mpc603 */
|
||||
"powerpc",
|
||||
"powerpc:603",
|
||||
3,
|
||||
false, /* not the default */
|
||||
powerpc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[1]
|
||||
},
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_powerpc,
|
||||
604, /* for the mpc604 */
|
||||
"powerpc",
|
||||
"powerpc:604",
|
||||
3,
|
||||
false, /* not the default */
|
||||
powerpc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[2]
|
||||
},
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_powerpc,
|
||||
403, /* for the 403 */
|
||||
"powerpc",
|
||||
"powerpc:403",
|
||||
3,
|
||||
false, /* not the default */
|
||||
powerpc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[3]
|
||||
},
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_powerpc,
|
||||
601, /* for the mpc601 */
|
||||
"powerpc",
|
||||
"powerpc:601",
|
||||
3,
|
||||
false, /* not the default */
|
||||
powerpc_compatible,
|
||||
bfd_default_scan,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_powerpc_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_powerpc,
|
||||
0, /* for the POWER/PowerPC common architecture */
|
||||
"powerpc",
|
||||
"powerpc:common",
|
||||
3,
|
||||
true, /* the default */
|
||||
powerpc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[0]
|
||||
};
|
@ -1,70 +0,0 @@
|
||||
/* BFD back-end for rs6000 support
|
||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
FIXME: Can someone provide a transliteration of this name into ASCII?
|
||||
Using the following chars caused a compiler warning on HIUX (so I replaced
|
||||
them with octal escapes), and isn't useful without an understanding of what
|
||||
character set it is.
|
||||
Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM
|
||||
and John Gilmore of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* The RS/6000 architecture is compatible with the PowerPC common
|
||||
architecture. */
|
||||
|
||||
static const bfd_arch_info_type *rs6000_compatible
|
||||
PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
rs6000_compatible (a,b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
BFD_ASSERT (a->arch == bfd_arch_rs6000);
|
||||
switch (b->arch)
|
||||
{
|
||||
default:
|
||||
return NULL;
|
||||
case bfd_arch_rs6000:
|
||||
return bfd_default_compatible (a, b);
|
||||
case bfd_arch_powerpc:
|
||||
if (b->mach == 0)
|
||||
return b;
|
||||
return NULL;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
const bfd_arch_info_type bfd_rs6000_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_rs6000,
|
||||
6000, /* only 1 machine */
|
||||
"rs6000",
|
||||
"rs6000:6000",
|
||||
3,
|
||||
true, /* the one and only */
|
||||
rs6000_compatible,
|
||||
bfd_default_scan,
|
||||
0,
|
||||
};
|
@ -1,68 +0,0 @@
|
||||
/* BFD library support routines for the Hitachi-SH architecture.
|
||||
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
int bfd_default_scan_num_mach();
|
||||
|
||||
static boolean
|
||||
scan_mach (info, string)
|
||||
const struct bfd_arch_info *info;
|
||||
const char *string;
|
||||
{
|
||||
if (strcmp(string,"sh") == 0) return true;
|
||||
if (strcmp(string,"SH") == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* This routine is provided two arch_infos and returns whether
|
||||
they'd be compatible */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (a,b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
if (a->arch != b->arch || a->mach != b->mach)
|
||||
return NULL;
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
const bfd_arch_info_type bfd_sh_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_sh,
|
||||
0, /* only 1 machine */
|
||||
"sh", /* arch_name */
|
||||
"sh", /* printable name */
|
||||
1,
|
||||
true, /* the default machine */
|
||||
bfd_default_compatible,
|
||||
scan_mach,
|
||||
0,
|
||||
};
|
@ -1,111 +0,0 @@
|
||||
/* BFD support for the SPARC architecture.
|
||||
Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* Don't mix 32 bit and 64 bit files. */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
sparc_compatible (a, b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
if (a->bits_per_word != b->bits_per_word)
|
||||
return NULL;
|
||||
|
||||
return bfd_default_compatible (a, b);
|
||||
}
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
{
|
||||
32, /* bits in a word */
|
||||
32, /* bits in an address */
|
||||
8, /* bits in a byte */
|
||||
bfd_arch_sparc,
|
||||
bfd_mach_sparc_v8plus,
|
||||
"sparc",
|
||||
"sparc:v8plus",
|
||||
3,
|
||||
false,
|
||||
sparc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[1],
|
||||
},
|
||||
{
|
||||
32, /* bits in a word */
|
||||
32, /* bits in an address */
|
||||
8, /* bits in a byte */
|
||||
bfd_arch_sparc,
|
||||
bfd_mach_sparc_v8plusa,
|
||||
"sparc",
|
||||
"sparc:v8plusa",
|
||||
3,
|
||||
false,
|
||||
sparc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[2],
|
||||
},
|
||||
{
|
||||
64, /* bits in a word */
|
||||
64, /* bits in an address */
|
||||
8, /* bits in a byte */
|
||||
bfd_arch_sparc,
|
||||
bfd_mach_sparc_v9,
|
||||
"sparc",
|
||||
"sparc:v9",
|
||||
3,
|
||||
false,
|
||||
sparc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[3],
|
||||
},
|
||||
{
|
||||
64, /* bits in a word */
|
||||
64, /* bits in an address */
|
||||
8, /* bits in a byte */
|
||||
bfd_arch_sparc,
|
||||
bfd_mach_sparc_v9a,
|
||||
"sparc",
|
||||
"sparc:v9a",
|
||||
3,
|
||||
false,
|
||||
sparc_compatible,
|
||||
bfd_default_scan,
|
||||
0,
|
||||
}
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_sparc_arch =
|
||||
{
|
||||
32, /* bits in a word */
|
||||
32, /* bits in an address */
|
||||
8, /* bits in a byte */
|
||||
bfd_arch_sparc,
|
||||
bfd_mach_sparc,
|
||||
"sparc",
|
||||
"sparc",
|
||||
3,
|
||||
true, /* the default */
|
||||
sparc_compatible,
|
||||
bfd_default_scan,
|
||||
&arch_info_struct[0],
|
||||
};
|
@ -1,39 +0,0 @@
|
||||
/* bfd back-end for vax support
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_vax_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_vax,
|
||||
0, /* only 1 machine */
|
||||
"vax",
|
||||
"vax",
|
||||
3,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,54 +0,0 @@
|
||||
/* BFD library support routines for the WDC 65816 architecture.
|
||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as publiw65ed by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You w65ould have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
int bfd_default_scan_num_mach();
|
||||
|
||||
static boolean
|
||||
scan_mach (info, string)
|
||||
const struct bfd_arch_info *info;
|
||||
const char *string;
|
||||
{
|
||||
if (strcmp(string,"w65") == 0) return true;
|
||||
if (strcmp(string,"w65816") == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const bfd_arch_info_type bfd_w65_arch =
|
||||
{
|
||||
16, /* 16 bits in a word */
|
||||
24, /* 24 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_w65,
|
||||
0, /* only 1 machine */
|
||||
"w65", /* arch_name */
|
||||
"w65", /* printable name */
|
||||
1,
|
||||
true, /* the default machine */
|
||||
bfd_default_compatible,
|
||||
scan_mach,
|
||||
0,
|
||||
};
|
@ -1,39 +0,0 @@
|
||||
/* bfd back-end for we32k support
|
||||
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
Contributed by Brendan Kehoe (brendan@cs.widener.edu).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
const bfd_arch_info_type bfd_we32k_arch =
|
||||
{
|
||||
32, /* 32 bits in a word */
|
||||
32, /* 32 bits in an address */
|
||||
8, /* 8 bits in a byte */
|
||||
bfd_arch_we32k,
|
||||
32000, /* only 1 machine */
|
||||
"we32k",
|
||||
"we32k:32000",
|
||||
3,
|
||||
true, /* the one and only */
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan ,
|
||||
0,
|
||||
};
|
@ -1,198 +0,0 @@
|
||||
/* BFD library support routines for the Z800n architecture.
|
||||
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
|
||||
#if 0 /* not used currently */
|
||||
/*
|
||||
Relocations for the Z8K
|
||||
|
||||
*/
|
||||
static bfd_reloc_status_type
|
||||
howto16_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
|
||||
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||
abort ();
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
|
||||
ignore_input_section, ignore_bfd)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
struct symbol_cache_entry *symbol_in;
|
||||
PTR data;
|
||||
asection *ignore_input_section;
|
||||
bfd *ignore_bfd;
|
||||
{
|
||||
long relocation = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
||||
abort ();
|
||||
HOWTO_PREPARE (relocation, symbol_in);
|
||||
|
||||
x = (x + relocation + reloc_entry->addend);
|
||||
|
||||
bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static reloc_howto_type howto_16
|
||||
= NEWHOWTO (howto16_callback, "abs16", 1, false, false);
|
||||
static reloc_howto_type howto_8
|
||||
= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
|
||||
|
||||
static reloc_howto_type howto_8_FFnn
|
||||
= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
|
||||
|
||||
static reloc_howto_type howto_8_pcrel
|
||||
= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
|
||||
|
||||
|
||||
static reloc_howto_type *
|
||||
local_bfd_reloc_type_lookup (arch, code)
|
||||
const struct bfd_arch_info *arch;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_16:
|
||||
return &howto_16;
|
||||
case BFD_RELOC_8_FFnn:
|
||||
return &howto_8_FFnn;
|
||||
case BFD_RELOC_8:
|
||||
return &howto_8;
|
||||
case BFD_RELOC_8_PCREL:
|
||||
return &howto_8_pcrel;
|
||||
default:
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int bfd_default_scan_num_mach ();
|
||||
|
||||
static boolean
|
||||
scan_mach (info, string)
|
||||
const struct bfd_arch_info *info;
|
||||
const char *string;
|
||||
{
|
||||
if (strcmp (string, "z8001") == 0 || strcmp (string, "z8k") == 0)
|
||||
{
|
||||
return bfd_mach_z8001 == info->mach;
|
||||
}
|
||||
if (strcmp (string, "z8002") == 0)
|
||||
{
|
||||
return bfd_mach_z8002 == info->mach;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* This routine is provided two arch_infos and returns whether
|
||||
they'd be compatible */
|
||||
|
||||
static const bfd_arch_info_type *
|
||||
compatible (a, b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
if (a->arch != b->arch || a->mach != b->mach)
|
||||
return NULL;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
static const bfd_arch_info_type arch_info_struct[] =
|
||||
{
|
||||
{32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, false, compatible, scan_mach, 0,},
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_z8k_arch =
|
||||
{
|
||||
32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, true, compatible, scan_mach, &arch_info_struct[0],
|
||||
};
|
@ -1,24 +0,0 @@
|
||||
/* BFD backend for demonstration 64-bit a.out binaries.
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 64
|
||||
#define MY(OP) CAT(demo_64_,OP)
|
||||
#define TARGETNAME "demo64"
|
||||
#include "aoutf1.h"
|
@ -1,853 +0,0 @@
|
||||
/* Generic ECOFF swapping routines, for BFD.
|
||||
Copyright 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* NOTE: This is a header file, but it contains executable routines.
|
||||
This is done this way because these routines are substantially
|
||||
similar, but are not identical, for all ECOFF targets.
|
||||
|
||||
These are routines to swap the ECOFF symbolic information in and
|
||||
out. The routines are defined statically. You can set breakpoints
|
||||
on them in gdb by naming the including source file; e.g.,
|
||||
'coff-mips.c':ecoff_swap_hdr_in.
|
||||
|
||||
Before including this header file, one of ECOFF_32 or ECOFF_64 must
|
||||
be defined. These are checked when swapping information that
|
||||
depends upon the target size. This code works for 32 bit and 64
|
||||
bit ECOFF, but may need to be generalized in the future.
|
||||
|
||||
Some header file which defines the external forms of these
|
||||
structures must also be included before including this header file.
|
||||
Currently this is either coff/mips.h or coff/alpha.h.
|
||||
|
||||
If the symbol TEST is defined when this file is compiled, a
|
||||
comparison is made to ensure that, in fact, the output is
|
||||
bit-for-bit the same as the input. Of course, this symbol should
|
||||
only be defined when deliberately testing the code on a machine
|
||||
with the proper byte sex and such. */
|
||||
|
||||
#ifdef ECOFF_32
|
||||
#define ecoff_get_off bfd_h_get_32
|
||||
#define ecoff_put_off bfd_h_put_32
|
||||
#endif
|
||||
#ifdef ECOFF_64
|
||||
#define ecoff_get_off bfd_h_get_64
|
||||
#define ecoff_put_off bfd_h_put_64
|
||||
#endif
|
||||
|
||||
/* ECOFF auxiliary information swapping routines. These are the same
|
||||
for all ECOFF targets, so they are defined in ecofflink.c. */
|
||||
|
||||
extern void _bfd_ecoff_swap_tir_in
|
||||
PARAMS ((int, const struct tir_ext *, TIR *));
|
||||
extern void _bfd_ecoff_swap_tir_out
|
||||
PARAMS ((int, const TIR *, struct tir_ext *));
|
||||
extern void _bfd_ecoff_swap_rndx_in
|
||||
PARAMS ((int, const struct rndx_ext *, RNDXR *));
|
||||
extern void _bfd_ecoff_swap_rndx_out
|
||||
PARAMS ((int, const RNDXR *, struct rndx_ext *));
|
||||
|
||||
/* Prototypes for functions defined in this file. */
|
||||
|
||||
static void ecoff_swap_hdr_in PARAMS ((bfd *, PTR, HDRR *));
|
||||
static void ecoff_swap_hdr_out PARAMS ((bfd *, const HDRR *, PTR));
|
||||
static void ecoff_swap_fdr_in PARAMS ((bfd *, PTR, FDR *));
|
||||
static void ecoff_swap_fdr_out PARAMS ((bfd *, const FDR *, PTR));
|
||||
static void ecoff_swap_pdr_in PARAMS ((bfd *, PTR, PDR *));
|
||||
static void ecoff_swap_pdr_out PARAMS ((bfd *, const PDR *, PTR));
|
||||
static void ecoff_swap_sym_in PARAMS ((bfd *, PTR, SYMR *));
|
||||
static void ecoff_swap_sym_out PARAMS ((bfd *, const SYMR *, PTR));
|
||||
static void ecoff_swap_ext_in PARAMS ((bfd *, PTR, EXTR *));
|
||||
static void ecoff_swap_ext_out PARAMS ((bfd *, const EXTR *, PTR));
|
||||
static void ecoff_swap_rfd_in PARAMS ((bfd *, PTR, RFDT *));
|
||||
static void ecoff_swap_rfd_out PARAMS ((bfd *, const RFDT *, PTR));
|
||||
static void ecoff_swap_opt_in PARAMS ((bfd *, PTR, OPTR *));
|
||||
static void ecoff_swap_opt_out PARAMS ((bfd *, const OPTR *, PTR));
|
||||
static void ecoff_swap_dnr_in PARAMS ((bfd *, PTR, DNR *));
|
||||
static void ecoff_swap_dnr_out PARAMS ((bfd *, const DNR *, PTR));
|
||||
|
||||
/* Swap in the symbolic header. */
|
||||
|
||||
static void
|
||||
ecoff_swap_hdr_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
HDRR *intern;
|
||||
{
|
||||
struct hdr_ext ext[1];
|
||||
|
||||
*ext = *(struct hdr_ext *) ext_copy;
|
||||
|
||||
intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
|
||||
intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
|
||||
intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
|
||||
intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
|
||||
intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
|
||||
intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
|
||||
intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
|
||||
intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
|
||||
intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
|
||||
intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
|
||||
intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
|
||||
intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
|
||||
intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
|
||||
intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
|
||||
intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
|
||||
intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
|
||||
intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
|
||||
intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
|
||||
intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
|
||||
intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
|
||||
intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
|
||||
intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
|
||||
intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
|
||||
intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
|
||||
intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out the symbolic header. */
|
||||
|
||||
static void
|
||||
ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const HDRR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
|
||||
HDRR intern[1];
|
||||
|
||||
*intern = *intern_copy;
|
||||
|
||||
bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
|
||||
bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
|
||||
bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
|
||||
ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
|
||||
ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
|
||||
bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
|
||||
ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
|
||||
bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
|
||||
ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
|
||||
bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
|
||||
ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
|
||||
bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
|
||||
ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
|
||||
bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
|
||||
ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
|
||||
bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
|
||||
ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
|
||||
bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
|
||||
ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
|
||||
bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
|
||||
ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
|
||||
bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
|
||||
ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
|
||||
bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
|
||||
ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap in the file descriptor record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_fdr_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
FDR *intern;
|
||||
{
|
||||
struct fdr_ext ext[1];
|
||||
|
||||
*ext = *(struct fdr_ext *) ext_copy;
|
||||
|
||||
intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
|
||||
intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
|
||||
#ifdef ECOFF_64
|
||||
if (intern->rss == 0xffffffff)
|
||||
intern->rss = -1;
|
||||
#endif
|
||||
intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
|
||||
intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
|
||||
intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
|
||||
intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
|
||||
intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
|
||||
intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
|
||||
intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
|
||||
intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
|
||||
#ifdef ECOFF_32
|
||||
intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
|
||||
intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
|
||||
#endif
|
||||
#ifdef ECOFF_64
|
||||
intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
|
||||
intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
|
||||
#endif
|
||||
intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
|
||||
intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
|
||||
intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
|
||||
intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
|
||||
|
||||
/* now the fun stuff... */
|
||||
if (bfd_header_big_endian (abfd)) {
|
||||
intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
|
||||
>> FDR_BITS1_LANG_SH_BIG;
|
||||
intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
|
||||
intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
|
||||
intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
|
||||
intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
|
||||
>> FDR_BITS2_GLEVEL_SH_BIG;
|
||||
} else {
|
||||
intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
|
||||
>> FDR_BITS1_LANG_SH_LITTLE;
|
||||
intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
|
||||
intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
|
||||
intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
|
||||
intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
|
||||
>> FDR_BITS2_GLEVEL_SH_LITTLE;
|
||||
}
|
||||
intern->reserved = 0;
|
||||
|
||||
intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
|
||||
intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out the file descriptor record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const FDR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
|
||||
FDR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
|
||||
bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
|
||||
bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
|
||||
ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
|
||||
bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
|
||||
bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
|
||||
bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
|
||||
bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
|
||||
bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
|
||||
bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
|
||||
#ifdef ECOFF_32
|
||||
bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
|
||||
bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
|
||||
#endif
|
||||
#ifdef ECOFF_64
|
||||
bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
|
||||
bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
|
||||
#endif
|
||||
bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
|
||||
bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
|
||||
bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
|
||||
bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
|
||||
|
||||
/* now the fun stuff... */
|
||||
if (bfd_header_big_endian (abfd)) {
|
||||
ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
|
||||
& FDR_BITS1_LANG_BIG)
|
||||
| (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
|
||||
| (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
|
||||
| (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
|
||||
ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
|
||||
& FDR_BITS2_GLEVEL_BIG);
|
||||
ext->f_bits2[1] = 0;
|
||||
ext->f_bits2[2] = 0;
|
||||
} else {
|
||||
ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
|
||||
& FDR_BITS1_LANG_LITTLE)
|
||||
| (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
|
||||
| (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
|
||||
| (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
|
||||
ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
|
||||
& FDR_BITS2_GLEVEL_LITTLE);
|
||||
ext->f_bits2[1] = 0;
|
||||
ext->f_bits2[2] = 0;
|
||||
}
|
||||
|
||||
ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
|
||||
ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef MPW_C
|
||||
|
||||
/* Swap in the procedure descriptor record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_pdr_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
PDR *intern;
|
||||
{
|
||||
struct pdr_ext ext[1];
|
||||
|
||||
*ext = *(struct pdr_ext *) ext_copy;
|
||||
|
||||
memset ((PTR) intern, 0, sizeof (*intern));
|
||||
|
||||
intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
|
||||
intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
|
||||
intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
|
||||
intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
|
||||
intern->regoffset = bfd_h_get_signed_32 (abfd,
|
||||
(bfd_byte *)ext->p_regoffset);
|
||||
intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
|
||||
intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
|
||||
intern->fregoffset = bfd_h_get_signed_32 (abfd,
|
||||
(bfd_byte *)ext->p_fregoffset);
|
||||
intern->frameoffset = bfd_h_get_signed_32 (abfd,
|
||||
(bfd_byte *)ext->p_frameoffset);
|
||||
intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
|
||||
intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
|
||||
intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
|
||||
intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
|
||||
intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
|
||||
|
||||
#ifdef ECOFF_64
|
||||
intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
|
||||
intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
|
||||
intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG);
|
||||
intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
|
||||
<< PDR_BITS1_RESERVED_SH_LEFT_BIG)
|
||||
| ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
|
||||
>> PDR_BITS2_RESERVED_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
|
||||
intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
|
||||
intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE);
|
||||
intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
|
||||
>> PDR_BITS1_RESERVED_SH_LITTLE)
|
||||
| ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
|
||||
<< PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
|
||||
}
|
||||
intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out the procedure descriptor record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const PDR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
|
||||
PDR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
|
||||
bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
|
||||
bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
|
||||
bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
|
||||
bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
|
||||
bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
|
||||
bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
|
||||
bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
|
||||
bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
|
||||
bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
|
||||
bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
|
||||
bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
|
||||
bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
|
||||
ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
|
||||
|
||||
#ifdef ECOFF_64
|
||||
bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
|
||||
| (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
|
||||
| (intern->prof ? PDR_BITS1_PROF_BIG : 0)
|
||||
| ((intern->reserved
|
||||
>> PDR_BITS1_RESERVED_SH_LEFT_BIG)
|
||||
& PDR_BITS1_RESERVED_BIG));
|
||||
ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
|
||||
& PDR_BITS2_RESERVED_BIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
|
||||
| (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
|
||||
| (intern->prof ? PDR_BITS1_PROF_LITTLE : 0)
|
||||
| ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
|
||||
& PDR_BITS1_RESERVED_LITTLE));
|
||||
ext->p_bits2[0] = ((intern->reserved >>
|
||||
PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
|
||||
& PDR_BITS2_RESERVED_LITTLE);
|
||||
}
|
||||
bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
#else /* MPW_C */
|
||||
/* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
|
||||
corrupt itself and then freak out. */
|
||||
/* Swap in the procedure descriptor record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_pdr_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
PDR *intern;
|
||||
{
|
||||
struct pdr_ext ext[1];
|
||||
|
||||
*ext = *(struct pdr_ext *) ext_copy;
|
||||
|
||||
intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
|
||||
intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
|
||||
intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
|
||||
intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
|
||||
intern->regoffset = bfd_h_get_signed_32 (abfd,
|
||||
(bfd_byte *)ext->p_regoffset);
|
||||
intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
|
||||
intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
|
||||
intern->fregoffset = bfd_h_get_signed_32 (abfd,
|
||||
(bfd_byte *)ext->p_fregoffset);
|
||||
intern->frameoffset = bfd_h_get_signed_32 (abfd,
|
||||
(bfd_byte *)ext->p_frameoffset);
|
||||
intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
|
||||
intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
|
||||
intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
|
||||
intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
|
||||
intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out the procedure descriptor record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const PDR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
|
||||
PDR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
|
||||
bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
|
||||
bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
|
||||
bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
|
||||
bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
|
||||
bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
|
||||
bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
|
||||
bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
|
||||
bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
|
||||
bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
|
||||
bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
|
||||
bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
|
||||
bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
|
||||
ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
#endif /* MPW_C */
|
||||
|
||||
/* Swap in a symbol record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_sym_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
SYMR *intern;
|
||||
{
|
||||
struct sym_ext ext[1];
|
||||
|
||||
*ext = *(struct sym_ext *) ext_copy;
|
||||
|
||||
intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
|
||||
intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
|
||||
|
||||
/* now the fun stuff... */
|
||||
if (bfd_header_big_endian (abfd)) {
|
||||
intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
|
||||
>> SYM_BITS1_ST_SH_BIG;
|
||||
intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
|
||||
<< SYM_BITS1_SC_SH_LEFT_BIG)
|
||||
| ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
|
||||
>> SYM_BITS2_SC_SH_BIG);
|
||||
intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
|
||||
intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
|
||||
<< SYM_BITS2_INDEX_SH_LEFT_BIG)
|
||||
| (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
|
||||
| (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
|
||||
} else {
|
||||
intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
|
||||
>> SYM_BITS1_ST_SH_LITTLE;
|
||||
intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
|
||||
>> SYM_BITS1_SC_SH_LITTLE)
|
||||
| ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
|
||||
<< SYM_BITS2_SC_SH_LEFT_LITTLE);
|
||||
intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
|
||||
intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
|
||||
>> SYM_BITS2_INDEX_SH_LITTLE)
|
||||
| (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
|
||||
| ((unsigned int) ext->s_bits4[0]
|
||||
<< SYM_BITS4_INDEX_SH_LEFT_LITTLE);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out a symbol record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const SYMR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct sym_ext *ext = (struct sym_ext *) ext_ptr;
|
||||
SYMR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
|
||||
ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
|
||||
|
||||
/* now the fun stuff... */
|
||||
if (bfd_header_big_endian (abfd)) {
|
||||
ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
|
||||
& SYM_BITS1_ST_BIG)
|
||||
| ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
|
||||
& SYM_BITS1_SC_BIG));
|
||||
ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
|
||||
& SYM_BITS2_SC_BIG)
|
||||
| (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
|
||||
| ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
|
||||
& SYM_BITS2_INDEX_BIG));
|
||||
ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
|
||||
ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
|
||||
} else {
|
||||
ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
|
||||
& SYM_BITS1_ST_LITTLE)
|
||||
| ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
|
||||
& SYM_BITS1_SC_LITTLE));
|
||||
ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
|
||||
& SYM_BITS2_SC_LITTLE)
|
||||
| (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
|
||||
| ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
|
||||
& SYM_BITS2_INDEX_LITTLE));
|
||||
ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
|
||||
ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap in an external symbol record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_ext_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
EXTR *intern;
|
||||
{
|
||||
struct ext_ext ext[1];
|
||||
|
||||
*ext = *(struct ext_ext *) ext_copy;
|
||||
|
||||
/* now the fun stuff... */
|
||||
if (bfd_header_big_endian (abfd)) {
|
||||
intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
|
||||
intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
|
||||
intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
|
||||
} else {
|
||||
intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
|
||||
intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
|
||||
intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
|
||||
}
|
||||
intern->reserved = 0;
|
||||
|
||||
#ifdef ECOFF_32
|
||||
intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
|
||||
#endif
|
||||
#ifdef ECOFF_64
|
||||
intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
|
||||
#endif
|
||||
|
||||
ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out an external symbol record. */
|
||||
|
||||
static void
|
||||
ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const EXTR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct ext_ext *ext = (struct ext_ext *) ext_ptr;
|
||||
EXTR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
/* now the fun stuff... */
|
||||
if (bfd_header_big_endian (abfd)) {
|
||||
ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
|
||||
| (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
|
||||
| (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
|
||||
ext->es_bits2[0] = 0;
|
||||
#ifdef ECOFF_64
|
||||
ext->es_bits2[1] = 0;
|
||||
ext->es_bits2[2] = 0;
|
||||
#endif
|
||||
} else {
|
||||
ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
|
||||
| (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
|
||||
| (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
|
||||
ext->es_bits2[0] = 0;
|
||||
#ifdef ECOFF_64
|
||||
ext->es_bits2[1] = 0;
|
||||
ext->es_bits2[2] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ECOFF_32
|
||||
bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
|
||||
#endif
|
||||
#ifdef ECOFF_64
|
||||
bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
|
||||
#endif
|
||||
|
||||
ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap in a relative file descriptor. */
|
||||
|
||||
static void
|
||||
ecoff_swap_rfd_in (abfd, ext_ptr, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_ptr;
|
||||
RFDT *intern;
|
||||
{
|
||||
struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
|
||||
|
||||
*intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out a relative file descriptor. */
|
||||
|
||||
static void
|
||||
ecoff_swap_rfd_out (abfd, intern, ext_ptr)
|
||||
bfd *abfd;
|
||||
const RFDT *intern;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
|
||||
|
||||
bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap in an optimization symbol. */
|
||||
|
||||
static void
|
||||
ecoff_swap_opt_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
OPTR *intern;
|
||||
{
|
||||
struct opt_ext ext[1];
|
||||
|
||||
*ext = *(struct opt_ext *) ext_copy;
|
||||
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
intern->ot = ext->o_bits1[0];
|
||||
intern->value = (((unsigned int) ext->o_bits2[0]
|
||||
<< OPT_BITS2_VALUE_SH_LEFT_BIG)
|
||||
| ((unsigned int) ext->o_bits3[0]
|
||||
<< OPT_BITS2_VALUE_SH_LEFT_BIG)
|
||||
| ((unsigned int) ext->o_bits4[0]
|
||||
<< OPT_BITS2_VALUE_SH_LEFT_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
intern->ot = ext->o_bits1[0];
|
||||
intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
|
||||
| (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
|
||||
| (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
|
||||
}
|
||||
|
||||
_bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd),
|
||||
&ext->o_rndx, &intern->rndx);
|
||||
|
||||
intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out an optimization symbol. */
|
||||
|
||||
static void
|
||||
ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const OPTR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct opt_ext *ext = (struct opt_ext *) ext_ptr;
|
||||
OPTR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
ext->o_bits1[0] = intern->ot;
|
||||
ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
|
||||
ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
|
||||
ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->o_bits1[0] = intern->ot;
|
||||
ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
|
||||
ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
|
||||
ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
|
||||
}
|
||||
|
||||
_bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd),
|
||||
&intern->rndx, &ext->o_rndx);
|
||||
|
||||
bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap in a dense number. */
|
||||
|
||||
static void
|
||||
ecoff_swap_dnr_in (abfd, ext_copy, intern)
|
||||
bfd *abfd;
|
||||
PTR ext_copy;
|
||||
DNR *intern;
|
||||
{
|
||||
struct dnr_ext ext[1];
|
||||
|
||||
*ext = *(struct dnr_ext *) ext_copy;
|
||||
|
||||
intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
|
||||
intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Swap out a dense number. */
|
||||
|
||||
static void
|
||||
ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
|
||||
bfd *abfd;
|
||||
const DNR *intern_copy;
|
||||
PTR ext_ptr;
|
||||
{
|
||||
struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
|
||||
DNR intern[1];
|
||||
|
||||
*intern = *intern_copy; /* Make it reasonable to do in-place. */
|
||||
|
||||
bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
|
||||
bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
|
||||
|
||||
#ifdef TEST
|
||||
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
|
||||
abort();
|
||||
#endif
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/* Generic support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
|
||||
/* This does not include any relocations, but should be good enough
|
||||
for GDB to read the file. */
|
||||
|
||||
#define TARGET_LITTLE_SYM bfd_elf32_little_generic_vec
|
||||
#define TARGET_LITTLE_NAME "elf32-little"
|
||||
#define TARGET_BIG_SYM bfd_elf32_big_generic_vec
|
||||
#define TARGET_BIG_NAME "elf32-big"
|
||||
#define ELF_ARCH bfd_arch_unknown
|
||||
#define ELF_MACHINE_CODE EM_NONE
|
||||
#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#include "elf32-target.h"
|
File diff suppressed because it is too large
Load Diff
@ -1,152 +0,0 @@
|
||||
/* ELF32/HPPA support
|
||||
|
||||
This file contains ELF32/HPPA relocation support as specified
|
||||
in the Stratus FTX/Golf Object File Format (SED-1762) dated
|
||||
February 1994.
|
||||
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
|
||||
Center for Software Science
|
||||
Department of Computer Science
|
||||
University of Utah
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _ELF32_HPPA_H
|
||||
#define _ELF32_HPPA_H
|
||||
|
||||
#include "elf-bfd.h"
|
||||
#include "libhppa.h"
|
||||
#include "elf/hppa.h"
|
||||
|
||||
/* ELF/HPPA relocation types */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* Address relocation types
|
||||
These relocation types do simple base + offset relocations. */
|
||||
|
||||
R_PARISC_NONE = 0x00,
|
||||
R_PARISC_DIR32 = 0x01,
|
||||
R_PARISC_DIR21L = 0x02,
|
||||
R_PARISC_DIR17R = 0x03,
|
||||
R_PARISC_DIR17F = 0x04,
|
||||
R_PARISC_DIR14R = 0x06,
|
||||
|
||||
/* PC-relative relocation types
|
||||
Typically used for calls.
|
||||
Note PCREL17C and PCREL17F differ only in overflow handling.
|
||||
PCREL17C never reports a relocation error.
|
||||
|
||||
When supporting argument relocations, function calls must be
|
||||
accompanied by parameter relocation information. This information is
|
||||
carried in the ten high-order bits of the addend field. The remaining
|
||||
22 bits of of the addend field are sign-extended to form the Addend.
|
||||
|
||||
Note the code to build argument relocations depends on the
|
||||
addend being zero. A consequence of this limitation is GAS
|
||||
can not perform relocation reductions for function symbols. */
|
||||
R_PARISC_PCREL21L = 0x0a,
|
||||
R_PARISC_PCREL17R = 0x0b,
|
||||
R_PARISC_PCREL17F = 0x0c,
|
||||
R_PARISC_PCREL17C = 0x0d,
|
||||
R_PARISC_PCREL14R = 0x0e,
|
||||
R_PARISC_PCREL14F = 0x0f,
|
||||
|
||||
/* DP-relative relocation types. */
|
||||
R_PARISC_DPREL21L = 0x12,
|
||||
R_PARISC_DPREL14R = 0x16,
|
||||
R_PARISC_DPREL14F = 0x17,
|
||||
|
||||
/* Data linkage table (DLT) relocation types
|
||||
|
||||
SOM DLT_REL fixup requests are used to for static data references
|
||||
from position-independent code within shared libraries. They are
|
||||
similar to the GOT relocation types in some SVR4 implementations. */
|
||||
|
||||
R_PARISC_DLTREL21L = 0x1a,
|
||||
R_PARISC_DLTREL14R = 0x1e,
|
||||
R_PARISC_DLTREL14F = 0x1f,
|
||||
|
||||
/* DLT indirect relocation types */
|
||||
R_PARISC_DLTIND21L = 0x22,
|
||||
R_PARISC_DLTIND14R = 0x26,
|
||||
R_PARISC_DLTIND14F = 0x27,
|
||||
|
||||
/* Base relative relocation types. Ugh. These imply lots of state */
|
||||
R_PARISC_SETBASE = 0x28,
|
||||
R_PARISC_BASEREL32 = 0x29,
|
||||
R_PARISC_BASEREL21L = 0x2a,
|
||||
R_PARISC_BASEREL17R = 0x2b,
|
||||
R_PARISC_BASEREL17F = 0x2c,
|
||||
R_PARISC_BASEREL14R = 0x2e,
|
||||
R_PARISC_BASEREL14F = 0x2f,
|
||||
|
||||
/* Segment relative relocation types. */
|
||||
R_PARISC_TEXTREL32 = 0x31,
|
||||
R_PARISC_DATAREL32 = 0x39,
|
||||
|
||||
/* Plabel relocation types. */
|
||||
R_PARISC_PLABEL32 = 0x41,
|
||||
R_PARISC_PLABEL21L = 0x42,
|
||||
R_PARISC_PLABEL14R = 0x46,
|
||||
|
||||
/* PLT relocations. */
|
||||
R_PARISC_PLTIND21L = 0x82,
|
||||
R_PARISC_PLTIND14R = 0x86,
|
||||
R_PARISC_PLTIND14F = 0x87,
|
||||
|
||||
/* Misc relocation types. */
|
||||
R_PARISC_COPY = 0x88,
|
||||
R_PARISC_GLOB_DAT = 0x89,
|
||||
R_PARISC_JMP_SLOT = 0x8a,
|
||||
R_PARISC_RELATIVE = 0x8b,
|
||||
R_PARISC_UNIMPLEMENTED,
|
||||
}
|
||||
elf32_hppa_reloc_type;
|
||||
|
||||
#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
|
||||
#define N_PARISC_RELOCS R_PARISC_UNIMPLEMENTED + 1
|
||||
|
||||
/* Define groups of basic relocations. FIXME: These should
|
||||
be the only basic relocations created by GAS. The rest
|
||||
should be internal to the BFD backend.
|
||||
|
||||
The idea is both SOM and ELF define these basic relocation
|
||||
types so they map into a SOM or ELF specific relocation
|
||||
as appropriate. This allows GAS to share much more code
|
||||
between the two target object formats. */
|
||||
|
||||
#define R_HPPA_NONE R_PARISC_NONE
|
||||
#define R_HPPA R_PARISC_DIR32
|
||||
#define R_HPPA_GOTOFF R_PARISC_DPREL21L
|
||||
#define R_HPPA_PCREL_CALL R_PARISC_PCREL21L
|
||||
#define R_HPPA_ABS_CALL R_PARISC_DIR17F
|
||||
#define R_HPPA_COMPLEX R_PARISC_UNIMPLEMENTED
|
||||
|
||||
elf32_hppa_reloc_type **hppa_elf_gen_reloc_type
|
||||
PARAMS ((bfd *, elf32_hppa_reloc_type, int, int, int));
|
||||
|
||||
boolean elf32_hppa_size_stubs
|
||||
PARAMS ((bfd *, bfd *, struct bfd_link_info *));
|
||||
|
||||
boolean elf32_hppa_build_stubs
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
#endif /* _ELF32_HPPA_H */
|
File diff suppressed because it is too large
Load Diff
@ -1,33 +0,0 @@
|
||||
/* Intel 860 specific support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
|
||||
#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#define TARGET_BIG_SYM bfd_elf32_i860_vec
|
||||
#define TARGET_BIG_NAME "elf32-i860"
|
||||
#define ELF_ARCH bfd_arch_i860
|
||||
#define ELF_MACHINE_CODE EM_860
|
||||
|
||||
#include "elf32-target.h"
|
File diff suppressed because it is too large
Load Diff
@ -1,35 +0,0 @@
|
||||
/* Motorola 88k-specific support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
|
||||
/* This does not include any relocations, but should be good enough
|
||||
for GDB. */
|
||||
|
||||
#define TARGET_BIG_SYM bfd_elf32_m88k_vec
|
||||
#define TARGET_BIG_NAME "elf32-m88k"
|
||||
#define ELF_ARCH bfd_arch_m88k
|
||||
#define ELF_MACHINE_CODE EM_88K
|
||||
#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#include "elf32-target.h"
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
||||
/* ELF 32-bit executable support for BFD.
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 32
|
||||
|
||||
|
||||
#include "elfcode.h"
|
@ -1,37 +0,0 @@
|
||||
/* Generic support for 64-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
|
||||
/* This does not include any relocations, but should be good enough
|
||||
for GDB to read the file. */
|
||||
|
||||
#define TARGET_LITTLE_SYM bfd_elf64_little_generic_vec
|
||||
#define TARGET_LITTLE_NAME "elf64-little"
|
||||
#define TARGET_BIG_SYM bfd_elf64_big_generic_vec
|
||||
#define TARGET_BIG_NAME "elf64-big"
|
||||
#define ELF_ARCH bfd_arch_unknown
|
||||
#define ELF_MACHINE_CODE EM_NONE
|
||||
#define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#include "elf64-target.h"
|
@ -1,421 +0,0 @@
|
||||
/* SPARC-specific support for 64-bit ELF
|
||||
Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* We need a published ABI spec for this. Until one comes out, don't
|
||||
assume this'll remain unchanged forever. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
|
||||
#define SPARC64_OLD_RELOCS
|
||||
#include "elf/sparc.h"
|
||||
|
||||
static reloc_howto_type *sparc64_elf_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static void elf_info_to_howto
|
||||
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
|
||||
|
||||
static boolean sparc64_elf_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
|
||||
static boolean sparc64_elf_object_p PARAMS ((bfd *));
|
||||
|
||||
/* The howto table and associated functions.
|
||||
??? Some of the relocation values have changed. Until we're ready
|
||||
to upgrade, we have our own copy. At some point a non upward compatible
|
||||
change will be made at which point this table can be deleted and we'll
|
||||
use the one in elf32-sparc.c. */
|
||||
|
||||
static bfd_reloc_status_type sparc_elf_wdisp16_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
|
||||
static reloc_howto_type sparc64_elf_howto_table[] =
|
||||
{
|
||||
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true),
|
||||
HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true),
|
||||
HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true),
|
||||
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true),
|
||||
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true),
|
||||
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0x00ffffff,true),
|
||||
HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
|
||||
HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true),
|
||||
HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true),
|
||||
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
|
||||
HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0x00000000,true),
|
||||
#if 0 /* not used yet */
|
||||
HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PLT32", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true),
|
||||
#endif
|
||||
HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true),
|
||||
HOWTO(R_SPARC_64, 0,4,00,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_64", false,0,~ (bfd_vma) 0, true),
|
||||
HOWTO(R_SPARC_OLO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_OLO10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_HH22, 42,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_HM10, 32,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_LM22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_PC_HH22, 42,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_PC_HM10, 32,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_PC_LM22, 10,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_WDISP19, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
|
||||
HOWTO(R_SPARC_GLOB_JMP, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true),
|
||||
#if 0 /* not used yet */
|
||||
HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true),
|
||||
HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true),
|
||||
#endif
|
||||
};
|
||||
|
||||
struct elf_reloc_map {
|
||||
unsigned char bfd_reloc_val;
|
||||
unsigned char elf_reloc_val;
|
||||
};
|
||||
|
||||
static CONST struct elf_reloc_map sparc_reloc_map[] =
|
||||
{
|
||||
{ BFD_RELOC_NONE, R_SPARC_NONE, },
|
||||
{ BFD_RELOC_16, R_SPARC_16, },
|
||||
{ BFD_RELOC_8, R_SPARC_8 },
|
||||
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
|
||||
/* ??? This might cause us to need separate functions in elf{32,64}-sparc.c
|
||||
(we could still have just one table), but is this reloc ever used? */
|
||||
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
|
||||
{ BFD_RELOC_32, R_SPARC_32 },
|
||||
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
|
||||
{ BFD_RELOC_HI22, R_SPARC_HI22 },
|
||||
{ BFD_RELOC_LO10, R_SPARC_LO10, },
|
||||
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
|
||||
{ BFD_RELOC_SPARC22, R_SPARC_22 },
|
||||
{ BFD_RELOC_SPARC13, R_SPARC_13 },
|
||||
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
|
||||
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
|
||||
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
|
||||
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
|
||||
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
|
||||
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
|
||||
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
|
||||
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
|
||||
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
|
||||
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
|
||||
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
|
||||
/* ??? Doesn't dwarf use this? */
|
||||
/*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
|
||||
{BFD_RELOC_SPARC_10, R_SPARC_10},
|
||||
{BFD_RELOC_SPARC_11, R_SPARC_11},
|
||||
{BFD_RELOC_SPARC_64, R_SPARC_64},
|
||||
{BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
|
||||
{BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
|
||||
{BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
|
||||
{BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
|
||||
{BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
|
||||
{BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
|
||||
{BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
|
||||
{BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
|
||||
{BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
|
||||
{BFD_RELOC_SPARC_GLOB_JMP, R_SPARC_GLOB_JMP},
|
||||
{BFD_RELOC_SPARC_7, R_SPARC_7},
|
||||
#if 0 /* unused */
|
||||
{BFD_RELOC_SPARC_5, R_SPARC_5},
|
||||
{BFD_RELOC_SPARC_6, R_SPARC_6},
|
||||
#endif
|
||||
};
|
||||
|
||||
static reloc_howto_type *
|
||||
sparc64_elf_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
|
||||
{
|
||||
if (sparc_reloc_map[i].bfd_reloc_val == code)
|
||||
return &sparc64_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
elf_info_to_howto (abfd, cache_ptr, dst)
|
||||
bfd *abfd;
|
||||
arelent *cache_ptr;
|
||||
Elf64_Internal_Rela *dst;
|
||||
{
|
||||
BFD_ASSERT (ELF64_R_TYPE (dst->r_info) < (unsigned int) R_SPARC_max);
|
||||
cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE (dst->r_info)];
|
||||
}
|
||||
|
||||
/* Handle the WDISP16 reloc. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
sparc_elf_wdisp16_reloc (abfd,
|
||||
reloc_entry,
|
||||
symbol,
|
||||
data,
|
||||
input_section,
|
||||
output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_vma x;
|
||||
|
||||
if (output_bfd != (bfd *) NULL
|
||||
&& (symbol->flags & BSF_SECTION_SYM) == 0
|
||||
&& (! reloc_entry->howto->partial_inplace
|
||||
|| reloc_entry->addend == 0))
|
||||
{
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
if (output_bfd != NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (reloc_entry->address > input_section->_cooked_size)
|
||||
return bfd_reloc_outofrange;
|
||||
|
||||
relocation = (symbol->value
|
||||
+ symbol->section->output_section->vma
|
||||
+ symbol->section->output_offset);
|
||||
relocation += reloc_entry->addend;
|
||||
relocation -= (input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
relocation -= reloc_entry->address;
|
||||
|
||||
x = bfd_get_32 (abfd, (char *) data + reloc_entry->address);
|
||||
x |= ((((relocation >> 2) & 0xc000) << 6)
|
||||
| ((relocation >> 2) & 0x3fff));
|
||||
bfd_put_32 (abfd, x, (char *) data + reloc_entry->address);
|
||||
|
||||
if ((bfd_signed_vma) relocation < - 0x40000
|
||||
|| (bfd_signed_vma) relocation > 0x3ffff)
|
||||
return bfd_reloc_overflow;
|
||||
else
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* Relocate a SPARC64 ELF section. */
|
||||
|
||||
static boolean
|
||||
sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, local_syms, local_sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
Elf_Internal_Rela *relocs;
|
||||
Elf_Internal_Sym *local_syms;
|
||||
asection **local_sections;
|
||||
{
|
||||
Elf_Internal_Shdr *symtab_hdr;
|
||||
struct elf_link_hash_entry **sym_hashes;
|
||||
Elf_Internal_Rela *rel;
|
||||
Elf_Internal_Rela *relend;
|
||||
|
||||
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
||||
sym_hashes = elf_sym_hashes (input_bfd);
|
||||
|
||||
rel = relocs;
|
||||
relend = relocs + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
int r_type;
|
||||
reloc_howto_type *howto;
|
||||
long r_symndx;
|
||||
struct elf_link_hash_entry *h;
|
||||
Elf_Internal_Sym *sym;
|
||||
asection *sec;
|
||||
bfd_vma relocation;
|
||||
bfd_reloc_status_type r;
|
||||
|
||||
r_type = ELF64_R_TYPE (rel->r_info);
|
||||
if (r_type < 0 || r_type >= (int) R_SPARC_max)
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
howto = sparc64_elf_howto_table + r_type;
|
||||
|
||||
r_symndx = ELF64_R_SYM (rel->r_info);
|
||||
|
||||
if (info->relocateable)
|
||||
{
|
||||
/* This is a relocateable link. We don't have to change
|
||||
anything, unless the reloc is against a section symbol,
|
||||
in which case we have to adjust according to where the
|
||||
section symbol winds up in the output section. */
|
||||
if (r_symndx < symtab_hdr->sh_info)
|
||||
{
|
||||
sym = local_syms + r_symndx;
|
||||
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
||||
{
|
||||
sec = local_sections[r_symndx];
|
||||
rel->r_addend += sec->output_offset + sym->st_value;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This is a final link. */
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
sec = NULL;
|
||||
if (r_symndx < symtab_hdr->sh_info)
|
||||
{
|
||||
sym = local_syms + r_symndx;
|
||||
sec = local_sections[r_symndx];
|
||||
relocation = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->st_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
sec = h->root.u.def.section;
|
||||
relocation = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else if (h->root.type == bfd_link_hash_undefweak)
|
||||
relocation = 0;
|
||||
else
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd,
|
||||
input_section, rel->r_offset)))
|
||||
return false;
|
||||
relocation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (r_type != R_SPARC_WDISP16)
|
||||
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents, rel->r_offset,
|
||||
relocation, rel->r_addend);
|
||||
else
|
||||
{
|
||||
bfd_vma x;
|
||||
|
||||
relocation += rel->r_addend;
|
||||
relocation -= (input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
relocation -= rel->r_offset;
|
||||
|
||||
x = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
||||
x |= ((((relocation >> 2) & 0xc000) << 6)
|
||||
| ((relocation >> 2) & 0x3fff));
|
||||
bfd_put_32 (input_bfd, x, contents + rel->r_offset);
|
||||
|
||||
if ((bfd_signed_vma) relocation < - 0x40000
|
||||
|| (bfd_signed_vma) relocation > 0x3ffff)
|
||||
r = bfd_reloc_overflow;
|
||||
else
|
||||
r = bfd_reloc_ok;
|
||||
}
|
||||
|
||||
if (r != bfd_reloc_ok)
|
||||
{
|
||||
switch (r)
|
||||
{
|
||||
default:
|
||||
case bfd_reloc_outofrange:
|
||||
abort ();
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
|
||||
if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = (bfd_elf_string_from_elf_section
|
||||
(input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name));
|
||||
if (name == NULL)
|
||||
return false;
|
||||
if (*name == '\0')
|
||||
name = bfd_section_name (input_bfd, sec);
|
||||
}
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto->name, (bfd_vma) 0,
|
||||
input_bfd, input_section, rel->r_offset)))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Set the right machine number for a SPARC64 ELF file. */
|
||||
|
||||
static boolean
|
||||
sparc64_elf_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc_v9);
|
||||
}
|
||||
|
||||
#define TARGET_BIG_SYM bfd_elf64_sparc_vec
|
||||
#define TARGET_BIG_NAME "elf64-sparc"
|
||||
#define ELF_ARCH bfd_arch_sparc
|
||||
#define ELF_MACHINE_CODE EM_SPARC64
|
||||
#define ELF_MAXPAGESIZE 0x100000
|
||||
|
||||
#define bfd_elf64_bfd_reloc_type_lookup sparc64_elf_reloc_type_lookup
|
||||
#define elf_backend_relocate_section sparc64_elf_relocate_section
|
||||
#define elf_backend_object_p sparc64_elf_object_p
|
||||
|
||||
#include "elf64-target.h"
|
@ -1,22 +0,0 @@
|
||||
/* ELF 64-bit executable support for BFD.
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 64
|
||||
|
||||
#include "elfcode.h"
|
File diff suppressed because it is too large
Load Diff
@ -1,475 +0,0 @@
|
||||
/* ELF core file support for BFD.
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/* Core file support */
|
||||
|
||||
#ifdef HAVE_SYS_PROCFS_H /* Some core file support requires host /proc files */
|
||||
#include <signal.h>
|
||||
#include <sys/procfs.h>
|
||||
#else
|
||||
#define bfd_prstatus(abfd, descdata, descsz, filepos) true
|
||||
#define bfd_fpregset(abfd, descdata, descsz, filepos) true
|
||||
#define bfd_prpsinfo(abfd, descdata, descsz, filepos) true
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PROCFS_H
|
||||
|
||||
static boolean
|
||||
bfd_prstatus (abfd, descdata, descsz, filepos)
|
||||
bfd *abfd;
|
||||
char *descdata;
|
||||
int descsz;
|
||||
long filepos;
|
||||
{
|
||||
asection *newsect;
|
||||
prstatus_t *status = (prstatus_t *) 0;
|
||||
|
||||
if (descsz == sizeof (prstatus_t))
|
||||
{
|
||||
newsect = bfd_make_section (abfd, ".reg");
|
||||
if (newsect == NULL)
|
||||
return false;
|
||||
newsect->_raw_size = sizeof (status->pr_reg);
|
||||
newsect->filepos = filepos + (long) &status->pr_reg;
|
||||
newsect->flags = SEC_HAS_CONTENTS;
|
||||
newsect->alignment_power = 2;
|
||||
if ((core_prstatus (abfd) = bfd_alloc (abfd, descsz)) != NULL)
|
||||
{
|
||||
memcpy (core_prstatus (abfd), descdata, descsz);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Stash a copy of the prpsinfo structure away for future use. */
|
||||
|
||||
static boolean
|
||||
bfd_prpsinfo (abfd, descdata, descsz, filepos)
|
||||
bfd *abfd;
|
||||
char *descdata;
|
||||
int descsz;
|
||||
long filepos;
|
||||
{
|
||||
if (descsz == sizeof (prpsinfo_t))
|
||||
{
|
||||
if ((core_prpsinfo (abfd) = bfd_alloc (abfd, descsz)) == NULL)
|
||||
return false;
|
||||
memcpy (core_prpsinfo (abfd), descdata, descsz);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
bfd_fpregset (abfd, descdata, descsz, filepos)
|
||||
bfd *abfd;
|
||||
char *descdata;
|
||||
int descsz;
|
||||
long filepos;
|
||||
{
|
||||
asection *newsect;
|
||||
|
||||
newsect = bfd_make_section (abfd, ".reg2");
|
||||
if (newsect == NULL)
|
||||
return false;
|
||||
newsect->_raw_size = descsz;
|
||||
newsect->filepos = filepos;
|
||||
newsect->flags = SEC_HAS_CONTENTS;
|
||||
newsect->alignment_power = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* HAVE_SYS_PROCFS_H */
|
||||
|
||||
/* Return a pointer to the args (including the command name) that were
|
||||
seen by the program that generated the core dump. Note that for
|
||||
some reason, a spurious space is tacked onto the end of the args
|
||||
in some (at least one anyway) implementations, so strip it off if
|
||||
it exists. */
|
||||
|
||||
char *
|
||||
elf_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifdef HAVE_SYS_PROCFS_H
|
||||
if (core_prpsinfo (abfd))
|
||||
{
|
||||
prpsinfo_t *p = core_prpsinfo (abfd);
|
||||
char *scan = p->pr_psargs;
|
||||
while (*scan++)
|
||||
{;
|
||||
}
|
||||
scan -= 2;
|
||||
if ((scan > p->pr_psargs) && (*scan == ' '))
|
||||
{
|
||||
*scan = '\000';
|
||||
}
|
||||
return p->pr_psargs;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return the number of the signal that caused the core dump. Presumably,
|
||||
since we have a core file, we got a signal of some kind, so don't bother
|
||||
checking the other process status fields, just return the signal number.
|
||||
*/
|
||||
|
||||
int
|
||||
elf_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifdef HAVE_SYS_PROCFS_H
|
||||
if (core_prstatus (abfd))
|
||||
{
|
||||
return ((prstatus_t *) (core_prstatus (abfd)))->pr_cursig;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check to see if the core file could reasonably be expected to have
|
||||
come for the current executable file. Note that by default we return
|
||||
true unless we find something that indicates that there might be a
|
||||
problem.
|
||||
*/
|
||||
|
||||
boolean
|
||||
elf_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
#ifdef HAVE_SYS_PROCFS_H
|
||||
char *corename;
|
||||
char *execname;
|
||||
#endif
|
||||
|
||||
/* First, xvecs must match since both are ELF files for the same target. */
|
||||
|
||||
if (core_bfd->xvec != exec_bfd->xvec)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_PROCFS_H
|
||||
|
||||
/* If no prpsinfo, just return true. Otherwise, grab the last component
|
||||
of the exec'd pathname from the prpsinfo. */
|
||||
|
||||
if (core_prpsinfo (core_bfd))
|
||||
{
|
||||
corename = (((prpsinfo_t *) core_prpsinfo (core_bfd))->pr_fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Find the last component of the executable pathname. */
|
||||
|
||||
if ((execname = strrchr (exec_bfd->filename, '/')) != NULL)
|
||||
{
|
||||
execname++;
|
||||
}
|
||||
else
|
||||
{
|
||||
execname = (char *) exec_bfd->filename;
|
||||
}
|
||||
|
||||
/* See if they match */
|
||||
|
||||
return strcmp (execname, corename) ? false : true;
|
||||
|
||||
#else
|
||||
|
||||
return true;
|
||||
|
||||
#endif /* HAVE_SYS_PROCFS_H */
|
||||
}
|
||||
|
||||
/* ELF core files contain a segment of type PT_NOTE, that holds much of
|
||||
the information that would normally be available from the /proc interface
|
||||
for the process, at the time the process dumped core. Currently this
|
||||
includes copies of the prstatus, prpsinfo, and fpregset structures.
|
||||
|
||||
Since these structures are potentially machine dependent in size and
|
||||
ordering, bfd provides two levels of support for them. The first level,
|
||||
available on all machines since it does not require that the host
|
||||
have /proc support or the relevant include files, is to create a bfd
|
||||
section for each of the prstatus, prpsinfo, and fpregset structures,
|
||||
without any interpretation of their contents. With just this support,
|
||||
the bfd client will have to interpret the structures itself. Even with
|
||||
/proc support, it might want these full structures for it's own reasons.
|
||||
|
||||
In the second level of support, where HAVE_SYS_PROCFS_H is defined,
|
||||
bfd will pick apart the structures to gather some additional
|
||||
information that clients may want, such as the general register
|
||||
set, the name of the exec'ed file and its arguments, the signal (if
|
||||
any) that caused the core dump, etc.
|
||||
|
||||
*/
|
||||
|
||||
static boolean
|
||||
elf_corefile_note (abfd, hdr)
|
||||
bfd *abfd;
|
||||
Elf_Internal_Phdr *hdr;
|
||||
{
|
||||
Elf_External_Note *x_note_p; /* Elf note, external form */
|
||||
Elf_Internal_Note i_note; /* Elf note, internal form */
|
||||
char *buf = NULL; /* Entire note segment contents */
|
||||
char *namedata; /* Name portion of the note */
|
||||
char *descdata; /* Descriptor portion of the note */
|
||||
char *sectname; /* Name to use for new section */
|
||||
long filepos; /* File offset to descriptor data */
|
||||
asection *newsect;
|
||||
|
||||
if (hdr->p_filesz > 0
|
||||
&& (buf = (char *) bfd_malloc ((size_t) hdr->p_filesz)) != NULL
|
||||
&& bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
|
||||
&& bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
|
||||
{
|
||||
x_note_p = (Elf_External_Note *) buf;
|
||||
while ((char *) x_note_p < (buf + hdr->p_filesz))
|
||||
{
|
||||
i_note.namesz = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->namesz);
|
||||
i_note.descsz = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->descsz);
|
||||
i_note.type = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->type);
|
||||
namedata = x_note_p->name;
|
||||
descdata = namedata + BFD_ALIGN (i_note.namesz, 4);
|
||||
filepos = hdr->p_offset + (descdata - buf);
|
||||
switch (i_note.type)
|
||||
{
|
||||
case NT_PRSTATUS:
|
||||
/* process descdata as prstatus info */
|
||||
if (! bfd_prstatus (abfd, descdata, i_note.descsz, filepos))
|
||||
return false;
|
||||
sectname = ".prstatus";
|
||||
break;
|
||||
case NT_FPREGSET:
|
||||
/* process descdata as fpregset info */
|
||||
if (! bfd_fpregset (abfd, descdata, i_note.descsz, filepos))
|
||||
return false;
|
||||
sectname = ".fpregset";
|
||||
break;
|
||||
case NT_PRPSINFO:
|
||||
/* process descdata as prpsinfo */
|
||||
if (! bfd_prpsinfo (abfd, descdata, i_note.descsz, filepos))
|
||||
return false;
|
||||
sectname = ".prpsinfo";
|
||||
break;
|
||||
default:
|
||||
/* Unknown descriptor, just ignore it. */
|
||||
sectname = NULL;
|
||||
break;
|
||||
}
|
||||
if (sectname != NULL)
|
||||
{
|
||||
newsect = bfd_make_section (abfd, sectname);
|
||||
if (newsect == NULL)
|
||||
return false;
|
||||
newsect->_raw_size = i_note.descsz;
|
||||
newsect->filepos = filepos;
|
||||
newsect->flags = SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
newsect->alignment_power = 2;
|
||||
}
|
||||
x_note_p = (Elf_External_Note *)
|
||||
(descdata + BFD_ALIGN (i_note.descsz, 4));
|
||||
}
|
||||
}
|
||||
if (buf != NULL)
|
||||
{
|
||||
free (buf);
|
||||
}
|
||||
else if (hdr->p_filesz > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/* Core files are simply standard ELF formatted files that partition
|
||||
the file using the execution view of the file (program header table)
|
||||
rather than the linking view. In fact, there is no section header
|
||||
table in a core file.
|
||||
|
||||
The process status information (including the contents of the general
|
||||
register set) and the floating point register set are stored in a
|
||||
segment of type PT_NOTE. We handcraft a couple of extra bfd sections
|
||||
that allow standard bfd access to the general registers (.reg) and the
|
||||
floating point registers (.reg2).
|
||||
|
||||
*/
|
||||
|
||||
const bfd_target *
|
||||
elf_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
|
||||
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
|
||||
Elf_External_Phdr x_phdr; /* Program header table entry, external form */
|
||||
Elf_Internal_Phdr *i_phdrp; /* Program header table, internal form */
|
||||
unsigned int phindex;
|
||||
struct elf_backend_data *ebd;
|
||||
|
||||
/* Read in the ELF header in external format. */
|
||||
|
||||
if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Now check to see if we have a valid ELF file, and one that BFD can
|
||||
make use of. The magic number must match, the address size ('class')
|
||||
and byte-swapping must match our XVEC entry, and it must have a
|
||||
program header table (FIXME: See comments re segments at top of this
|
||||
file). */
|
||||
|
||||
if (elf_file_p (&x_ehdr) == false)
|
||||
{
|
||||
wrong:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* FIXME, Check EI_VERSION here ! */
|
||||
|
||||
{
|
||||
#if ARCH_SIZE == 32
|
||||
int desired_address_size = ELFCLASS32;
|
||||
#endif
|
||||
#if ARCH_SIZE == 64
|
||||
int desired_address_size = ELFCLASS64;
|
||||
#endif
|
||||
|
||||
if (x_ehdr.e_ident[EI_CLASS] != desired_address_size)
|
||||
goto wrong;
|
||||
}
|
||||
|
||||
/* Switch xvec to match the specified byte order. */
|
||||
switch (x_ehdr.e_ident[EI_DATA])
|
||||
{
|
||||
case ELFDATA2MSB: /* Big-endian */
|
||||
if (! bfd_big_endian (abfd))
|
||||
goto wrong;
|
||||
break;
|
||||
case ELFDATA2LSB: /* Little-endian */
|
||||
if (! bfd_little_endian (abfd))
|
||||
goto wrong;
|
||||
break;
|
||||
case ELFDATANONE: /* No data encoding specified */
|
||||
default: /* Unknown data encoding specified */
|
||||
goto wrong;
|
||||
}
|
||||
|
||||
/* Allocate an instance of the elf_obj_tdata structure and hook it up to
|
||||
the tdata pointer in the bfd. */
|
||||
|
||||
elf_tdata (abfd) =
|
||||
(struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
|
||||
if (elf_tdata (abfd) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* FIXME, `wrong' returns from this point onward, leak memory. */
|
||||
|
||||
/* Now that we know the byte order, swap in the rest of the header */
|
||||
i_ehdrp = elf_elfheader (abfd);
|
||||
elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
|
||||
#if DEBUG & 1
|
||||
elf_debug_file (i_ehdrp);
|
||||
#endif
|
||||
|
||||
ebd = get_elf_backend_data (abfd);
|
||||
|
||||
/* Check that the ELF e_machine field matches what this particular
|
||||
BFD format expects. */
|
||||
if (ebd->elf_machine_code != i_ehdrp->e_machine
|
||||
&& (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
|
||||
&& (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
|
||||
{
|
||||
const bfd_target * const *target_ptr;
|
||||
|
||||
if (ebd->elf_machine_code != EM_NONE)
|
||||
goto wrong;
|
||||
|
||||
/* This is the generic ELF target. Let it match any ELF target
|
||||
for which we do not have a specific backend. */
|
||||
for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
|
||||
{
|
||||
struct elf_backend_data *back;
|
||||
|
||||
if ((*target_ptr)->flavour != bfd_target_elf_flavour)
|
||||
continue;
|
||||
back = (struct elf_backend_data *) (*target_ptr)->backend_data;
|
||||
if (back->elf_machine_code == i_ehdrp->e_machine)
|
||||
{
|
||||
/* target_ptr is an ELF backend which matches this
|
||||
object file, so reject the generic ELF target. */
|
||||
goto wrong;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is no program header, or the type is not a core file, then
|
||||
we are hosed. */
|
||||
if (i_ehdrp->e_phoff == 0 || i_ehdrp->e_type != ET_CORE)
|
||||
goto wrong;
|
||||
|
||||
/* Allocate space for a copy of the program header table in
|
||||
internal form, seek to the program header table in the file,
|
||||
read it in, and convert it to internal form. As a simple sanity
|
||||
check, verify that the what BFD thinks is the size of each program
|
||||
header table entry actually matches the size recorded in the file. */
|
||||
|
||||
if (i_ehdrp->e_phentsize != sizeof (x_phdr))
|
||||
goto wrong;
|
||||
i_phdrp = (Elf_Internal_Phdr *)
|
||||
bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
|
||||
if (!i_phdrp)
|
||||
return NULL;
|
||||
if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
|
||||
return NULL;
|
||||
for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
|
||||
{
|
||||
if (bfd_read ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd)
|
||||
!= sizeof (x_phdr))
|
||||
return NULL;
|
||||
elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);
|
||||
}
|
||||
|
||||
/* Once all of the program headers have been read and converted, we
|
||||
can start processing them. */
|
||||
|
||||
for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
|
||||
{
|
||||
bfd_section_from_phdr (abfd, i_phdrp + phindex, phindex);
|
||||
if ((i_phdrp + phindex)->p_type == PT_NOTE)
|
||||
{
|
||||
if (! elf_corefile_note (abfd, i_phdrp + phindex))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember the entry point specified in the ELF file header. */
|
||||
|
||||
bfd_get_start_address (abfd) = i_ehdrp->e_entry;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
@ -1,372 +0,0 @@
|
||||
/* ELF linking support for BFD.
|
||||
Copyright 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libbfd.h"
|
||||
#define ARCH_SIZE 0
|
||||
#include "elf-bfd.h"
|
||||
|
||||
boolean
|
||||
_bfd_elf_create_got_section (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
|
||||
/* This function may be called more than once. */
|
||||
if (bfd_get_section_by_name (abfd, ".got") != NULL)
|
||||
return true;
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".got");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (bed->want_got_plt)
|
||||
{
|
||||
s = bfd_make_section (abfd, ".got.plt");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
|
||||
(or .got.plt) section. We don't do this in the linker script
|
||||
because we don't want to define the symbol if we are not creating
|
||||
a global offset table. */
|
||||
h = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
|
||||
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
|
||||
/* The first three global offset table entries are reserved. */
|
||||
s->_raw_size += 3 * 4;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Create dynamic sections when linking against a dynamic object. */
|
||||
|
||||
boolean
|
||||
_bfd_elf_create_dynamic_sections (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
|
||||
/* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
|
||||
.rel[a].bss sections. */
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s,
|
||||
(flags | SEC_CODE
|
||||
| (bed->plt_readonly ? SEC_READONLY : 0)))
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (bed->want_plt_sym)
|
||||
{
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
|
||||
(bfd_vma) 0, (const char *) NULL, false,
|
||||
get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
}
|
||||
|
||||
s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.plt" : ".rel.plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (! _bfd_elf_create_got_section (abfd, info))
|
||||
return false;
|
||||
|
||||
/* The .dynbss section is a place to put symbols which are defined
|
||||
by dynamic objects, are referenced by regular objects, and are
|
||||
not functions. We must allocate space for them in the process
|
||||
image and use a R_*_COPY reloc to tell the dynamic linker to
|
||||
initialize them at run time. The linker script puts the .dynbss
|
||||
section into the .bss section of the final image. */
|
||||
s = bfd_make_section (abfd, ".dynbss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
||||
return false;
|
||||
|
||||
/* The .rel[a].bss section holds copy relocs. This section is not
|
||||
normally needed. We need to create it here, though, so that the
|
||||
linker will map it to an output section. We can't just create it
|
||||
only if we need it, because we will not know whether we need it
|
||||
until we have seen all the input files, and the first time the
|
||||
main linker code calls BFD after examining all the input files
|
||||
(size_dynamic_sections) the input sections have already been
|
||||
mapped to the output sections. If the section turns out not to
|
||||
be needed, we can discard it later. We will never need this
|
||||
section when generating a shared object, since they do not use
|
||||
copy relocs. */
|
||||
if (! info->shared)
|
||||
{
|
||||
s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.bss" : ".rel.bss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Record a new dynamic symbol. We record the dynamic symbols as we
|
||||
read the input files, since we need to have a list of all of them
|
||||
before we can determine the final sizes of the output sections.
|
||||
Note that we may actually call this function even though we are not
|
||||
going to output any dynamic symbols; in some cases we know that a
|
||||
symbol should be in the dynamic symbol table, but only if there is
|
||||
one. */
|
||||
|
||||
boolean
|
||||
_bfd_elf_link_record_dynamic_symbol (info, h)
|
||||
struct bfd_link_info *info;
|
||||
struct elf_link_hash_entry *h;
|
||||
{
|
||||
if (h->dynindx == -1)
|
||||
{
|
||||
struct bfd_strtab_hash *dynstr;
|
||||
|
||||
h->dynindx = elf_hash_table (info)->dynsymcount;
|
||||
++elf_hash_table (info)->dynsymcount;
|
||||
|
||||
dynstr = elf_hash_table (info)->dynstr;
|
||||
if (dynstr == NULL)
|
||||
{
|
||||
/* Create a strtab to hold the dynamic symbol names. */
|
||||
elf_hash_table (info)->dynstr = dynstr = _bfd_elf_stringtab_init ();
|
||||
if (dynstr == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
h->dynstr_index = ((unsigned long)
|
||||
_bfd_stringtab_add (dynstr, h->root.root.string,
|
||||
true, false));
|
||||
if (h->dynstr_index == (unsigned long) -1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create a special linker section, or return a pointer to a linker section already created */
|
||||
|
||||
elf_linker_section_t *
|
||||
_bfd_elf_create_linker_section (abfd, info, which, defaults)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
enum elf_linker_section_enum which;
|
||||
elf_linker_section_t *defaults;
|
||||
{
|
||||
bfd *dynobj = elf_hash_table (info)->dynobj;
|
||||
elf_linker_section_t *lsect;
|
||||
|
||||
/* Record the first bfd section that needs the special section */
|
||||
if (!dynobj)
|
||||
dynobj = elf_hash_table (info)->dynobj = abfd;
|
||||
|
||||
/* If this is the first time, create the section */
|
||||
lsect = elf_linker_section (dynobj, which);
|
||||
if (!lsect)
|
||||
{
|
||||
asection *s;
|
||||
|
||||
lsect = (elf_linker_section_t *)
|
||||
bfd_alloc (dynobj, sizeof (elf_linker_section_t));
|
||||
|
||||
*lsect = *defaults;
|
||||
elf_linker_section (dynobj, which) = lsect;
|
||||
lsect->which = which;
|
||||
lsect->hole_written_p = false;
|
||||
|
||||
/* See if the sections already exist */
|
||||
lsect->section = s = bfd_get_section_by_name (dynobj, lsect->name);
|
||||
if (!s)
|
||||
{
|
||||
lsect->section = s = bfd_make_section (dynobj, lsect->name);
|
||||
|
||||
if (s == NULL)
|
||||
return (elf_linker_section_t *)0;
|
||||
|
||||
bfd_set_section_flags (dynobj, s, defaults->flags);
|
||||
bfd_set_section_alignment (dynobj, s, lsect->alignment);
|
||||
}
|
||||
else if (bfd_get_section_alignment (dynobj, s) < lsect->alignment)
|
||||
bfd_set_section_alignment (dynobj, s, lsect->alignment);
|
||||
|
||||
s->_raw_size = align_power (s->_raw_size, lsect->alignment);
|
||||
|
||||
/* Is there a hole we have to provide? If so check whether the segment is
|
||||
too big already */
|
||||
if (lsect->hole_size)
|
||||
{
|
||||
lsect->hole_offset = s->_raw_size;
|
||||
s->_raw_size += lsect->hole_size;
|
||||
if (lsect->hole_offset > lsect->max_hole_offset)
|
||||
{
|
||||
(*_bfd_error_handler) ("%s: Section %s is already to large to put hole of %ld bytes in",
|
||||
bfd_get_filename (abfd),
|
||||
lsect->name,
|
||||
(long)lsect->hole_size);
|
||||
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return (elf_linker_section_t *)0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Creating section %s, current size = %ld\n",
|
||||
lsect->name, (long)s->_raw_size);
|
||||
#endif
|
||||
|
||||
if (lsect->sym_name)
|
||||
{
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "Adding %s to section %s\n",
|
||||
lsect->sym_name,
|
||||
lsect->name);
|
||||
#endif
|
||||
h = (struct elf_link_hash_entry *)
|
||||
bfd_link_hash_lookup (info->hash, lsect->sym_name, false, false, false);
|
||||
|
||||
if ((h == NULL || h->root.type == bfd_link_hash_undefined)
|
||||
&& !(_bfd_generic_link_add_one_symbol (info,
|
||||
abfd,
|
||||
lsect->sym_name,
|
||||
BSF_GLOBAL,
|
||||
s,
|
||||
((lsect->hole_size)
|
||||
? s->_raw_size - lsect->hole_size + lsect->sym_offset
|
||||
: lsect->sym_offset),
|
||||
(const char *) NULL,
|
||||
false,
|
||||
get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return (elf_linker_section_t *)0;
|
||||
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_DYNAMIC;
|
||||
h->type = STT_OBJECT;
|
||||
lsect->sym_hash = h;
|
||||
|
||||
if (info->shared
|
||||
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return (elf_linker_section_t *)0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the related sections if they have been created */
|
||||
if (lsect->bss_name && !lsect->bss_section)
|
||||
lsect->bss_section = bfd_get_section_by_name (dynobj, lsect->bss_name);
|
||||
|
||||
if (lsect->rel_name && !lsect->rel_section)
|
||||
lsect->rel_section = bfd_get_section_by_name (dynobj, lsect->rel_name);
|
||||
|
||||
return lsect;
|
||||
}
|
||||
|
||||
|
||||
/* Find a linker generated pointer with a given addend and type. */
|
||||
|
||||
elf_linker_section_pointers_t *
|
||||
_bfd_elf_find_pointer_linker_section (linker_pointers, addend, which)
|
||||
elf_linker_section_pointers_t *linker_pointers;
|
||||
bfd_signed_vma addend;
|
||||
elf_linker_section_enum_t which;
|
||||
{
|
||||
for ( ; linker_pointers != NULL; linker_pointers = linker_pointers->next)
|
||||
{
|
||||
if (which == linker_pointers->which && addend == linker_pointers->addend)
|
||||
return linker_pointers;
|
||||
}
|
||||
|
||||
return (elf_linker_section_pointers_t *)0;
|
||||
}
|
||||
|
||||
|
||||
/* Make the .rela section corresponding to the generated linker section. */
|
||||
|
||||
boolean
|
||||
_bfd_elf_make_linker_section_rela (dynobj, lsect, alignment)
|
||||
bfd *dynobj;
|
||||
elf_linker_section_t *lsect;
|
||||
int alignment;
|
||||
{
|
||||
if (lsect->rel_section)
|
||||
return true;
|
||||
|
||||
lsect->rel_section = bfd_get_section_by_name (dynobj, lsect->rel_name);
|
||||
if (lsect->rel_section == NULL)
|
||||
{
|
||||
lsect->rel_section = bfd_make_section (dynobj, lsect->rel_name);
|
||||
if (lsect->rel_section == NULL
|
||||
|| ! bfd_set_section_flags (dynobj,
|
||||
lsect->rel_section,
|
||||
(SEC_ALLOC
|
||||
| SEC_LOAD
|
||||
| SEC_HAS_CONTENTS
|
||||
| SEC_IN_MEMORY
|
||||
| SEC_READONLY))
|
||||
|| ! bfd_set_section_alignment (dynobj, lsect->rel_section, alignment))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,450 +0,0 @@
|
||||
/* Target definitions for NN-bit ELF
|
||||
Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This structure contains everything that BFD knows about a target.
|
||||
It includes things like its byte order, name, what routines to call
|
||||
to do various operations, etc. Every BFD points to a target structure
|
||||
with its "xvec" member.
|
||||
|
||||
There are two such structures here: one for big-endian machines and
|
||||
one for little-endian machines. */
|
||||
|
||||
#define bfd_elfNN_close_and_cleanup _bfd_generic_close_and_cleanup
|
||||
#define bfd_elfNN_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
|
||||
#ifndef bfd_elfNN_get_section_contents
|
||||
#define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
|
||||
#endif
|
||||
|
||||
#define bfd_elfNN_canonicalize_dynamic_symtab _bfd_elf_canonicalize_dynamic_symtab
|
||||
#define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
|
||||
#ifndef bfd_elfNN_find_nearest_line
|
||||
#define bfd_elfNN_find_nearest_line _bfd_elf_find_nearest_line
|
||||
#endif
|
||||
#define bfd_elfNN_read_minisymbols _bfd_elf_read_minisymbols
|
||||
#define bfd_elfNN_minisymbol_to_symbol _bfd_elf_minisymbol_to_symbol
|
||||
#define bfd_elfNN_get_dynamic_symtab_upper_bound _bfd_elf_get_dynamic_symtab_upper_bound
|
||||
#define bfd_elfNN_get_lineno _bfd_elf_get_lineno
|
||||
#define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
|
||||
#define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
|
||||
#define bfd_elfNN_get_symtab _bfd_elf_get_symtab
|
||||
#define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
|
||||
#if 0 /* done in elf-bfd.h */
|
||||
#define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
|
||||
#endif
|
||||
#define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
|
||||
#define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
|
||||
#define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
|
||||
#ifndef bfd_elfNN_set_section_contents
|
||||
#define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
|
||||
#endif
|
||||
#define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
|
||||
#define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
|
||||
|
||||
#define bfd_elfNN_get_section_contents_in_window \
|
||||
_bfd_generic_get_section_contents_in_window
|
||||
|
||||
#ifndef elf_backend_want_got_plt
|
||||
#define elf_backend_want_got_plt 0
|
||||
#endif
|
||||
#ifndef elf_backend_plt_readonly
|
||||
#define elf_backend_plt_readonly 0
|
||||
#endif
|
||||
#ifndef elf_backend_want_plt_sym
|
||||
#define elf_backend_want_plt_sym 0
|
||||
#endif
|
||||
|
||||
#define bfd_elfNN_bfd_debug_info_start bfd_void
|
||||
#define bfd_elfNN_bfd_debug_info_end bfd_void
|
||||
#define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
||||
|
||||
#ifndef bfd_elfNN_bfd_get_relocated_section_contents
|
||||
#define bfd_elfNN_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#endif
|
||||
|
||||
#define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
|
||||
#define bfd_elfNN_bfd_make_debug_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
|
||||
|
||||
#ifndef bfd_elfNN_bfd_copy_private_symbol_data
|
||||
#define bfd_elfNN_bfd_copy_private_symbol_data \
|
||||
_bfd_elf_copy_private_symbol_data
|
||||
#endif
|
||||
|
||||
#ifndef bfd_elfNN_bfd_copy_private_section_data
|
||||
#define bfd_elfNN_bfd_copy_private_section_data \
|
||||
_bfd_elf_copy_private_section_data
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_copy_private_bfd_data
|
||||
#define bfd_elfNN_bfd_copy_private_bfd_data \
|
||||
((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_print_private_bfd_data
|
||||
#define bfd_elfNN_bfd_print_private_bfd_data \
|
||||
_bfd_elf_print_private_bfd_data
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_merge_private_bfd_data
|
||||
#define bfd_elfNN_bfd_merge_private_bfd_data \
|
||||
((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_set_private_flags
|
||||
#define bfd_elfNN_bfd_set_private_flags \
|
||||
((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_is_local_label
|
||||
#define bfd_elfNN_bfd_is_local_label bfd_generic_is_local_label
|
||||
#endif
|
||||
|
||||
#ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
|
||||
#define bfd_elfNN_get_dynamic_reloc_upper_bound \
|
||||
_bfd_nodynamic_get_dynamic_reloc_upper_bound
|
||||
#endif
|
||||
#ifndef bfd_elfNN_canonicalize_dynamic_reloc
|
||||
#define bfd_elfNN_canonicalize_dynamic_reloc \
|
||||
_bfd_nodynamic_canonicalize_dynamic_reloc
|
||||
#endif
|
||||
|
||||
#ifdef elf_backend_relocate_section
|
||||
#ifndef bfd_elfNN_bfd_link_hash_table_create
|
||||
#define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
|
||||
#endif
|
||||
#else /* ! defined (elf_backend_relocate_section) */
|
||||
/* If no backend relocate_section routine, use the generic linker. */
|
||||
#ifndef bfd_elfNN_bfd_link_hash_table_create
|
||||
#define bfd_elfNN_bfd_link_hash_table_create \
|
||||
_bfd_generic_link_hash_table_create
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_link_add_symbols
|
||||
#define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#endif
|
||||
#ifndef bfd_elfNN_bfd_final_link
|
||||
#define bfd_elfNN_bfd_final_link _bfd_generic_final_link
|
||||
#endif
|
||||
#endif /* ! defined (elf_backend_relocate_section) */
|
||||
#ifndef bfd_elfNN_bfd_link_split_section
|
||||
#define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
|
||||
#endif
|
||||
|
||||
#ifndef elf_symbol_leading_char
|
||||
#define elf_symbol_leading_char 0
|
||||
#endif
|
||||
|
||||
#ifndef elf_info_to_howto_rel
|
||||
#define elf_info_to_howto_rel 0
|
||||
#endif
|
||||
|
||||
#ifndef ELF_MAXPAGESIZE
|
||||
#define ELF_MAXPAGESIZE 1
|
||||
#endif
|
||||
|
||||
#ifndef elf_backend_collect
|
||||
#define elf_backend_collect false
|
||||
#endif
|
||||
#ifndef elf_backend_type_change_ok
|
||||
#define elf_backend_type_change_ok false
|
||||
#endif
|
||||
|
||||
#ifndef elf_backend_sym_is_global
|
||||
#define elf_backend_sym_is_global 0
|
||||
#endif
|
||||
#ifndef elf_backend_object_p
|
||||
#define elf_backend_object_p 0
|
||||
#endif
|
||||
#ifndef elf_backend_symbol_processing
|
||||
#define elf_backend_symbol_processing 0
|
||||
#endif
|
||||
#ifndef elf_backend_symbol_table_processing
|
||||
#define elf_backend_symbol_table_processing 0
|
||||
#endif
|
||||
#ifndef elf_backend_section_processing
|
||||
#define elf_backend_section_processing 0
|
||||
#endif
|
||||
#ifndef elf_backend_section_from_shdr
|
||||
#define elf_backend_section_from_shdr 0
|
||||
#endif
|
||||
#ifndef elf_backend_fake_sections
|
||||
#define elf_backend_fake_sections 0
|
||||
#endif
|
||||
#ifndef elf_backend_section_from_bfd_section
|
||||
#define elf_backend_section_from_bfd_section 0
|
||||
#endif
|
||||
#ifndef elf_backend_add_symbol_hook
|
||||
#define elf_backend_add_symbol_hook 0
|
||||
#endif
|
||||
#ifndef elf_backend_link_output_symbol_hook
|
||||
#define elf_backend_link_output_symbol_hook 0
|
||||
#endif
|
||||
#ifndef elf_backend_create_dynamic_sections
|
||||
#define elf_backend_create_dynamic_sections 0
|
||||
#endif
|
||||
#ifndef elf_backend_check_relocs
|
||||
#define elf_backend_check_relocs 0
|
||||
#endif
|
||||
#ifndef elf_backend_adjust_dynamic_symbol
|
||||
#define elf_backend_adjust_dynamic_symbol 0
|
||||
#endif
|
||||
#ifndef elf_backend_size_dynamic_sections
|
||||
#define elf_backend_size_dynamic_sections 0
|
||||
#endif
|
||||
#ifndef elf_backend_relocate_section
|
||||
#define elf_backend_relocate_section 0
|
||||
#endif
|
||||
#ifndef elf_backend_finish_dynamic_symbol
|
||||
#define elf_backend_finish_dynamic_symbol 0
|
||||
#endif
|
||||
#ifndef elf_backend_finish_dynamic_sections
|
||||
#define elf_backend_finish_dynamic_sections 0
|
||||
#endif
|
||||
#ifndef elf_backend_begin_write_processing
|
||||
#define elf_backend_begin_write_processing 0
|
||||
#endif
|
||||
#ifndef elf_backend_final_write_processing
|
||||
#define elf_backend_final_write_processing 0
|
||||
#endif
|
||||
#ifndef elf_backend_additional_program_headers
|
||||
#define elf_backend_additional_program_headers 0
|
||||
#endif
|
||||
#ifndef elf_backend_modify_segment_map
|
||||
#define elf_backend_modify_segment_map 0
|
||||
#endif
|
||||
#ifndef elf_backend_ecoff_debug_swap
|
||||
#define elf_backend_ecoff_debug_swap 0
|
||||
#endif
|
||||
|
||||
#ifndef ELF_MACHINE_ALT1
|
||||
#define ELF_MACHINE_ALT1 0
|
||||
#endif
|
||||
|
||||
#ifndef ELF_MACHINE_ALT2
|
||||
#define ELF_MACHINE_ALT2 0
|
||||
#endif
|
||||
|
||||
extern const struct elf_size_info _bfd_elfNN_size_info;
|
||||
|
||||
static CONST struct elf_backend_data elfNN_bed =
|
||||
{
|
||||
#ifdef USE_REL
|
||||
0, /* use_rela_p */
|
||||
#else
|
||||
1, /* use_rela_p */
|
||||
#endif
|
||||
ELF_ARCH, /* arch */
|
||||
ELF_MACHINE_CODE, /* elf_machine_code */
|
||||
ELF_MAXPAGESIZE, /* maxpagesize */
|
||||
elf_backend_collect,
|
||||
elf_backend_type_change_ok,
|
||||
elf_info_to_howto,
|
||||
elf_info_to_howto_rel,
|
||||
elf_backend_sym_is_global,
|
||||
elf_backend_object_p,
|
||||
elf_backend_symbol_processing,
|
||||
elf_backend_symbol_table_processing,
|
||||
elf_backend_section_processing,
|
||||
elf_backend_section_from_shdr,
|
||||
elf_backend_fake_sections,
|
||||
elf_backend_section_from_bfd_section,
|
||||
elf_backend_add_symbol_hook,
|
||||
elf_backend_link_output_symbol_hook,
|
||||
elf_backend_create_dynamic_sections,
|
||||
elf_backend_check_relocs,
|
||||
elf_backend_adjust_dynamic_symbol,
|
||||
elf_backend_size_dynamic_sections,
|
||||
elf_backend_relocate_section,
|
||||
elf_backend_finish_dynamic_symbol,
|
||||
elf_backend_finish_dynamic_sections,
|
||||
elf_backend_begin_write_processing,
|
||||
elf_backend_final_write_processing,
|
||||
elf_backend_additional_program_headers,
|
||||
elf_backend_modify_segment_map,
|
||||
elf_backend_ecoff_debug_swap,
|
||||
ELF_MACHINE_ALT1,
|
||||
ELF_MACHINE_ALT2,
|
||||
&_bfd_elfNN_size_info,
|
||||
elf_backend_want_got_plt,
|
||||
elf_backend_plt_readonly,
|
||||
elf_backend_want_plt_sym
|
||||
};
|
||||
|
||||
#ifdef TARGET_BIG_SYM
|
||||
const bfd_target TARGET_BIG_SYM =
|
||||
{
|
||||
/* name: identify kind of target */
|
||||
TARGET_BIG_NAME,
|
||||
|
||||
/* flavour: general indication about file */
|
||||
bfd_target_elf_flavour,
|
||||
|
||||
/* byteorder: data is big endian */
|
||||
BFD_ENDIAN_BIG,
|
||||
|
||||
/* header_byteorder: header is also big endian */
|
||||
BFD_ENDIAN_BIG,
|
||||
|
||||
/* object_flags: mask of all file flags */
|
||||
(HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
|
||||
DYNAMIC | WP_TEXT | D_PAGED),
|
||||
|
||||
/* section_flags: mask of all section flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
|
||||
SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
|
||||
|
||||
/* leading_symbol_char: is the first char of a user symbol
|
||||
predictable, and if so what is it */
|
||||
elf_symbol_leading_char,
|
||||
|
||||
/* ar_pad_char: pad character for filenames within an archive header
|
||||
FIXME: this really has nothing to do with ELF, this is a characteristic
|
||||
of the archiver and/or os and should be independently tunable */
|
||||
'/',
|
||||
|
||||
/* ar_max_namelen: maximum number of characters in an archive header
|
||||
FIXME: this really has nothing to do with ELF, this is a characteristic
|
||||
of the archiver and should be independently tunable. This value is
|
||||
a WAG (wild a** guess) */
|
||||
14,
|
||||
|
||||
/* Routines to byte-swap various sized integers from the data sections */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
||||
/* Routines to byte-swap various sized integers from the file headers */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
||||
/* bfd_check_format: check the format of a file being read */
|
||||
{ _bfd_dummy_target, /* unknown format */
|
||||
bfd_elfNN_object_p, /* assembler/linker output (object file) */
|
||||
bfd_generic_archive_p, /* an archive */
|
||||
bfd_elfNN_core_file_p /* a core file */
|
||||
},
|
||||
|
||||
/* bfd_set_format: set the format of a file being written */
|
||||
{ bfd_false,
|
||||
bfd_elf_mkobject,
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
/* bfd_write_contents: write cached information into a file being written */
|
||||
{ bfd_false,
|
||||
bfd_elfNN_write_object_contents,
|
||||
_bfd_write_archive_contents,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_COPY (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_CORE (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_WRITE (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_LINK (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
|
||||
|
||||
/* backend_data: */
|
||||
(PTR) &elfNN_bed,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_LITTLE_SYM
|
||||
const bfd_target TARGET_LITTLE_SYM =
|
||||
{
|
||||
/* name: identify kind of target */
|
||||
TARGET_LITTLE_NAME,
|
||||
|
||||
/* flavour: general indication about file */
|
||||
bfd_target_elf_flavour,
|
||||
|
||||
/* byteorder: data is little endian */
|
||||
BFD_ENDIAN_LITTLE,
|
||||
|
||||
/* header_byteorder: header is also little endian */
|
||||
BFD_ENDIAN_LITTLE,
|
||||
|
||||
/* object_flags: mask of all file flags */
|
||||
(HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
|
||||
DYNAMIC | WP_TEXT | D_PAGED),
|
||||
|
||||
/* section_flags: mask of all section flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
|
||||
SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
|
||||
|
||||
/* leading_symbol_char: is the first char of a user symbol
|
||||
predictable, and if so what is it */
|
||||
elf_symbol_leading_char,
|
||||
|
||||
/* ar_pad_char: pad character for filenames within an archive header
|
||||
FIXME: this really has nothing to do with ELF, this is a characteristic
|
||||
of the archiver and/or os and should be independently tunable */
|
||||
'/',
|
||||
|
||||
/* ar_max_namelen: maximum number of characters in an archive header
|
||||
FIXME: this really has nothing to do with ELF, this is a characteristic
|
||||
of the archiver and should be independently tunable. This value is
|
||||
a WAG (wild a** guess) */
|
||||
14,
|
||||
|
||||
/* Routines to byte-swap various sized integers from the data sections */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16,
|
||||
|
||||
/* Routines to byte-swap various sized integers from the file headers */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16,
|
||||
|
||||
/* bfd_check_format: check the format of a file being read */
|
||||
{ _bfd_dummy_target, /* unknown format */
|
||||
bfd_elfNN_object_p, /* assembler/linker output (object file) */
|
||||
bfd_generic_archive_p, /* an archive */
|
||||
bfd_elfNN_core_file_p /* a core file */
|
||||
},
|
||||
|
||||
/* bfd_set_format: set the format of a file being written */
|
||||
{ bfd_false,
|
||||
bfd_elf_mkobject,
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
/* bfd_write_contents: write cached information into a file being written */
|
||||
{ bfd_false,
|
||||
bfd_elfNN_write_object_contents,
|
||||
_bfd_write_archive_contents,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_COPY (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_CORE (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_WRITE (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_LINK (bfd_elfNN),
|
||||
BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
|
||||
|
||||
/* backend_data: */
|
||||
(PTR) &elfNN_bed,
|
||||
};
|
||||
#endif
|
@ -1,193 +0,0 @@
|
||||
/* filemode.c -- make a string describing file modes
|
||||
Copyright (C) 1985, 1990 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
void mode_string ();
|
||||
static char ftypelet ();
|
||||
static void rwx ();
|
||||
static void setst ();
|
||||
|
||||
/* filemodestring - fill in string STR with an ls-style ASCII
|
||||
representation of the st_mode field of file stats block STATP.
|
||||
10 characters are stored in STR; no terminating null is added.
|
||||
The characters stored in STR are:
|
||||
|
||||
0 File type. 'd' for directory, 'c' for character
|
||||
special, 'b' for block special, 'm' for multiplex,
|
||||
'l' for symbolic link, 's' for socket, 'p' for fifo,
|
||||
'-' for any other file type
|
||||
|
||||
1 'r' if the owner may read, '-' otherwise.
|
||||
|
||||
2 'w' if the owner may write, '-' otherwise.
|
||||
|
||||
3 'x' if the owner may execute, 's' if the file is
|
||||
set-user-id, '-' otherwise.
|
||||
'S' if the file is set-user-id, but the execute
|
||||
bit isn't set.
|
||||
|
||||
4 'r' if group members may read, '-' otherwise.
|
||||
|
||||
5 'w' if group members may write, '-' otherwise.
|
||||
|
||||
6 'x' if group members may execute, 's' if the file is
|
||||
set-group-id, '-' otherwise.
|
||||
'S' if it is set-group-id but not executable.
|
||||
|
||||
7 'r' if any user may read, '-' otherwise.
|
||||
|
||||
8 'w' if any user may write, '-' otherwise.
|
||||
|
||||
9 'x' if any user may execute, 't' if the file is "sticky"
|
||||
(will be retained in swap space after execution), '-'
|
||||
otherwise.
|
||||
'T' if the file is sticky but not executable. */
|
||||
|
||||
void
|
||||
filemodestring (statp, str)
|
||||
struct stat *statp;
|
||||
char *str;
|
||||
{
|
||||
mode_string (statp->st_mode, str);
|
||||
}
|
||||
|
||||
/* Like filemodestring, but only the relevant part of the `struct stat'
|
||||
is given as an argument. */
|
||||
|
||||
void
|
||||
mode_string (mode, str)
|
||||
unsigned short mode;
|
||||
char *str;
|
||||
{
|
||||
str[0] = ftypelet (mode);
|
||||
rwx ((mode & 0700) << 0, &str[1]);
|
||||
rwx ((mode & 0070) << 3, &str[4]);
|
||||
rwx ((mode & 0007) << 6, &str[7]);
|
||||
setst (mode, str);
|
||||
}
|
||||
|
||||
/* Return a character indicating the type of file described by
|
||||
file mode BITS:
|
||||
'd' for directories
|
||||
'b' for block special files
|
||||
'c' for character special files
|
||||
'm' for multiplexor files
|
||||
'l' for symbolic links
|
||||
's' for sockets
|
||||
'p' for fifos
|
||||
'-' for any other file type. */
|
||||
|
||||
static char
|
||||
ftypelet (bits)
|
||||
unsigned short bits;
|
||||
{
|
||||
switch (bits & S_IFMT)
|
||||
{
|
||||
default:
|
||||
return '-';
|
||||
case S_IFDIR:
|
||||
return 'd';
|
||||
#ifdef S_IFLNK
|
||||
case S_IFLNK:
|
||||
return 'l';
|
||||
#endif
|
||||
#ifdef S_IFCHR
|
||||
case S_IFCHR:
|
||||
return 'c';
|
||||
#endif
|
||||
#ifdef S_IFBLK
|
||||
case S_IFBLK:
|
||||
return 'b';
|
||||
#endif
|
||||
#ifdef S_IFMPC
|
||||
case S_IFMPC:
|
||||
case S_IFMPB:
|
||||
return 'm';
|
||||
#endif
|
||||
#ifdef S_IFSOCK
|
||||
case S_IFSOCK:
|
||||
return 's';
|
||||
#endif
|
||||
#ifdef S_IFIFO
|
||||
#if S_IFIFO != S_IFSOCK
|
||||
case S_IFIFO:
|
||||
return 'p';
|
||||
#endif
|
||||
#endif
|
||||
#ifdef S_IFNWK /* HP-UX */
|
||||
case S_IFNWK:
|
||||
return 'n';
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at read, write, and execute bits in BITS and set
|
||||
flags in CHARS accordingly. */
|
||||
|
||||
static void
|
||||
rwx (bits, chars)
|
||||
unsigned short bits;
|
||||
char *chars;
|
||||
{
|
||||
chars[0] = (bits & S_IREAD) ? 'r' : '-';
|
||||
chars[1] = (bits & S_IWRITE) ? 'w' : '-';
|
||||
chars[2] = (bits & S_IEXEC) ? 'x' : '-';
|
||||
}
|
||||
|
||||
/* Set the 's' and 't' flags in file attributes string CHARS,
|
||||
according to the file mode BITS. */
|
||||
|
||||
static void
|
||||
setst (bits, chars)
|
||||
unsigned short bits;
|
||||
char *chars;
|
||||
{
|
||||
#ifdef S_ISUID
|
||||
if (bits & S_ISUID)
|
||||
{
|
||||
if (chars[3] != 'x')
|
||||
/* Set-uid, but not executable by owner. */
|
||||
chars[3] = 'S';
|
||||
else
|
||||
chars[3] = 's';
|
||||
}
|
||||
#endif
|
||||
#ifdef S_ISGID
|
||||
if (bits & S_ISGID)
|
||||
{
|
||||
if (chars[6] != 'x')
|
||||
/* Set-gid, but not executable by group. */
|
||||
chars[6] = 'S';
|
||||
else
|
||||
chars[6] = 's';
|
||||
}
|
||||
#endif
|
||||
#ifdef S_ISVTX
|
||||
if (bits & S_ISVTX)
|
||||
{
|
||||
if (chars[9] != 'x')
|
||||
/* Sticky, but not executable by others. */
|
||||
chars[9] = 'T';
|
||||
else
|
||||
chars[9] = 't';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,101 +0,0 @@
|
||||
/* Generate parameters for an a.out system.
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "/usr/include/a.out.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc; char** argv;
|
||||
{
|
||||
struct exec my_exec;
|
||||
int page_size;
|
||||
char *target = "unknown", *arch = "unknown";
|
||||
FILE *file = fopen("gen-aout", "r");
|
||||
|
||||
if (file == NULL) {
|
||||
fprintf(stderr, "Cannot open gen-aout!\n");
|
||||
return -1;
|
||||
}
|
||||
if (fread(&my_exec, sizeof(struct exec), 1, file) != 1) {
|
||||
fprintf(stderr, "Cannot read gen-aout!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
target = argv[1];
|
||||
if (target == NULL) {
|
||||
fprintf(stderr, "Usage: gen-aout target_name\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#ifdef N_TXTOFF
|
||||
page_size = N_TXTOFF(my_exec);
|
||||
if (page_size == 0)
|
||||
printf("#define N_HEADER_IN_TEXT(x) 1\n");
|
||||
else
|
||||
printf("#define N_HEADER_IN_TEXT(x) 0\n");
|
||||
#endif
|
||||
|
||||
printf("#define BYTES_IN_WORD %d\n", sizeof (int));
|
||||
if (my_exec.a_entry == 0) {
|
||||
printf("#define ENTRY_CAN_BE_ZERO\n");
|
||||
printf("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n");
|
||||
}
|
||||
else {
|
||||
printf("/*#define ENTRY_CAN_BE_ZERO*/\n");
|
||||
printf("/*#define N_SHARED_LIB(x) 0*/\n");
|
||||
}
|
||||
|
||||
printf("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
|
||||
|
||||
#ifdef PAGSIZ
|
||||
if (page_size == 0)
|
||||
page_size = PAGSIZ;
|
||||
#endif
|
||||
if (page_size != 0)
|
||||
printf("#define TARGET_PAGE_SIZE %d\n", page_size);
|
||||
else
|
||||
printf("/* #define TARGET_PAGE_SIZE ??? */\n");
|
||||
printf("#define SEGMENT_SIZE TARGET_PAGE_SIZE\n");
|
||||
|
||||
#ifdef vax
|
||||
arch = "vax";
|
||||
#endif
|
||||
#ifdef m68k
|
||||
arch = "m68k";
|
||||
#endif
|
||||
if (arch[0] == '1')
|
||||
{
|
||||
fprintf (stderr, "warning: preprocessor substituted architecture name inside string;");
|
||||
fprintf (stderr, " fix DEFAULT_ARCH in the output file yourself\n");
|
||||
arch = "unknown";
|
||||
}
|
||||
printf("#define DEFAULT_ARCH bfd_arch_%s\n", arch);
|
||||
|
||||
printf("\n#define MY(OP) CAT(%s_,OP)\n", target);
|
||||
printf("#define TARGETNAME \"a.out-%s\"\n\n", target);
|
||||
|
||||
printf("#include \"bfd.h\"\n");
|
||||
printf("#include \"sysdep.h\"\n");
|
||||
printf("#include \"libbfd.h\"\n");
|
||||
printf("#include \"libaout.h\"\n");
|
||||
printf("\n#include \"aout-target.h\"\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* BFD backend for local host's a.out binaries
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support. Probably John Gilmore's fault.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#define ARCH_SIZE 32
|
||||
|
||||
/* When porting to a new system, you must supply:
|
||||
|
||||
HOST_PAGE_SIZE (optional)
|
||||
HOST_SEGMENT_SIZE (optional -- defaults to page size)
|
||||
HOST_MACHINE_ARCH (optional)
|
||||
HOST_MACHINE_MACHINE (optional)
|
||||
HOST_TEXT_START_ADDR (optional)
|
||||
HOST_STACK_END_ADDR (not used, except by trad-core ???)
|
||||
HOST_BIG_ENDIAN_P (required -- define if big-endian)
|
||||
|
||||
in the ./hosts/h-systemname.h file. */
|
||||
|
||||
#ifdef TRAD_HEADER
|
||||
#include TRAD_HEADER
|
||||
#endif
|
||||
|
||||
#ifdef HOST_PAGE_SIZE
|
||||
#define TARGET_PAGE_SIZE HOST_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
#ifdef HOST_SEGMENT_SIZE
|
||||
#define SEGMENT_SIZE HOST_SEGMENT_SIZE
|
||||
#else
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#endif
|
||||
|
||||
#ifdef HOST_TEXT_START_ADDR
|
||||
#define TEXT_START_ADDR HOST_TEXT_START_ADDR
|
||||
#endif
|
||||
|
||||
#ifdef HOST_STACK_END_ADDR
|
||||
#define STACK_END_ADDR HOST_STACK_END_ADDR
|
||||
#endif
|
||||
|
||||
#ifdef HOST_BIG_ENDIAN_P
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
#else
|
||||
#undef TARGET_IS_BIG_ENDIAN_P
|
||||
#endif
|
||||
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
#include "aout/aout64.h"
|
||||
|
||||
#ifdef HOST_MACHINE_ARCH
|
||||
#ifdef HOST_MACHINE_MACHINE
|
||||
#define SET_ARCH_MACH(abfd, execp) \
|
||||
bfd_default_set_arch_mach(abfd, HOST_MACHINE_ARCH, HOST_MACHINE_MACHINE)
|
||||
#else
|
||||
#define SET_ARCH_MACH(abfd, execp) \
|
||||
bfd_default_set_arch_mach(abfd, HOST_MACHINE_ARCH, 0)
|
||||
#endif
|
||||
#endif /* HOST_MACHINE_ARCH */
|
||||
|
||||
#define MY(OP) CAT(host_aout_,OP)
|
||||
#define TARGETNAME "a.out"
|
||||
|
||||
#include "aout-target.h"
|
@ -1,38 +0,0 @@
|
||||
/* BFD back-end for HP 9000/300 (68000-based) machines running BSD Unix.
|
||||
Copyright 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
#define N_HEADER_IN_TEXT(x) 0
|
||||
#define BYTES_IN_WORD 4
|
||||
#define ENTRY_CAN_BE_ZERO
|
||||
#define N_SHARED_LIB(x) 0 /* Avoids warning */
|
||||
#define TEXT_START_ADDR 0
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define DEFAULT_ARCH bfd_arch_m68k
|
||||
|
||||
#define MY(OP) CAT(hp300bsd_,OP)
|
||||
#define TARGETNAME "a.out-hp300bsd"
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "libaout.h"
|
||||
|
||||
#include "aout-target.h"
|
@ -1,865 +0,0 @@
|
||||
/* BFD backend for hp-ux 9000/300
|
||||
Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Glenn Engel.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
|
||||
hpux native ------------> | |
|
||||
| hp300hpux bfd | ----------> hpux w/gnu ext
|
||||
hpux w/gnu extension ----> | |
|
||||
|
||||
|
||||
Support for the 9000/[34]00 has several limitations.
|
||||
1. Shared libraries are not supported.
|
||||
2. The output format from this bfd is not usable by native tools.
|
||||
|
||||
The primary motivation for writing this bfd was to allow use of
|
||||
gdb and gcc for host based debugging and not to mimic the hp-ux tools
|
||||
in every detail. This leads to a significant simplification of the
|
||||
code and a leap in performance. The decision to not output hp native
|
||||
compatible objects was further strengthened by the fact that the richness
|
||||
of the gcc compiled objects could not be represented without loss of
|
||||
information. For example, while the hp format supports the concept of
|
||||
secondary symbols, it does not support indirect symbols. Another
|
||||
reason is to maintain backwards compatibility with older implementations
|
||||
of gcc on hpux which used 'hpxt' to translate .a and .o files into a
|
||||
format which could be readily understood by the gnu linker and gdb.
|
||||
This allows reading hp secondary symbols and converting them into
|
||||
indirect symbols but the reverse it not always possible.
|
||||
|
||||
Another example of differences is that the hp format stores symbol offsets
|
||||
in the object code while the gnu utilities use a field in the
|
||||
relocation record for this. To support the hp native format, the object
|
||||
code would need to be patched with the offsets when producing .o files.
|
||||
|
||||
The basic technique taken in this implementation is to #include the code
|
||||
from aoutx.h and aout-target.h with appropriate #defines to override
|
||||
code where a unique implementation is needed:
|
||||
|
||||
{
|
||||
#define a bunch of stuff
|
||||
#include <aoutx.h>
|
||||
|
||||
implement a bunch of functions
|
||||
|
||||
#include "aout-target.h"
|
||||
}
|
||||
|
||||
The hp symbol table is a bit different than other a.out targets. Instead
|
||||
of having an array of nlist items and an array of strings, hp's format
|
||||
has them mixed together in one structure. In addition, the strings are
|
||||
not null terminated. It looks something like this:
|
||||
|
||||
nlist element 1
|
||||
string1
|
||||
nlist element 2
|
||||
string2
|
||||
...
|
||||
|
||||
The whole symbol table is read as one chunk and then we march thru it
|
||||
and convert it to canonical form. As we march thru the table, we copy
|
||||
the nlist data into the internal form and we compact the strings and null
|
||||
terminate them, using storage from the already allocated symbol table:
|
||||
|
||||
string1
|
||||
null
|
||||
string2
|
||||
null
|
||||
*/
|
||||
|
||||
/* @@ Is this really so different from normal a.out that it needs to include
|
||||
aoutx.h? We should go through this file sometime and see what can be made
|
||||
more dependent on aout32.o and what might need to be broken off and accessed
|
||||
through the backend_data field. Or, maybe we really do need such a
|
||||
completely separate implementation. I don't have time to investigate this
|
||||
much further right now. [raeburn:19930428.2124EST] */
|
||||
/* @@ Also, note that there wind up being two versions of some routines, with
|
||||
different names, only one of which actually gets used. For example:
|
||||
slurp_symbol_table
|
||||
swap_std_reloc_in
|
||||
slurp_reloc_table
|
||||
get_symtab
|
||||
get_symtab_upper_bound
|
||||
canonicalize_reloc
|
||||
mkobject
|
||||
This should also be fixed. */
|
||||
|
||||
#define TARGETNAME "a.out-hp300hpux"
|
||||
#define MY(OP) CAT(hp300hpux_,OP)
|
||||
|
||||
#define external_exec hp300hpux_exec_bytes
|
||||
#define external_nlist hp300hpux_nlist_bytes
|
||||
|
||||
#include "aout/hp300hpux.h"
|
||||
|
||||
/* define these so we can compile unused routines in aoutx.h */
|
||||
#define e_strx e_shlib
|
||||
#define e_other e_length
|
||||
#define e_desc e_almod
|
||||
|
||||
#define AR_PAD_CHAR '/'
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
#define DEFAULT_ARCH bfd_arch_m68k
|
||||
|
||||
#define MY_get_section_contents aout_32_get_section_contents
|
||||
#define MY_slurp_armap bfd_slurp_bsd_armap_f2
|
||||
|
||||
/***********************************************/
|
||||
/* provide overrides for routines in this file */
|
||||
/***********************************************/
|
||||
/* these don't use MY because that causes problems within JUMP_TABLE
|
||||
(CAT winds up being expanded recursively, which ANSI C compilers
|
||||
will not do). */
|
||||
#define MY_get_symtab hp300hpux_get_symtab
|
||||
#define MY_get_symtab_upper_bound hp300hpux_get_symtab_upper_bound
|
||||
#define MY_canonicalize_reloc hp300hpux_canonicalize_reloc
|
||||
#define MY_write_object_contents hp300hpux_write_object_contents
|
||||
|
||||
#define MY_read_minisymbols _bfd_generic_read_minisymbols
|
||||
#define MY_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
|
||||
|
||||
#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define MY_final_link_callback unused
|
||||
#define MY_bfd_final_link _bfd_generic_final_link
|
||||
|
||||
/* Until and unless we convert the slurp_reloc and slurp_symtab
|
||||
routines in this file, we can not use the default aout
|
||||
free_cached_info routine which assumes that the relocs and symtabs
|
||||
were allocated using malloc. */
|
||||
#define MY_bfd_free_cached_info bfd_true
|
||||
|
||||
#define hp300hpux_write_syms aout_32_write_syms
|
||||
|
||||
#define MY_callback MY(callback)
|
||||
|
||||
#define MY_exec_hdr_flags 0x2
|
||||
|
||||
#define NAME_swap_exec_header_in NAME(hp300hpux_32_,swap_exec_header_in)
|
||||
|
||||
#define HP_SYMTYPE_UNDEFINED 0x00
|
||||
#define HP_SYMTYPE_ABSOLUTE 0x01
|
||||
#define HP_SYMTYPE_TEXT 0x02
|
||||
#define HP_SYMTYPE_DATA 0x03
|
||||
#define HP_SYMTYPE_BSS 0x04
|
||||
#define HP_SYMTYPE_COMMON 0x05
|
||||
|
||||
#define HP_SYMTYPE_TYPE 0x0F
|
||||
#define HP_SYMTYPE_FILENAME 0x1F
|
||||
|
||||
#define HP_SYMTYPE_ALIGN 0x10
|
||||
#define HP_SYMTYPE_EXTERNAL 0x20
|
||||
#define HP_SECONDARY_SYMBOL 0x40
|
||||
|
||||
/* RELOCATION DEFINITIONS */
|
||||
#define HP_RSEGMENT_TEXT 0x00
|
||||
#define HP_RSEGMENT_DATA 0x01
|
||||
#define HP_RSEGMENT_BSS 0x02
|
||||
#define HP_RSEGMENT_EXTERNAL 0x03
|
||||
#define HP_RSEGMENT_PCREL 0x04
|
||||
#define HP_RSEGMENT_RDLT 0x05
|
||||
#define HP_RSEGMENT_RPLT 0x06
|
||||
#define HP_RSEGMENT_NOOP 0x3F
|
||||
|
||||
#define HP_RLENGTH_BYTE 0x00
|
||||
#define HP_RLENGTH_WORD 0x01
|
||||
#define HP_RLENGTH_LONG 0x02
|
||||
#define HP_RLENGTH_ALIGN 0x03
|
||||
|
||||
#define NAME(x,y) CAT3(hp300hpux,_32_,y)
|
||||
#define ARCH_SIZE 32
|
||||
|
||||
/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
|
||||
#define BMAGIC HPUX_DOT_O_MAGIC
|
||||
#define QMAGIC 0314
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
/* Since the hpux symbol table has nlist elements interspersed with
|
||||
strings and we need to insert som strings for secondary symbols, we
|
||||
give ourselves a little extra padding up front to account for
|
||||
this. Note that for each non-secondary symbol we process, we gain
|
||||
9 bytes of space for the discarded nlist element (one byte used for
|
||||
null). SYM_EXTRA_BYTES is the extra space. */
|
||||
#define SYM_EXTRA_BYTES 1024
|
||||
|
||||
/* Set parameters about this a.out file that are machine-dependent.
|
||||
This routine is called from some_aout_object_p just before it returns. */
|
||||
static const bfd_target *
|
||||
MY (callback) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* Calculate the file positions of the parts of a newly read aout header */
|
||||
obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
|
||||
|
||||
/* The virtual memory addresses of the sections */
|
||||
obj_textsec (abfd)->vma = N_TXTADDR (*execp);
|
||||
obj_datasec (abfd)->vma = N_DATADDR (*execp);
|
||||
obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
|
||||
|
||||
obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
|
||||
obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
|
||||
obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
|
||||
|
||||
/* The file offsets of the sections */
|
||||
obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
|
||||
obj_datasec (abfd)->filepos = N_DATOFF (*execp);
|
||||
|
||||
/* The file offsets of the relocation info */
|
||||
obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
|
||||
obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
|
||||
|
||||
/* The file offsets of the string table and symbol table. */
|
||||
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
#ifdef SET_ARCH_MACH
|
||||
SET_ARCH_MACH (abfd, *execp);
|
||||
#else
|
||||
bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
|
||||
#endif
|
||||
|
||||
|
||||
if (obj_aout_subformat (abfd) == gnu_encap_format)
|
||||
{
|
||||
/* The file offsets of the relocation info */
|
||||
obj_textsec (abfd)->rel_filepos = N_GNU_TRELOFF (*execp);
|
||||
obj_datasec (abfd)->rel_filepos = N_GNU_DRELOFF (*execp);
|
||||
|
||||
/* The file offsets of the string table and symbol table. */
|
||||
obj_sym_filepos (abfd) = N_GNU_SYMOFF (*execp);
|
||||
obj_str_filepos (abfd) = (obj_sym_filepos (abfd) + execp->a_syms);
|
||||
|
||||
abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
|
||||
bfd_get_symcount (abfd) = execp->a_syms / 12;
|
||||
obj_symbol_entry_size (abfd) = 12;
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
}
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
extern boolean aout_32_write_syms PARAMS ((bfd * abfd));
|
||||
|
||||
static boolean
|
||||
MY (write_object_contents) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
bfd_size_type text_size; /* dummy vars */
|
||||
file_ptr text_end;
|
||||
|
||||
memset (&exec_bytes, 0, sizeof (exec_bytes));
|
||||
#if CHOOSE_RELOC_SIZE
|
||||
CHOOSE_RELOC_SIZE (abfd);
|
||||
#else
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
#endif
|
||||
|
||||
if (adata (abfd).magic == undecided_magic)
|
||||
NAME (aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
|
||||
execp->a_syms = 0;
|
||||
|
||||
execp->a_entry = bfd_get_start_address (abfd);
|
||||
|
||||
execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
|
||||
obj_reloc_entry_size (abfd));
|
||||
execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
|
||||
obj_reloc_entry_size (abfd));
|
||||
|
||||
N_SET_MACHTYPE (*execp, 0xc);
|
||||
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
|
||||
NAME (aout,swap_exec_header_out) (abfd, execp, &exec_bytes);
|
||||
|
||||
/* update fields not covered by default swap_exec_header_out */
|
||||
|
||||
/* this is really the sym table size but we store it in drelocs */
|
||||
bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
|
||||
|
||||
if (bfd_seek (abfd, 0L, false) != 0
|
||||
|| (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE))
|
||||
return false;
|
||||
|
||||
/* Write out the symbols, and then the relocs. We must write out
|
||||
the symbols first so that we know the symbol indices. */
|
||||
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
/* Skip the relocs to where we want to put the symbols. */
|
||||
if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
|
||||
SEEK_SET) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!MY (write_syms) (abfd))
|
||||
return false;
|
||||
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
|
||||
return false;
|
||||
if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
|
||||
return false;
|
||||
if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
|
||||
return false;
|
||||
if (!NAME (aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* convert the hp symbol type to be the same as aout64.h usage so we */
|
||||
/* can piggyback routines in aoutx.h. */
|
||||
|
||||
static void
|
||||
convert_sym_type (sym_pointer, cache_ptr, abfd)
|
||||
struct external_nlist *sym_pointer;
|
||||
aout_symbol_type *cache_ptr;
|
||||
bfd *abfd;
|
||||
{
|
||||
int name_type;
|
||||
int new_type;
|
||||
|
||||
name_type = (cache_ptr->type);
|
||||
new_type = 0;
|
||||
|
||||
if ((name_type & HP_SYMTYPE_ALIGN) != 0)
|
||||
{
|
||||
/* iou_error ("aligned symbol encountered: %s", name);*/
|
||||
name_type = 0;
|
||||
}
|
||||
|
||||
if (name_type == HP_SYMTYPE_FILENAME)
|
||||
new_type = N_FN;
|
||||
else
|
||||
{
|
||||
switch (name_type & HP_SYMTYPE_TYPE)
|
||||
{
|
||||
case HP_SYMTYPE_UNDEFINED:
|
||||
new_type = N_UNDF;
|
||||
break;
|
||||
|
||||
case HP_SYMTYPE_ABSOLUTE:
|
||||
new_type = N_ABS;
|
||||
break;
|
||||
|
||||
case HP_SYMTYPE_TEXT:
|
||||
new_type = N_TEXT;
|
||||
break;
|
||||
|
||||
case HP_SYMTYPE_DATA:
|
||||
new_type = N_DATA;
|
||||
break;
|
||||
|
||||
case HP_SYMTYPE_BSS:
|
||||
new_type = N_BSS;
|
||||
break;
|
||||
|
||||
case HP_SYMTYPE_COMMON:
|
||||
new_type = N_COMM;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
if (name_type & HP_SYMTYPE_EXTERNAL)
|
||||
new_type |= N_EXT;
|
||||
|
||||
if (name_type & HP_SECONDARY_SYMBOL)
|
||||
{
|
||||
switch (new_type)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
case N_UNDF | N_EXT:
|
||||
new_type = N_WEAKU;
|
||||
break;
|
||||
case N_ABS | N_EXT:
|
||||
new_type = N_WEAKA;
|
||||
break;
|
||||
case N_TEXT | N_EXT:
|
||||
new_type = N_WEAKT;
|
||||
break;
|
||||
case N_DATA | N_EXT:
|
||||
new_type = N_WEAKD;
|
||||
break;
|
||||
case N_BSS | N_EXT:
|
||||
new_type = N_WEAKB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cache_ptr->type = new_type;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
Swaps the information in an executable header taken from a raw
|
||||
byte stream memory image, into the internal exec_header
|
||||
structure.
|
||||
*/
|
||||
|
||||
void
|
||||
NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp)
|
||||
bfd *abfd;
|
||||
struct external_exec *raw_bytes;
|
||||
struct internal_exec *execp;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *) raw_bytes;
|
||||
|
||||
/* The internal_exec structure has some fields that are unused in this
|
||||
configuration (IE for i960), so ensure that all such uninitialized
|
||||
fields are zero'd out. There are places where two of these structs
|
||||
are memcmp'd, and thus the contents do matter. */
|
||||
memset (execp, 0, sizeof (struct internal_exec));
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
|
||||
execp->a_text = GET_WORD (abfd, bytes->e_text);
|
||||
execp->a_data = GET_WORD (abfd, bytes->e_data);
|
||||
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
|
||||
execp->a_syms = GET_WORD (abfd, bytes->e_syms);
|
||||
execp->a_entry = GET_WORD (abfd, bytes->e_entry);
|
||||
execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
|
||||
execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
|
||||
|
||||
/***************************************************************/
|
||||
/* check the header to see if it was generated by a bfd output */
|
||||
/* this is detected rather bizarely by requiring a bunch of */
|
||||
/* header fields to be zero and an old unused field (now used) */
|
||||
/* to be set. */
|
||||
/***************************************************************/
|
||||
do
|
||||
{
|
||||
long syms;
|
||||
struct aout_data_struct *rawptr;
|
||||
if (bfd_h_get_32 (abfd, bytes->e_passize) != 0)
|
||||
break;
|
||||
if (bfd_h_get_32 (abfd, bytes->e_syms) != 0)
|
||||
break;
|
||||
if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0)
|
||||
break;
|
||||
|
||||
syms = bfd_h_get_32 (abfd, bytes->e_drelocs);
|
||||
if (syms == 0)
|
||||
break;
|
||||
|
||||
/* OK, we've passed the test as best as we can determine */
|
||||
execp->a_syms = syms;
|
||||
|
||||
/* allocate storage for where we will store this result */
|
||||
rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr));
|
||||
|
||||
if (rawptr == NULL)
|
||||
return;
|
||||
abfd->tdata.aout_data = rawptr;
|
||||
obj_aout_subformat (abfd) = gnu_encap_format;
|
||||
}
|
||||
while (0);
|
||||
}
|
||||
|
||||
|
||||
/* The hp symbol table is a bit different than other a.out targets. Instead
|
||||
of having an array of nlist items and an array of strings, hp's format
|
||||
has them mixed together in one structure. In addition, the strings are
|
||||
not null terminated. It looks something like this:
|
||||
|
||||
nlist element 1
|
||||
string1
|
||||
nlist element 2
|
||||
string2
|
||||
...
|
||||
|
||||
The whole symbol table is read as one chunk and then we march thru it
|
||||
and convert it to canonical form. As we march thru the table, we copy
|
||||
the nlist data into the internal form and we compact the strings and null
|
||||
terminate them, using storage from the already allocated symbol table:
|
||||
|
||||
string1
|
||||
null
|
||||
string2
|
||||
null
|
||||
...
|
||||
*/
|
||||
|
||||
boolean
|
||||
MY (slurp_symbol_table) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
bfd_size_type symbol_bytes;
|
||||
struct external_nlist *syms;
|
||||
struct external_nlist *sym_pointer;
|
||||
struct external_nlist *sym_end;
|
||||
char *strings;
|
||||
aout_symbol_type *cached;
|
||||
unsigned num_syms = 0;
|
||||
|
||||
/* If there's no work to be done, don't do any */
|
||||
if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
|
||||
return true;
|
||||
symbol_bytes = exec_hdr (abfd)->a_syms;
|
||||
|
||||
strings = (char *) bfd_alloc (abfd,
|
||||
symbol_bytes + SYM_EXTRA_BYTES);
|
||||
if (!strings)
|
||||
return false;
|
||||
syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
|
||||
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
|
||||
|| bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
|
||||
{
|
||||
bfd_release (abfd, syms);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
sym_end = (struct external_nlist *) (((char *) syms) + symbol_bytes);
|
||||
|
||||
/* first, march thru the table and figure out how many symbols there are */
|
||||
for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++, num_syms++)
|
||||
{
|
||||
/* skip over the embedded symbol. */
|
||||
sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
|
||||
sym_pointer->e_length[0]);
|
||||
}
|
||||
|
||||
/* now that we know the symbol count, update the bfd header */
|
||||
bfd_get_symcount (abfd) = num_syms;
|
||||
|
||||
cached = ((aout_symbol_type *)
|
||||
bfd_zalloc (abfd,
|
||||
bfd_get_symcount (abfd) * sizeof (aout_symbol_type)));
|
||||
if (cached == NULL && bfd_get_symcount (abfd) != 0)
|
||||
return false;
|
||||
|
||||
/* as we march thru the hp symbol table, convert it into a list of
|
||||
null terminated strings to hold the symbol names. Make sure any
|
||||
assignment to the strings pointer is done after we're thru using
|
||||
the nlist so we don't overwrite anything important. */
|
||||
|
||||
/* OK, now walk the new symtable, cacheing symbol properties */
|
||||
{
|
||||
aout_symbol_type *cache_ptr = cached;
|
||||
aout_symbol_type cache_save;
|
||||
/* Run through table and copy values */
|
||||
for (sym_pointer = syms, cache_ptr = cached;
|
||||
sym_pointer < sym_end; sym_pointer++, cache_ptr++)
|
||||
{
|
||||
unsigned int length;
|
||||
cache_ptr->symbol.the_bfd = abfd;
|
||||
cache_ptr->symbol.value = GET_SWORD (abfd, sym_pointer->e_value);
|
||||
cache_ptr->desc = bfd_get_16 (abfd, sym_pointer->e_almod);
|
||||
cache_ptr->type = bfd_get_8 (abfd, sym_pointer->e_type);
|
||||
cache_ptr->symbol.udata.p = NULL;
|
||||
length = bfd_get_8 (abfd, sym_pointer->e_length);
|
||||
cache_ptr->other = length; /* other not used, save length here */
|
||||
|
||||
cache_save = *cache_ptr;
|
||||
convert_sym_type (sym_pointer, cache_ptr, abfd);
|
||||
if (!translate_from_native_sym_flags (abfd, cache_ptr))
|
||||
return false;
|
||||
|
||||
/********************************************************/
|
||||
/* for hpux, the 'lenght' value indicates the length of */
|
||||
/* the symbol name which follows the nlist entry. */
|
||||
/********************************************************/
|
||||
if (length)
|
||||
{
|
||||
/**************************************************************/
|
||||
/* the hp string is not null terminated so we create a new one*/
|
||||
/* by copying the string to overlap the just vacated nlist */
|
||||
/* structure before it in memory. */
|
||||
/**************************************************************/
|
||||
cache_ptr->symbol.name = strings;
|
||||
memcpy (strings, sym_pointer + 1, length);
|
||||
strings[length] = '\0';
|
||||
strings += length + 1;
|
||||
}
|
||||
else
|
||||
cache_ptr->symbol.name = (char *) NULL;
|
||||
|
||||
/* skip over the embedded symbol. */
|
||||
sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
|
||||
length);
|
||||
}
|
||||
}
|
||||
|
||||
obj_aout_symbols (abfd) = cached;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct hp300hpux_reloc *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern = 0;
|
||||
unsigned int r_length;
|
||||
int r_pcrel = 0;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||
r_index = bfd_h_get_16 (abfd, bytes->r_index);
|
||||
|
||||
switch (bytes->r_type[0])
|
||||
{
|
||||
case HP_RSEGMENT_TEXT:
|
||||
r_index = N_TEXT;
|
||||
break;
|
||||
case HP_RSEGMENT_DATA:
|
||||
r_index = N_DATA;
|
||||
break;
|
||||
case HP_RSEGMENT_BSS:
|
||||
r_index = N_BSS;
|
||||
break;
|
||||
case HP_RSEGMENT_EXTERNAL:
|
||||
r_extern = 1;
|
||||
break;
|
||||
case HP_RSEGMENT_PCREL:
|
||||
r_extern = 1;
|
||||
r_pcrel = 1;
|
||||
break;
|
||||
case HP_RSEGMENT_RDLT:
|
||||
break;
|
||||
case HP_RSEGMENT_RPLT:
|
||||
break;
|
||||
case HP_RSEGMENT_NOOP:
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
|
||||
switch (bytes->r_length[0])
|
||||
{
|
||||
case HP_RLENGTH_BYTE:
|
||||
r_length = 0;
|
||||
break;
|
||||
case HP_RLENGTH_WORD:
|
||||
r_length = 1;
|
||||
break;
|
||||
case HP_RLENGTH_LONG:
|
||||
r_length = 2;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
|
||||
cache_ptr->howto = howto_table_std + r_length + 4 * r_pcrel;
|
||||
/* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */
|
||||
|
||||
/* This macro uses the r_index value computed above */
|
||||
if (r_pcrel && r_extern)
|
||||
{
|
||||
/* The GNU linker assumes any offset from beginning of section */
|
||||
/* is already incorporated into the image while the HP linker */
|
||||
/* adds this in later. Add it in now... */
|
||||
MOVE_ADDRESS (-cache_ptr->address);
|
||||
}
|
||||
else
|
||||
{
|
||||
MOVE_ADDRESS (0);
|
||||
}
|
||||
}
|
||||
|
||||
boolean
|
||||
MY (slurp_reloc_table) (abfd, asect, symbols)
|
||||
bfd *abfd;
|
||||
sec_ptr asect;
|
||||
asymbol **symbols;
|
||||
{
|
||||
unsigned int count;
|
||||
bfd_size_type reloc_size;
|
||||
PTR relocs;
|
||||
arelent *reloc_cache;
|
||||
size_t each_size;
|
||||
struct hp300hpux_reloc *rptr;
|
||||
unsigned int counter;
|
||||
arelent *cache_ptr;
|
||||
|
||||
if (asect->relocation)
|
||||
return true;
|
||||
|
||||
if (asect->flags & SEC_CONSTRUCTOR)
|
||||
return true;
|
||||
|
||||
if (asect == obj_datasec (abfd))
|
||||
{
|
||||
reloc_size = exec_hdr (abfd)->a_drsize;
|
||||
goto doit;
|
||||
}
|
||||
|
||||
if (asect == obj_textsec (abfd))
|
||||
{
|
||||
reloc_size = exec_hdr (abfd)->a_trsize;
|
||||
goto doit;
|
||||
}
|
||||
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return false;
|
||||
|
||||
doit:
|
||||
if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
|
||||
return false;
|
||||
each_size = obj_reloc_entry_size (abfd);
|
||||
|
||||
count = reloc_size / each_size;
|
||||
|
||||
|
||||
reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
|
||||
(arelent)));
|
||||
if (!reloc_cache && count != 0)
|
||||
return false;
|
||||
|
||||
relocs = (PTR) bfd_alloc (abfd, reloc_size);
|
||||
if (!relocs && reloc_size != 0)
|
||||
{
|
||||
bfd_release (abfd, reloc_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
|
||||
{
|
||||
bfd_release (abfd, relocs);
|
||||
bfd_release (abfd, reloc_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
rptr = (struct hp300hpux_reloc *) relocs;
|
||||
counter = 0;
|
||||
cache_ptr = reloc_cache;
|
||||
|
||||
for (; counter < count; counter++, rptr++, cache_ptr++)
|
||||
{
|
||||
MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
|
||||
bfd_get_symcount (abfd));
|
||||
}
|
||||
|
||||
|
||||
bfd_release (abfd, relocs);
|
||||
asect->relocation = reloc_cache;
|
||||
asect->reloc_count = count;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* The following functions are identical to functions in aoutx.h except */
|
||||
/* they refer to MY(func) rather than NAME(aout,func) and they also */
|
||||
/* call aout_32 versions if the input file was generated by gcc */
|
||||
/************************************************************************/
|
||||
|
||||
long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
|
||||
long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
|
||||
|
||||
long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
|
||||
arelent ** relptr,
|
||||
asymbol ** symbols));
|
||||
|
||||
long
|
||||
MY (get_symtab) (abfd, location)
|
||||
bfd *abfd;
|
||||
asymbol **location;
|
||||
{
|
||||
unsigned int counter = 0;
|
||||
aout_symbol_type *symbase;
|
||||
|
||||
if (obj_aout_subformat (abfd) == gnu_encap_format)
|
||||
return aout_32_get_symtab (abfd, location);
|
||||
|
||||
if (!MY (slurp_symbol_table) (abfd))
|
||||
return -1;
|
||||
|
||||
for (symbase = obj_aout_symbols (abfd); counter++ < bfd_get_symcount (abfd);)
|
||||
*(location++) = (asymbol *) (symbase++);
|
||||
*location++ = 0;
|
||||
return bfd_get_symcount (abfd);
|
||||
}
|
||||
|
||||
long
|
||||
MY (get_symtab_upper_bound) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (obj_aout_subformat (abfd) == gnu_encap_format)
|
||||
return aout_32_get_symtab_upper_bound (abfd);
|
||||
if (!MY (slurp_symbol_table) (abfd))
|
||||
return -1;
|
||||
|
||||
return (bfd_get_symcount (abfd) + 1) * (sizeof (aout_symbol_type *));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
long
|
||||
MY (canonicalize_reloc) (abfd, section, relptr, symbols)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
arelent **relptr;
|
||||
asymbol **symbols;
|
||||
{
|
||||
arelent *tblptr = section->relocation;
|
||||
unsigned int count;
|
||||
if (obj_aout_subformat (abfd) == gnu_encap_format)
|
||||
return aout_32_canonicalize_reloc (abfd, section, relptr, symbols);
|
||||
|
||||
if (!(tblptr || MY (slurp_reloc_table) (abfd, section, symbols)))
|
||||
return -1;
|
||||
|
||||
if (section->flags & SEC_CONSTRUCTOR)
|
||||
{
|
||||
arelent_chain *chain = section->constructor_chain;
|
||||
for (count = 0; count < section->reloc_count; count++)
|
||||
{
|
||||
*relptr++ = &chain->relent;
|
||||
chain = chain->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tblptr = section->relocation;
|
||||
|
||||
for (count = 0; count++ < section->reloc_count;)
|
||||
{
|
||||
*relptr++ = tblptr++;
|
||||
}
|
||||
}
|
||||
*relptr = 0;
|
||||
|
||||
return section->reloc_count;
|
||||
}
|
||||
|
||||
|
||||
#include "aout-target.h"
|
@ -1,23 +0,0 @@
|
||||
/* HPPA linker stub instructions */
|
||||
|
||||
/* These are the instructions which the linker may insert into the
|
||||
code stream when building final executables to handle out-of-range
|
||||
calls and argument relocations. */
|
||||
|
||||
#define LDO_M4_R31_R31 0x37ff3ff9 /* ldo -4(%r31),%r31 */
|
||||
#define LDIL_R1 0x20200000 /* ldil XXX,%r1 */
|
||||
#define BE_SR4_R1 0xe0202000 /* be XXX(%sr4,%r1) */
|
||||
#define COPY_R31_R2 0x081f0242 /* copy %r31,%r2 */
|
||||
#define BLE_SR4_R0 0xe4002000 /* ble XXX(%sr4,%r0) */
|
||||
#define BLE_SR4_R1 0xe4202000 /* ble XXX(%sr4,%r1) */
|
||||
#define BV_N_0_R31 0xebe0c002 /* bv,n 0(%r31) */
|
||||
#define STW_R31_M8R30 0x6bdf3ff1 /* stw %r31,-8(%r30) */
|
||||
#define LDW_M8R30_R31 0x4bdf3ff1 /* ldw -8(%r30),%r31 */
|
||||
#define STW_ARG_M16R30 0x6bc03fe1 /* stw %argX,-16(%r30) */
|
||||
#define LDW_M16R30_ARG 0x4bc03fe1 /* ldw -12(%r30),%argX */
|
||||
#define STW_ARG_M12R30 0x6bc03fe9 /* stw %argX,-16(%r30) */
|
||||
#define LDW_M12R30_ARG 0x4bc03fe9 /* ldw -12(%r30),%argX */
|
||||
#define FSTW_FARG_M16R30 0x27c11200 /* fstws %fargX,-16(%r30) */
|
||||
#define FLDW_M16R30_FARG 0x27c11000 /* fldws -16(%r30),%fargX */
|
||||
#define FSTD_FARG_M16R30 0x2fc11200 /* fstds %fargX,-16(%r30) */
|
||||
#define FLDD_M16R30_FARG 0x2fc11000 /* fldds -16(%r30),%fargX */
|
@ -1,305 +0,0 @@
|
||||
/* BFD back-end for HPPA BSD core files.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Written by the Center for Software Science at the University of Utah
|
||||
and by Cygnus Support.
|
||||
|
||||
The core file structure for the Utah 4.3BSD and OSF1 ports on the
|
||||
PA is a mix between traditional cores and hpux cores -- just
|
||||
different enough that supporting this format would tend to add
|
||||
gross hacks to trad-core.c or hpux-core.c. So instead we keep any
|
||||
gross hacks isolated to this file. */
|
||||
|
||||
|
||||
/* This file can only be compiled on systems which use HPPA-BSD style
|
||||
core files.
|
||||
|
||||
I would not expect this to be of use to any other host/target, but
|
||||
you never know. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#if defined (HOST_HPPABSD)
|
||||
|
||||
#include "machine/vmparam.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/dir.h>
|
||||
#include <signal.h>
|
||||
#include <machine/reg.h>
|
||||
#include <sys/user.h> /* After a.out.h */
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
|
||||
static asection *make_bfd_asection PARAMS ((bfd *, CONST char *,
|
||||
flagword, bfd_size_type,
|
||||
file_ptr, unsigned int));
|
||||
static asymbol *hppabsd_core_make_empty_symbol PARAMS ((bfd *));
|
||||
static const bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
|
||||
static char *hppabsd_core_core_file_failing_command PARAMS ((bfd *));
|
||||
static int hppabsd_core_core_file_failing_signal PARAMS ((bfd *));
|
||||
static boolean hppabsd_core_core_file_matches_executable_p
|
||||
PARAMS ((bfd *, bfd *));
|
||||
static void swap_abort PARAMS ((void));
|
||||
|
||||
/* These are stored in the bfd's tdata. */
|
||||
|
||||
struct hppabsd_core_struct
|
||||
{
|
||||
int sig;
|
||||
char cmd[MAXCOMLEN + 1];
|
||||
asection *data_section;
|
||||
asection *stack_section;
|
||||
asection *reg_section;
|
||||
};
|
||||
|
||||
#define core_hdr(bfd) ((bfd)->tdata.hppabsd_core_data)
|
||||
#define core_signal(bfd) (core_hdr(bfd)->sig)
|
||||
#define core_command(bfd) (core_hdr(bfd)->cmd)
|
||||
#define core_datasec(bfd) (core_hdr(bfd)->data_section)
|
||||
#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
|
||||
#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
|
||||
|
||||
static asection *
|
||||
make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power)
|
||||
bfd *abfd;
|
||||
CONST char *name;
|
||||
flagword flags;
|
||||
bfd_size_type _raw_size;
|
||||
file_ptr offset;
|
||||
unsigned int alignment_power;
|
||||
{
|
||||
asection *asect;
|
||||
|
||||
asect = bfd_make_section (abfd, name);
|
||||
if (!asect)
|
||||
return NULL;
|
||||
|
||||
asect->flags = flags;
|
||||
asect->_raw_size = _raw_size;
|
||||
asect->filepos = offset;
|
||||
asect->alignment_power = alignment_power;
|
||||
|
||||
return asect;
|
||||
}
|
||||
|
||||
static asymbol *
|
||||
hppabsd_core_make_empty_symbol (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
|
||||
if (new)
|
||||
new->the_bfd = abfd;
|
||||
return new;
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
hppabsd_core_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int val;
|
||||
struct user u;
|
||||
struct hppabsd_core_struct *coredata;
|
||||
int clicksz;
|
||||
|
||||
/* Try to read in the u-area. We will need information from this
|
||||
to know how to grok the rest of the core structures. */
|
||||
val = bfd_read ((void *) &u, 1, sizeof u, abfd);
|
||||
if (val != sizeof u)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get the page size out of the u structure. This will be different
|
||||
for PA 1.0 machines and PA 1.1 machines. Yuk! */
|
||||
clicksz = u.u_pcb.pcb_pgsz;
|
||||
|
||||
/* clicksz must be a power of two >= 2k. */
|
||||
if (clicksz < 0x800
|
||||
|| clicksz != (clicksz & -clicksz))
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Sanity checks. Make sure the size of the core file matches the
|
||||
the size computed from information within the core itself. */
|
||||
{
|
||||
FILE *stream = bfd_cache_lookup (abfd);
|
||||
struct stat statbuf;
|
||||
if (stream == NULL || fstat (fileno (stream), &statbuf) < 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
if (NBPG * (UPAGES + u.u_dsize + u.u_ssize) > statbuf.st_size)
|
||||
{
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
return NULL;
|
||||
}
|
||||
if (clicksz * (UPAGES + u.u_dsize + u.u_ssize) < statbuf.st_size)
|
||||
{
|
||||
/* The file is too big. Maybe it's not a core file
|
||||
or we otherwise have bad values for u_dsize and u_ssize). */
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* OK, we believe you. You're a core file (sure, sure). */
|
||||
|
||||
coredata = (struct hppabsd_core_struct *)
|
||||
bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
|
||||
if (!coredata)
|
||||
return NULL;
|
||||
|
||||
/* Make the core data and available via the tdata part of the BFD. */
|
||||
abfd->tdata.hppabsd_core_data = coredata;
|
||||
|
||||
/* Create the sections. */
|
||||
core_stacksec (abfd) = make_bfd_asection (abfd, ".stack",
|
||||
SEC_ALLOC + SEC_HAS_CONTENTS,
|
||||
clicksz * u.u_ssize,
|
||||
NBPG * (USIZE + KSTAKSIZE)
|
||||
+ clicksz * u.u_dsize, 2);
|
||||
core_stacksec (abfd)->vma = USRSTACK;
|
||||
|
||||
core_datasec (abfd) = make_bfd_asection (abfd, ".data",
|
||||
SEC_ALLOC + SEC_LOAD
|
||||
+ SEC_HAS_CONTENTS,
|
||||
clicksz * u.u_dsize,
|
||||
NBPG * (USIZE + KSTAKSIZE), 2);
|
||||
core_datasec (abfd)->vma = UDATASEG;
|
||||
|
||||
core_regsec (abfd) = make_bfd_asection (abfd, ".reg",
|
||||
SEC_HAS_CONTENTS,
|
||||
KSTAKSIZE * NBPG,
|
||||
NBPG * USIZE, 2);
|
||||
core_regsec (abfd)->vma = 0;
|
||||
|
||||
strncpy (core_command (abfd), u.u_comm, MAXCOMLEN + 1);
|
||||
core_signal (abfd) = u.u_code;
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
hppabsd_core_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_command (abfd);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
hppabsd_core_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_signal (abfd);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static boolean
|
||||
hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd, *exec_bfd;
|
||||
{
|
||||
/* There's no way to know this... */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#define hppabsd_core_get_symtab_upper_bound \
|
||||
_bfd_nosymbols_get_symtab_upper_bound
|
||||
#define hppabsd_core_get_symtab _bfd_nosymbols_get_symtab
|
||||
#define hppabsd_core_print_symbol _bfd_nosymbols_print_symbol
|
||||
#define hppabsd_core_get_symbol_info _bfd_nosymbols_get_symbol_info
|
||||
#define hppabsd_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
|
||||
#define hppabsd_core_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define hppabsd_core_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define hppabsd_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define hppabsd_core_read_minisymbols _bfd_nosymbols_read_minisymbols
|
||||
#define hppabsd_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
static void
|
||||
swap_abort ()
|
||||
{
|
||||
/* This way doesn't require any declaration for ANSI to fuck up. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET \
|
||||
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
|
||||
|
||||
const bfd_target hppabsd_core_vec =
|
||||
{
|
||||
"hppabsd-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
hppabsd_core_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (hppabsd_core),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (hppabsd_core),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
#endif
|
@ -1,270 +0,0 @@
|
||||
/* BFD back-end for HP/UX core files.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Stu Grossman, Cygnus Support.
|
||||
Converted to back-end form by Ian Lance Taylor, Cygnus SUpport
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file can only be compiled on systems which use HP/UX style
|
||||
core files. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#if defined (HOST_HPPAHPUX) || defined (HOST_HP300HPUX)
|
||||
|
||||
/* FIXME: sys/core.h doesn't exist for HPUX version 7. HPUX version
|
||||
5, 6, and 7 core files seem to be standard trad-core.c type core
|
||||
files; can we just use trad-core.c in addition to this file? */
|
||||
|
||||
#include <sys/core.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#endif /* HOST_HPPAHPUX */
|
||||
|
||||
#ifdef HOST_HPPABSD
|
||||
|
||||
/* Not a very swift place to put it, but that's where the BSD port
|
||||
puts them. */
|
||||
#include "/hpux/usr/include/sys/core.h"
|
||||
|
||||
#endif /* HOST_HPPABSD */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/dir.h>
|
||||
#include <signal.h>
|
||||
#include <machine/reg.h>
|
||||
#include <sys/user.h> /* After a.out.h */
|
||||
#include <sys/file.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
|
||||
struct hpux_core_struct
|
||||
{
|
||||
int sig;
|
||||
char cmd[MAXCOMLEN + 1];
|
||||
};
|
||||
|
||||
#define core_hdr(bfd) ((bfd)->tdata.hpux_core_data)
|
||||
#define core_signal(bfd) (core_hdr(bfd)->sig)
|
||||
#define core_command(bfd) (core_hdr(bfd)->cmd)
|
||||
|
||||
static asection *
|
||||
make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
|
||||
bfd *abfd;
|
||||
CONST char *name;
|
||||
flagword flags;
|
||||
bfd_size_type _raw_size;
|
||||
bfd_vma vma;
|
||||
unsigned int alignment_power;
|
||||
{
|
||||
asection *asect;
|
||||
|
||||
asect = bfd_make_section_anyway (abfd, name);
|
||||
if (!asect)
|
||||
return NULL;
|
||||
|
||||
asect->flags = flags;
|
||||
asect->_raw_size = _raw_size;
|
||||
asect->vma = vma;
|
||||
asect->filepos = bfd_tell (abfd);
|
||||
asect->alignment_power = alignment_power;
|
||||
|
||||
return asect;
|
||||
}
|
||||
|
||||
static asymbol *
|
||||
hpux_core_make_empty_symbol (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
|
||||
if (new)
|
||||
new->the_bfd = abfd;
|
||||
return new;
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
hpux_core_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
core_hdr (abfd) = (struct hpux_core_struct *)
|
||||
bfd_zalloc (abfd, sizeof (struct hpux_core_struct));
|
||||
if (!core_hdr (abfd))
|
||||
return NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int val;
|
||||
struct corehead core_header;
|
||||
|
||||
val = bfd_read ((void *) &core_header, 1, sizeof core_header, abfd);
|
||||
if (val <= 0)
|
||||
break;
|
||||
switch (core_header.type)
|
||||
{
|
||||
case CORE_KERNEL:
|
||||
case CORE_FORMAT:
|
||||
bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */
|
||||
break;
|
||||
case CORE_EXEC:
|
||||
{
|
||||
struct proc_exec proc_exec;
|
||||
if (bfd_read ((void *) &proc_exec, 1, core_header.len, abfd)
|
||||
!= core_header.len)
|
||||
break;
|
||||
strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
|
||||
}
|
||||
break;
|
||||
case CORE_PROC:
|
||||
{
|
||||
struct proc_info proc_info;
|
||||
if (!make_bfd_asection (abfd, ".reg",
|
||||
SEC_HAS_CONTENTS,
|
||||
core_header.len,
|
||||
(int) &proc_info - (int) & proc_info.hw_regs,
|
||||
2))
|
||||
return NULL;
|
||||
|
||||
if (bfd_read (&proc_info, 1, core_header.len, abfd)
|
||||
!= core_header.len)
|
||||
break;
|
||||
core_signal (abfd) = proc_info.sig;
|
||||
}
|
||||
break;
|
||||
|
||||
case CORE_DATA:
|
||||
case CORE_STACK:
|
||||
case CORE_TEXT:
|
||||
case CORE_MMF:
|
||||
case CORE_SHM:
|
||||
if (!make_bfd_asection (abfd, ".data",
|
||||
SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
|
||||
core_header.len, core_header.addr, 2))
|
||||
return NULL;
|
||||
|
||||
bfd_seek (abfd, core_header.len, SEEK_CUR);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Falling into here is an error and should prevent this
|
||||
target from matching. That way systems which use hpux
|
||||
cores along with other formats can still work. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* OK, we believe you. You're a core file (sure, sure). */
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
hpux_core_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_command (abfd);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
hpux_core_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_signal (abfd);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static boolean
|
||||
hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd, *exec_bfd;
|
||||
{
|
||||
return true; /* FIXME, We have no way of telling at this point */
|
||||
}
|
||||
|
||||
#define hpux_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
|
||||
#define hpux_core_get_symtab _bfd_nosymbols_get_symtab
|
||||
#define hpux_core_print_symbol _bfd_nosymbols_print_symbol
|
||||
#define hpux_core_get_symbol_info _bfd_nosymbols_get_symbol_info
|
||||
#define hpux_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
|
||||
#define hpux_core_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define hpux_core_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define hpux_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define hpux_core_read_minisymbols _bfd_nosymbols_read_minisymbols
|
||||
#define hpux_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
void
|
||||
swap_abort()
|
||||
{
|
||||
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
|
||||
}
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET \
|
||||
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
|
||||
|
||||
const bfd_target hpux_core_vec =
|
||||
{
|
||||
"hpux-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
hpux_core_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (hpux_core),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (hpux_core),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
@ -1,80 +0,0 @@
|
||||
/* BFD back-end for i386 a.out binaries under dynix.
|
||||
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This BFD is currently only tested with gdb, writing object files
|
||||
may not work. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
|
||||
#define TEXT_START_ADDR 4096
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
|
||||
#include "aout/dynix3.h"
|
||||
|
||||
#define DEFAULT_ARCH bfd_arch_i386
|
||||
#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
|
||||
|
||||
#define MY(OP) CAT(i386dynix_,OP)
|
||||
#define TARGETNAME "a.out-i386-dynix"
|
||||
#define NAME(x,y) CAT3(i386dynix,_32_,y)
|
||||
#define ARCH_SIZE 32
|
||||
#define NAME_swap_exec_header_in NAME(i386dynix_32_,swap_exec_header_in)
|
||||
#define MY_get_section_contents aout_32_get_section_contents
|
||||
|
||||
/* aoutx.h requires definitions for NMAGIC, BMAGIC and QMAGIC. */
|
||||
#define NMAGIC 0
|
||||
#define BMAGIC OMAGIC
|
||||
#define QMAGIC XMAGIC
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
/* (Ab)use some fields in the internal exec header to be able to read
|
||||
executables that contain shared data. */
|
||||
|
||||
#define a_shdata a_tload
|
||||
#define a_shdrsize a_dload
|
||||
|
||||
void
|
||||
i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp)
|
||||
bfd *abfd;
|
||||
struct external_exec *raw_bytes;
|
||||
struct internal_exec *execp;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||
|
||||
/* The internal_exec structure has some fields that are unused in this
|
||||
configuration (IE for i960), so ensure that all such uninitialized
|
||||
fields are zero'd out. There are places where two of these structs
|
||||
are memcmp'd, and thus the contents do matter. */
|
||||
memset ((PTR) execp, 0, sizeof (struct internal_exec));
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
|
||||
execp->a_text = GET_WORD (abfd, bytes->e_text);
|
||||
execp->a_data = GET_WORD (abfd, bytes->e_data);
|
||||
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
|
||||
execp->a_syms = GET_WORD (abfd, bytes->e_syms);
|
||||
execp->a_entry = GET_WORD (abfd, bytes->e_entry);
|
||||
execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
|
||||
execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
|
||||
execp->a_shdata = GET_WORD (abfd, bytes->e_shdata);
|
||||
execp->a_shdrsize = GET_WORD (abfd, bytes->e_shdrsize);
|
||||
}
|
||||
|
||||
#include "aout-target.h"
|
@ -1,762 +0,0 @@
|
||||
/* BFD back-end for linux flavored i386 a.out binaries.
|
||||
Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define ZMAGIC_DISK_BLOCK_SIZE 1024
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define TEXT_START_ADDR 0x0
|
||||
#define N_SHARED_LIB(x) 0
|
||||
#define BYTES_IN_WORD 4
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
#define DEFAULT_ARCH bfd_arch_i386
|
||||
#define MY(OP) CAT(i386linux_,OP)
|
||||
#define TARGETNAME "a.out-i386-linux"
|
||||
|
||||
extern const bfd_target MY(vec);
|
||||
|
||||
/* We always generate QMAGIC files in preference to ZMAGIC files. It
|
||||
would be possible to make this a linker option, if that ever
|
||||
becomes important. */
|
||||
|
||||
static void MY_final_link_callback
|
||||
PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
|
||||
|
||||
static boolean
|
||||
i386linux_bfd_final_link (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
obj_aout_subformat (abfd) = q_magic_format;
|
||||
return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
|
||||
}
|
||||
|
||||
#define MY_bfd_final_link i386linux_bfd_final_link
|
||||
|
||||
/* Set the machine type correctly. */
|
||||
|
||||
static boolean
|
||||
i386linux_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
N_SET_MACHTYPE (*execp, M_386);
|
||||
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
|
||||
WRITE_HEADERS(abfd, execp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MY_write_object_contents i386linux_write_object_contents
|
||||
|
||||
/* Code to link against Linux a.out shared libraries. */
|
||||
|
||||
/* See if a symbol name is a reference to the global offset table. */
|
||||
|
||||
#ifndef GOT_REF_PREFIX
|
||||
#define GOT_REF_PREFIX "__GOT_"
|
||||
#endif
|
||||
|
||||
#define IS_GOT_SYM(name) \
|
||||
(strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
|
||||
|
||||
/* See if a symbol name is a reference to the procedure linkage table. */
|
||||
|
||||
#ifndef PLT_REF_PREFIX
|
||||
#define PLT_REF_PREFIX "__PLT_"
|
||||
#endif
|
||||
|
||||
#define IS_PLT_SYM(name) \
|
||||
(strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
|
||||
|
||||
/* This string is used to generate specialized error messages. */
|
||||
|
||||
#ifndef NEEDS_SHRLIB
|
||||
#define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
|
||||
#endif
|
||||
|
||||
/* This special symbol is a set vector that contains a list of
|
||||
pointers to fixup tables. It will be present in any dynamicly
|
||||
linked file. The linker generated fixup table should also be added
|
||||
to the list, and it should always appear in the second slot (the
|
||||
first one is a dummy with a magic number that is defined in
|
||||
crt0.o). */
|
||||
|
||||
#ifndef SHARABLE_CONFLICTS
|
||||
#define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
|
||||
#endif
|
||||
|
||||
/* We keep a list of fixups. The terminology is a bit strange, but
|
||||
each fixup contains two 32 bit numbers. A regular fixup contains
|
||||
an address and a pointer, and at runtime we should store the
|
||||
address at the location pointed to by the pointer. A builtin fixup
|
||||
contains two pointers, and we should read the address using one
|
||||
pointer and store it at the location pointed to by the other
|
||||
pointer. Builtin fixups come into play when we have duplicate
|
||||
__GOT__ symbols for the same variable. The builtin fixup will copy
|
||||
the GOT pointer from one over into the other. */
|
||||
|
||||
struct fixup
|
||||
{
|
||||
struct fixup *next;
|
||||
struct linux_link_hash_entry *h;
|
||||
bfd_vma value;
|
||||
|
||||
/* Nonzero if this is a jump instruction that needs to be fixed,
|
||||
zero if this is just a pointer */
|
||||
char jump;
|
||||
|
||||
char builtin;
|
||||
};
|
||||
|
||||
/* We don't need a special hash table entry structure, but we do need
|
||||
to keep some information between linker passes, so we use a special
|
||||
hash table. */
|
||||
|
||||
struct linux_link_hash_entry
|
||||
{
|
||||
struct aout_link_hash_entry root;
|
||||
};
|
||||
|
||||
struct linux_link_hash_table
|
||||
{
|
||||
struct aout_link_hash_table root;
|
||||
|
||||
/* First dynamic object found in link. */
|
||||
bfd *dynobj;
|
||||
|
||||
/* Number of fixups. */
|
||||
size_t fixup_count;
|
||||
|
||||
/* Number of builtin fixups. */
|
||||
size_t local_builtins;
|
||||
|
||||
/* List of fixups. */
|
||||
struct fixup *fixup_list;
|
||||
};
|
||||
|
||||
static struct bfd_hash_entry *linux_link_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
||||
static struct bfd_link_hash_table *linux_link_hash_table_create
|
||||
PARAMS ((bfd *));
|
||||
static struct fixup *new_fixup
|
||||
PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
|
||||
bfd_vma, int));
|
||||
static boolean linux_link_create_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean linux_add_one_symbol
|
||||
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
|
||||
bfd_vma, const char *, boolean, boolean,
|
||||
struct bfd_link_hash_entry **));
|
||||
static boolean linux_tally_symbols
|
||||
PARAMS ((struct linux_link_hash_entry *, PTR));
|
||||
static boolean linux_finish_dynamic_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
/* Routine to create an entry in an Linux link hash table. */
|
||||
|
||||
static struct bfd_hash_entry *
|
||||
linux_link_hash_newfunc (entry, table, string)
|
||||
struct bfd_hash_entry *entry;
|
||||
struct bfd_hash_table *table;
|
||||
const char *string;
|
||||
{
|
||||
struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
|
||||
|
||||
/* Allocate the structure if it has not already been allocated by a
|
||||
subclass. */
|
||||
if (ret == (struct linux_link_hash_entry *) NULL)
|
||||
ret = ((struct linux_link_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
|
||||
if (ret == NULL)
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct linux_link_hash_entry *)
|
||||
NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
|
||||
table, string));
|
||||
if (ret != NULL)
|
||||
{
|
||||
/* Set local fields; there aren't any. */
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
|
||||
/* Create a Linux link hash table. */
|
||||
|
||||
static struct bfd_link_hash_table *
|
||||
linux_link_hash_table_create (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct linux_link_hash_table *ret;
|
||||
|
||||
ret = ((struct linux_link_hash_table *)
|
||||
bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
|
||||
if (ret == (struct linux_link_hash_table *) NULL)
|
||||
return (struct bfd_link_hash_table *) NULL;
|
||||
if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
|
||||
linux_link_hash_newfunc))
|
||||
{
|
||||
free (ret);
|
||||
return (struct bfd_link_hash_table *) NULL;
|
||||
}
|
||||
|
||||
ret->dynobj = NULL;
|
||||
ret->fixup_count = 0;
|
||||
ret->local_builtins = 0;
|
||||
ret->fixup_list = NULL;
|
||||
|
||||
return &ret->root.root;
|
||||
}
|
||||
|
||||
/* Look up an entry in a Linux link hash table. */
|
||||
|
||||
#define linux_link_hash_lookup(table, string, create, copy, follow) \
|
||||
((struct linux_link_hash_entry *) \
|
||||
aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
|
||||
(follow)))
|
||||
|
||||
/* Traverse a Linux link hash table. */
|
||||
|
||||
#define linux_link_hash_traverse(table, func, info) \
|
||||
(aout_link_hash_traverse \
|
||||
(&(table)->root, \
|
||||
(boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
|
||||
(info)))
|
||||
|
||||
/* Get the Linux link hash table from the info structure. This is
|
||||
just a cast. */
|
||||
|
||||
#define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
|
||||
|
||||
/* Store the information for a new fixup. */
|
||||
|
||||
static struct fixup *
|
||||
new_fixup (info, h, value, builtin)
|
||||
struct bfd_link_info *info;
|
||||
struct linux_link_hash_entry *h;
|
||||
bfd_vma value;
|
||||
int builtin;
|
||||
{
|
||||
struct fixup *f;
|
||||
|
||||
f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
|
||||
sizeof (struct fixup));
|
||||
if (f == NULL)
|
||||
return f;
|
||||
f->next = linux_hash_table (info)->fixup_list;
|
||||
linux_hash_table (info)->fixup_list = f;
|
||||
f->h = h;
|
||||
f->value = value;
|
||||
f->builtin = builtin;
|
||||
f->jump = 0;
|
||||
++linux_hash_table (info)->fixup_count;
|
||||
return f;
|
||||
}
|
||||
|
||||
/* We come here once we realize that we are going to link to a shared
|
||||
library. We need to create a special section that contains the
|
||||
fixup table, and we ultimately need to add a pointer to this into
|
||||
the set vector for SHARABLE_CONFLICTS. At this point we do not
|
||||
know the size of the section, but that's OK - we just need to
|
||||
create it for now. */
|
||||
|
||||
static boolean
|
||||
linux_link_create_dynamic_sections (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
|
||||
/* Note that we set the SEC_IN_MEMORY flag. */
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
/* We choose to use the name ".linux-dynamic" for the fixup table.
|
||||
Why not? */
|
||||
s = bfd_make_section (abfd, ".linux-dynamic");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
s->_raw_size = 0;
|
||||
s->contents = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Function to add a single symbol to the linker hash table. This is
|
||||
a wrapper around _bfd_generic_link_add_one_symbol which handles the
|
||||
tweaking needed for dynamic linking support. */
|
||||
|
||||
static boolean
|
||||
linux_add_one_symbol (info, abfd, name, flags, section, value, string,
|
||||
copy, collect, hashp)
|
||||
struct bfd_link_info *info;
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
flagword flags;
|
||||
asection *section;
|
||||
bfd_vma value;
|
||||
const char *string;
|
||||
boolean copy;
|
||||
boolean collect;
|
||||
struct bfd_link_hash_entry **hashp;
|
||||
{
|
||||
struct linux_link_hash_entry *h;
|
||||
boolean insert;
|
||||
|
||||
/* Look up and see if we already have this symbol in the hash table.
|
||||
If we do, and the defining entry is from a shared library, we
|
||||
need to create the dynamic sections.
|
||||
|
||||
FIXME: What if abfd->xvec != info->hash->creator? We may want to
|
||||
be able to link Linux a.out and ELF objects together, but serious
|
||||
confusion is possible. */
|
||||
|
||||
insert = false;
|
||||
|
||||
if (! info->relocateable
|
||||
&& linux_hash_table (info)->dynobj == NULL
|
||||
&& strcmp (name, SHARABLE_CONFLICTS) == 0
|
||||
&& (flags & BSF_CONSTRUCTOR) != 0
|
||||
&& abfd->xvec == info->hash->creator)
|
||||
{
|
||||
if (! linux_link_create_dynamic_sections (abfd, info))
|
||||
return false;
|
||||
linux_hash_table (info)->dynobj = abfd;
|
||||
insert = true;
|
||||
}
|
||||
|
||||
if (bfd_is_abs_section (section)
|
||||
&& abfd->xvec == info->hash->creator)
|
||||
{
|
||||
h = linux_link_hash_lookup (linux_hash_table (info), name, false,
|
||||
false, false);
|
||||
if (h != NULL
|
||||
&& (h->root.root.type == bfd_link_hash_defined
|
||||
|| h->root.root.type == bfd_link_hash_defweak))
|
||||
{
|
||||
struct fixup *f;
|
||||
|
||||
if (hashp != NULL)
|
||||
*hashp = (struct bfd_link_hash_entry *) h;
|
||||
|
||||
f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
|
||||
if (f == NULL)
|
||||
return false;
|
||||
f->jump = IS_PLT_SYM (name);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do the usual procedure for adding a symbol. */
|
||||
if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
|
||||
value, string, copy, collect,
|
||||
hashp))
|
||||
return false;
|
||||
|
||||
/* Insert a pointer to our table in the set vector. The dynamic
|
||||
linker requires this information */
|
||||
if (insert)
|
||||
{
|
||||
asection *s;
|
||||
|
||||
/* Here we do our special thing to add the pointer to the
|
||||
dynamic section in the SHARABLE_CONFLICTS set vector. */
|
||||
s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
|
||||
".linux-dynamic");
|
||||
BFD_ASSERT (s != NULL);
|
||||
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
|
||||
BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We will crawl the hash table and come here for every global symbol.
|
||||
We will examine each entry and see if there are indications that we
|
||||
need to add a fixup. There are two possible cases - one is where
|
||||
you have duplicate definitions of PLT or GOT symbols - these will
|
||||
have already been caught and added as "builtin" fixups. If we find
|
||||
that the corresponding non PLT/GOT symbol is also present, we
|
||||
convert it to a regular fixup instead.
|
||||
|
||||
This function is called via linux_link_hash_traverse. */
|
||||
|
||||
static boolean
|
||||
linux_tally_symbols (h, data)
|
||||
struct linux_link_hash_entry *h;
|
||||
PTR data;
|
||||
{
|
||||
struct bfd_link_info *info = (struct bfd_link_info *) data;
|
||||
struct fixup *f, *f1;
|
||||
int is_plt;
|
||||
struct linux_link_hash_entry *h1, *h2;
|
||||
boolean exists;
|
||||
|
||||
if (h->root.root.type == bfd_link_hash_undefined
|
||||
&& strncmp (h->root.root.root.string, NEEDS_SHRLIB,
|
||||
sizeof NEEDS_SHRLIB - 1) == 0)
|
||||
{
|
||||
const char *name;
|
||||
char *p;
|
||||
char *alloc = NULL;
|
||||
|
||||
name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
|
||||
p = strrchr (name, '_');
|
||||
if (p != NULL)
|
||||
alloc = (char *) bfd_malloc (strlen (name) + 1);
|
||||
|
||||
if (p == NULL || alloc == NULL)
|
||||
(*_bfd_error_handler) ("Output file requires shared library `%s'\n",
|
||||
name);
|
||||
else
|
||||
{
|
||||
strcpy (alloc, name);
|
||||
p = strrchr (alloc, '_');
|
||||
*p++ = '\0';
|
||||
(*_bfd_error_handler)
|
||||
("Output file requires shared library `%s.so.%s'\n",
|
||||
alloc, p);
|
||||
free (alloc);
|
||||
}
|
||||
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* If this symbol is not a PLT/GOT, we do not even need to look at it */
|
||||
is_plt = IS_PLT_SYM (h->root.root.root.string);
|
||||
|
||||
if (is_plt || IS_GOT_SYM (h->root.root.root.string))
|
||||
{
|
||||
/* Look up this symbol twice. Once just as a regular lookup,
|
||||
and then again following all of the indirect links until we
|
||||
reach a real symbol. */
|
||||
h1 = linux_link_hash_lookup (linux_hash_table (info),
|
||||
(h->root.root.root.string
|
||||
+ sizeof PLT_REF_PREFIX - 1),
|
||||
false, false, true);
|
||||
/* h2 does not follow indirect symbols. */
|
||||
h2 = linux_link_hash_lookup (linux_hash_table (info),
|
||||
(h->root.root.root.string
|
||||
+ sizeof PLT_REF_PREFIX - 1),
|
||||
false, false, false);
|
||||
|
||||
/* The real symbol must exist but if it is also an ABS symbol,
|
||||
there is no need to have a fixup. This is because they both
|
||||
came from the same library. If on the other hand, we had to
|
||||
use an indirect symbol to get to the real symbol, we add the
|
||||
fixup anyway, since there are cases where these symbols come
|
||||
from different shared libraries */
|
||||
if (h1 != NULL
|
||||
&& (((h1->root.root.type == bfd_link_hash_defined
|
||||
|| h1->root.root.type == bfd_link_hash_defweak)
|
||||
&& ! bfd_is_abs_section (h1->root.root.u.def.section))
|
||||
|| h2->root.root.type == bfd_link_hash_indirect))
|
||||
{
|
||||
/* See if there is a "builtin" fixup already present
|
||||
involving this symbol. If so, convert it to a regular
|
||||
fixup. In the end, this relaxes some of the requirements
|
||||
about the order of performing fixups. */
|
||||
exists = false;
|
||||
for (f1 = linux_hash_table (info)->fixup_list;
|
||||
f1 != NULL;
|
||||
f1 = f1->next)
|
||||
{
|
||||
if ((f1->h != h && f1->h != h1)
|
||||
|| (! f1->builtin && ! f1->jump))
|
||||
continue;
|
||||
if (f1->h == h1)
|
||||
exists = true;
|
||||
if (! exists
|
||||
&& bfd_is_abs_section (h->root.root.u.def.section))
|
||||
{
|
||||
f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
|
||||
f->jump = is_plt;
|
||||
}
|
||||
f1->h = h1;
|
||||
f1->jump = is_plt;
|
||||
f1->builtin = 0;
|
||||
exists = true;
|
||||
}
|
||||
if (! exists
|
||||
&& bfd_is_abs_section (h->root.root.u.def.section))
|
||||
{
|
||||
f = new_fixup (info, h1, h->root.root.u.def.value, 0);
|
||||
if (f == NULL)
|
||||
{
|
||||
/* FIXME: No way to return error. */
|
||||
abort ();
|
||||
}
|
||||
f->jump = is_plt;
|
||||
}
|
||||
}
|
||||
|
||||
/* Quick and dirty way of stripping these symbols from the
|
||||
symtab. */
|
||||
if (bfd_is_abs_section (h->root.root.u.def.section))
|
||||
h->root.written = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This is called to set the size of the .linux-dynamic section is.
|
||||
It is called by the Linux linker emulation before_allocation
|
||||
routine. We have finished reading all of the input files, and now
|
||||
we just scan the hash tables to find out how many additional fixups
|
||||
are required. */
|
||||
|
||||
boolean
|
||||
bfd_i386linux_size_dynamic_sections (output_bfd, info)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
struct fixup *f;
|
||||
asection *s;
|
||||
|
||||
if (output_bfd->xvec != &MY(vec))
|
||||
return true;
|
||||
|
||||
/* First find the fixups... */
|
||||
linux_link_hash_traverse (linux_hash_table (info),
|
||||
linux_tally_symbols,
|
||||
(PTR) info);
|
||||
|
||||
/* If there are builtin fixups, leave room for a marker. This is
|
||||
used by the dynamic linker so that it knows that all that follow
|
||||
are builtin fixups instead of regular fixups. */
|
||||
for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
|
||||
{
|
||||
if (f->builtin)
|
||||
{
|
||||
++linux_hash_table (info)->fixup_count;
|
||||
++linux_hash_table (info)->local_builtins;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (linux_hash_table (info)->dynobj == NULL)
|
||||
{
|
||||
if (linux_hash_table (info)->fixup_count > 0)
|
||||
abort ();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Allocate memory for our fixup table. We will fill it in later. */
|
||||
s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
|
||||
".linux-dynamic");
|
||||
if (s != NULL)
|
||||
{
|
||||
s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
|
||||
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
|
||||
if (s->contents == NULL)
|
||||
return false;
|
||||
memset (s->contents, 0, (size_t) s->_raw_size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We come here once we are ready to actually write the fixup table to
|
||||
the output file. Scan the fixup tables and so forth and generate
|
||||
the stuff we need. */
|
||||
|
||||
static boolean
|
||||
linux_finish_dynamic_link (output_bfd, info)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
asection *s, *os, *is;
|
||||
bfd_byte *fixup_table;
|
||||
struct linux_link_hash_entry *h;
|
||||
struct fixup *f;
|
||||
unsigned int new_addr;
|
||||
int section_offset;
|
||||
unsigned int fixups_written;
|
||||
|
||||
if (linux_hash_table (info)->dynobj == NULL)
|
||||
return true;
|
||||
|
||||
s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
|
||||
".linux-dynamic");
|
||||
BFD_ASSERT (s != NULL);
|
||||
os = s->output_section;
|
||||
fixups_written = 0;
|
||||
|
||||
#ifdef LINUX_LINK_DEBUG
|
||||
printf ("Fixup table file offset: %x VMA: %x\n",
|
||||
os->filepos + s->output_offset,
|
||||
os->vma + s->output_offset);
|
||||
#endif
|
||||
|
||||
fixup_table = s->contents;
|
||||
bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
|
||||
fixup_table += 4;
|
||||
|
||||
/* Fill in fixup table. */
|
||||
for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
|
||||
{
|
||||
if (f->builtin)
|
||||
continue;
|
||||
|
||||
if (f->h->root.root.type != bfd_link_hash_defined
|
||||
&& f->h->root.root.type != bfd_link_hash_defweak)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
("Symbol %s not defined for fixups\n",
|
||||
f->h->root.root.root.string);
|
||||
continue;
|
||||
}
|
||||
|
||||
is = f->h->root.root.u.def.section;
|
||||
section_offset = is->output_section->vma + is->output_offset;
|
||||
new_addr = f->h->root.root.u.def.value + section_offset;
|
||||
|
||||
#ifdef LINUX_LINK_DEBUG
|
||||
printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
|
||||
new_addr, f->value);
|
||||
#endif
|
||||
|
||||
if (f->jump)
|
||||
{
|
||||
/* Relative address */
|
||||
new_addr = new_addr - (f->value + 5);
|
||||
bfd_put_32 (output_bfd, new_addr, fixup_table);
|
||||
fixup_table += 4;
|
||||
bfd_put_32 (output_bfd, f->value + 1, fixup_table);
|
||||
fixup_table += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_put_32 (output_bfd, new_addr, fixup_table);
|
||||
fixup_table += 4;
|
||||
bfd_put_32 (output_bfd, f->value, fixup_table);
|
||||
fixup_table += 4;
|
||||
}
|
||||
++fixups_written;
|
||||
}
|
||||
|
||||
if (linux_hash_table (info)->local_builtins != 0)
|
||||
{
|
||||
/* Special marker so we know to switch to the other type of fixup */
|
||||
bfd_put_32 (output_bfd, 0, fixup_table);
|
||||
fixup_table += 4;
|
||||
bfd_put_32 (output_bfd, 0, fixup_table);
|
||||
fixup_table += 4;
|
||||
++fixups_written;
|
||||
for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
|
||||
{
|
||||
if (! f->builtin)
|
||||
continue;
|
||||
|
||||
if (f->h->root.root.type != bfd_link_hash_defined
|
||||
&& f->h->root.root.type != bfd_link_hash_defweak)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
("Symbol %s not defined for fixups\n",
|
||||
f->h->root.root.root.string);
|
||||
continue;
|
||||
}
|
||||
|
||||
is = f->h->root.root.u.def.section;
|
||||
section_offset = is->output_section->vma + is->output_offset;
|
||||
new_addr = f->h->root.root.u.def.value + section_offset;
|
||||
|
||||
#ifdef LINUX_LINK_DEBUG
|
||||
printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
|
||||
new_addr, f->value);
|
||||
#endif
|
||||
|
||||
bfd_put_32 (output_bfd, new_addr, fixup_table);
|
||||
fixup_table += 4;
|
||||
bfd_put_32 (output_bfd, f->value, fixup_table);
|
||||
fixup_table += 4;
|
||||
++fixups_written;
|
||||
}
|
||||
}
|
||||
|
||||
if (linux_hash_table (info)->fixup_count != fixups_written)
|
||||
{
|
||||
(*_bfd_error_handler) ("Warning: fixup count mismatch\n");
|
||||
while (linux_hash_table (info)->fixup_count > fixups_written)
|
||||
{
|
||||
bfd_put_32 (output_bfd, 0, fixup_table);
|
||||
fixup_table += 4;
|
||||
bfd_put_32 (output_bfd, 0, fixup_table);
|
||||
fixup_table += 4;
|
||||
++fixups_written;
|
||||
}
|
||||
}
|
||||
|
||||
h = linux_link_hash_lookup (linux_hash_table (info),
|
||||
"__BUILTIN_FIXUPS__",
|
||||
false, false, false);
|
||||
|
||||
if (h != NULL
|
||||
&& (h->root.root.type == bfd_link_hash_defined
|
||||
|| h->root.root.type == bfd_link_hash_defweak))
|
||||
{
|
||||
is = h->root.root.u.def.section;
|
||||
section_offset = is->output_section->vma + is->output_offset;
|
||||
new_addr = h->root.root.u.def.value + section_offset;
|
||||
|
||||
#ifdef LINUX_LINK_DEBUG
|
||||
printf ("Builtin fixup table at %x\n", new_addr);
|
||||
#endif
|
||||
|
||||
bfd_put_32 (output_bfd, new_addr, fixup_table);
|
||||
}
|
||||
else
|
||||
bfd_put_32 (output_bfd, 0, fixup_table);
|
||||
|
||||
if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
|
||||
!= s->_raw_size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MY_bfd_link_hash_table_create linux_link_hash_table_create
|
||||
#define MY_add_one_symbol linux_add_one_symbol
|
||||
#define MY_finish_dynamic_link linux_finish_dynamic_link
|
||||
|
||||
#define MY_zmagic_contiguous 1
|
||||
|
||||
#include "aout-target.h"
|
@ -1,563 +0,0 @@
|
||||
/* BFD back-end for i386 a.out binaries under LynxOS.
|
||||
Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
#define N_SHARED_LIB(x) 0
|
||||
|
||||
#define TEXT_START_ADDR 0
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define DEFAULT_ARCH bfd_arch_i386
|
||||
|
||||
#define MY(OP) CAT(i386lynx_aout_,OP)
|
||||
#define TARGETNAME "a.out-i386-lynx"
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#ifndef WRITE_HEADERS
|
||||
#define WRITE_HEADERS(abfd, execp) \
|
||||
{ \
|
||||
bfd_size_type text_size; /* dummy vars */ \
|
||||
file_ptr text_end; \
|
||||
if (adata(abfd).magic == undecided_magic) \
|
||||
NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
|
||||
\
|
||||
execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
|
||||
execp->a_entry = bfd_get_start_address (abfd); \
|
||||
\
|
||||
execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
|
||||
obj_reloc_entry_size (abfd)); \
|
||||
execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
|
||||
obj_reloc_entry_size (abfd)); \
|
||||
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
|
||||
\
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
|
||||
if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
|
||||
!= EXEC_BYTES_SIZE) \
|
||||
return false; \
|
||||
/* Now write out reloc info, followed by syms and strings */ \
|
||||
\
|
||||
if (bfd_get_symcount (abfd) != 0) \
|
||||
{ \
|
||||
if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
|
||||
!= 0) \
|
||||
return false; \
|
||||
\
|
||||
if (! NAME(aout,write_syms)(abfd)) return false; \
|
||||
\
|
||||
if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
|
||||
!= 0) \
|
||||
return false; \
|
||||
\
|
||||
if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
|
||||
return false; \
|
||||
if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
|
||||
!= 0) \
|
||||
return 0; \
|
||||
\
|
||||
if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
|
||||
return false; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "libaout.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
#ifdef LYNX_CORE
|
||||
|
||||
char *lynx_core_file_failing_command ();
|
||||
int lynx_core_file_failing_signal ();
|
||||
boolean lynx_core_file_matches_executable_p ();
|
||||
const bfd_target *lynx_core_file_p ();
|
||||
|
||||
#define MY_core_file_failing_command lynx_core_file_failing_command
|
||||
#define MY_core_file_failing_signal lynx_core_file_failing_signal
|
||||
#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
|
||||
#define MY_core_file_p lynx_core_file_p
|
||||
|
||||
#endif /* LYNX_CORE */
|
||||
|
||||
|
||||
#define KEEPIT flags
|
||||
|
||||
extern reloc_howto_type aout_32_ext_howto_table[];
|
||||
extern reloc_howto_type aout_32_std_howto_table[];
|
||||
|
||||
/* Standard reloc stuff */
|
||||
/* Output standard relocation information to a file in target byte order. */
|
||||
|
||||
void
|
||||
NAME(lynx,swap_std_reloc_out) (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_baserel, r_jmptable, r_relative;
|
||||
unsigned int r_addend;
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD (abfd, g->address, natptr->r_address);
|
||||
|
||||
r_length = g->howto->size; /* Size as a power of two */
|
||||
r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
|
||||
/* r_baserel, r_jmptable, r_relative??? FIXME-soon */
|
||||
r_baserel = 0;
|
||||
r_jmptable = 0;
|
||||
r_relative = 0;
|
||||
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
/* name was clobbered by aout_write_syms to be symbol index */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here
|
||||
*/
|
||||
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| bfd_is_abs_section (output_section)
|
||||
|| bfd_is_und_section (output_section))
|
||||
{
|
||||
if (bfd_abs_section_ptr->symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol */
|
||||
r_extern = 1;
|
||||
r_index = stoi ((*(g->sym_ptr_ptr))->KEEPIT);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
/* now the fun stuff */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
natptr->r_index[0] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[2] = r_index;
|
||||
natptr->r_type[0] =
|
||||
(r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
|
||||
| (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)
|
||||
| (r_jmptable ? RELOC_STD_BITS_JMPTABLE_BIG : 0)
|
||||
| (r_relative ? RELOC_STD_BITS_RELATIVE_BIG : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
(r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
|
||||
| (r_baserel ? RELOC_STD_BITS_BASEREL_LITTLE : 0)
|
||||
| (r_jmptable ? RELOC_STD_BITS_JMPTABLE_LITTLE : 0)
|
||||
| (r_relative ? RELOC_STD_BITS_RELATIVE_LITTLE : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Extended stuff */
|
||||
/* Output extended relocation information to a file in target byte order. */
|
||||
|
||||
void
|
||||
NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
register struct reloc_ext_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_type;
|
||||
unsigned int r_addend;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD (abfd, g->address, natptr->r_address);
|
||||
|
||||
r_type = (unsigned int) g->howto->type;
|
||||
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here
|
||||
*/
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| bfd_is_abs_section (output_section)
|
||||
|| bfd_is_und_section (output_section))
|
||||
{
|
||||
if (bfd_abs_section_ptr->symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_extern = 1;
|
||||
r_index = stoi ((*(g->sym_ptr_ptr))->KEEPIT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
|
||||
/* now the fun stuff */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
natptr->r_index[0] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[2] = r_index;
|
||||
natptr->r_type[0] =
|
||||
(r_extern ? RELOC_EXT_BITS_EXTERN_BIG : 0)
|
||||
| (r_type << RELOC_EXT_BITS_TYPE_SH_BIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
(r_extern ? RELOC_EXT_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
|
||||
}
|
||||
|
||||
PUT_WORD (abfd, r_addend, natptr->r_addend);
|
||||
}
|
||||
|
||||
/* BFD deals internally with all things based from the section they're
|
||||
in. so, something in 10 bytes into a text section with a base of
|
||||
50 would have a symbol (.text+10) and know .text vma was 50.
|
||||
|
||||
Aout keeps all it's symbols based from zero, so the symbol would
|
||||
contain 60. This macro subs the base of each section from the value
|
||||
to give the true offset from the section */
|
||||
|
||||
|
||||
#define MOVE_ADDRESS(ad) \
|
||||
if (r_extern) { \
|
||||
/* undefined symbol */ \
|
||||
cache_ptr->sym_ptr_ptr = symbols + r_index; \
|
||||
cache_ptr->addend = ad; \
|
||||
} else { \
|
||||
/* defined, section relative. replace symbol with pointer to \
|
||||
symbol which points to section */ \
|
||||
switch (r_index) { \
|
||||
case N_TEXT: \
|
||||
case N_TEXT | N_EXT: \
|
||||
cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr; \
|
||||
cache_ptr->addend = ad - su->textsec->vma; \
|
||||
break; \
|
||||
case N_DATA: \
|
||||
case N_DATA | N_EXT: \
|
||||
cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr; \
|
||||
cache_ptr->addend = ad - su->datasec->vma; \
|
||||
break; \
|
||||
case N_BSS: \
|
||||
case N_BSS | N_EXT: \
|
||||
cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr; \
|
||||
cache_ptr->addend = ad - su->bsssec->vma; \
|
||||
break; \
|
||||
default: \
|
||||
case N_ABS: \
|
||||
case N_ABS | N_EXT: \
|
||||
cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; \
|
||||
cache_ptr->addend = ad; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
|
||||
void
|
||||
NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_ext_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_type;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
|
||||
|
||||
r_index = bytes->r_index[1];
|
||||
r_extern = (0 != (bytes->r_index[0] & RELOC_EXT_BITS_EXTERN_BIG));
|
||||
r_type = (bytes->r_index[0] & RELOC_EXT_BITS_TYPE_BIG)
|
||||
>> RELOC_EXT_BITS_TYPE_SH_BIG;
|
||||
|
||||
cache_ptr->howto = aout_32_ext_howto_table + r_type;
|
||||
MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
|
||||
}
|
||||
|
||||
void
|
||||
NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_baserel, r_jmptable, r_relative;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||
|
||||
r_index = bytes->r_index[1];
|
||||
r_extern = (0 != (bytes->r_index[0] & RELOC_STD_BITS_EXTERN_BIG));
|
||||
r_pcrel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_PCREL_BIG));
|
||||
r_baserel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_BASEREL_BIG));
|
||||
r_jmptable = (0 != (bytes->r_index[0] & RELOC_STD_BITS_JMPTABLE_BIG));
|
||||
r_relative = (0 != (bytes->r_index[0] & RELOC_STD_BITS_RELATIVE_BIG));
|
||||
r_length = (bytes->r_index[0] & RELOC_STD_BITS_LENGTH_BIG)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_BIG;
|
||||
|
||||
cache_ptr->howto = aout_32_std_howto_table + r_length + 4 * r_pcrel;
|
||||
/* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */
|
||||
|
||||
MOVE_ADDRESS (0);
|
||||
}
|
||||
|
||||
/* Reloc hackery */
|
||||
|
||||
boolean
|
||||
NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)
|
||||
bfd *abfd;
|
||||
sec_ptr asect;
|
||||
asymbol **symbols;
|
||||
{
|
||||
unsigned int count;
|
||||
bfd_size_type reloc_size;
|
||||
PTR relocs;
|
||||
arelent *reloc_cache;
|
||||
size_t each_size;
|
||||
|
||||
if (asect->relocation)
|
||||
return true;
|
||||
|
||||
if (asect->flags & SEC_CONSTRUCTOR)
|
||||
return true;
|
||||
|
||||
if (asect == obj_datasec (abfd))
|
||||
{
|
||||
reloc_size = exec_hdr (abfd)->a_drsize;
|
||||
goto doit;
|
||||
}
|
||||
|
||||
if (asect == obj_textsec (abfd))
|
||||
{
|
||||
reloc_size = exec_hdr (abfd)->a_trsize;
|
||||
goto doit;
|
||||
}
|
||||
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return false;
|
||||
|
||||
doit:
|
||||
if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
|
||||
return false;
|
||||
each_size = obj_reloc_entry_size (abfd);
|
||||
|
||||
count = reloc_size / each_size;
|
||||
|
||||
|
||||
reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
|
||||
if (!reloc_cache && count != 0)
|
||||
return false;
|
||||
memset (reloc_cache, 0, count * sizeof (arelent));
|
||||
|
||||
relocs = (PTR) bfd_alloc (abfd, reloc_size);
|
||||
if (!relocs && reloc_size != 0)
|
||||
{
|
||||
free (reloc_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
|
||||
{
|
||||
bfd_release (abfd, relocs);
|
||||
free (reloc_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (each_size == RELOC_EXT_SIZE)
|
||||
{
|
||||
register struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
|
||||
unsigned int counter = 0;
|
||||
arelent *cache_ptr = reloc_cache;
|
||||
|
||||
for (; counter < count; counter++, rptr++, cache_ptr++)
|
||||
{
|
||||
NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
|
||||
bfd_get_symcount (abfd));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
register struct reloc_std_external *rptr = (struct reloc_std_external *) relocs;
|
||||
unsigned int counter = 0;
|
||||
arelent *cache_ptr = reloc_cache;
|
||||
|
||||
for (; counter < count; counter++, rptr++, cache_ptr++)
|
||||
{
|
||||
NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
|
||||
bfd_get_symcount (abfd));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bfd_release (abfd, relocs);
|
||||
asect->relocation = reloc_cache;
|
||||
asect->reloc_count = count;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Write out a relocation section into an object file. */
|
||||
|
||||
boolean
|
||||
NAME(lynx,squirt_out_relocs) (abfd, section)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
arelent **generic;
|
||||
unsigned char *native, *natptr;
|
||||
size_t each_size;
|
||||
|
||||
unsigned int count = section->reloc_count;
|
||||
size_t natsize;
|
||||
|
||||
if (count == 0)
|
||||
return true;
|
||||
|
||||
each_size = obj_reloc_entry_size (abfd);
|
||||
natsize = each_size * count;
|
||||
native = (unsigned char *) bfd_zalloc (abfd, natsize);
|
||||
if (!native)
|
||||
return false;
|
||||
|
||||
generic = section->orelocation;
|
||||
|
||||
if (each_size == RELOC_EXT_SIZE)
|
||||
{
|
||||
for (natptr = native;
|
||||
count != 0;
|
||||
--count, natptr += each_size, ++generic)
|
||||
NAME(lynx,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *) natptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (natptr = native;
|
||||
count != 0;
|
||||
--count, natptr += each_size, ++generic)
|
||||
NAME(lynx,swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
|
||||
}
|
||||
|
||||
if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
|
||||
{
|
||||
bfd_release (abfd, native);
|
||||
return false;
|
||||
}
|
||||
bfd_release (abfd, native);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This is stupid. This function should be a boolean predicate */
|
||||
long
|
||||
NAME(lynx,canonicalize_reloc) (abfd, section, relptr, symbols)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
arelent **relptr;
|
||||
asymbol **symbols;
|
||||
{
|
||||
arelent *tblptr = section->relocation;
|
||||
unsigned int count;
|
||||
|
||||
if (!(tblptr || NAME(lynx,slurp_reloc_table) (abfd, section, symbols)))
|
||||
return -1;
|
||||
|
||||
if (section->flags & SEC_CONSTRUCTOR)
|
||||
{
|
||||
arelent_chain *chain = section->constructor_chain;
|
||||
for (count = 0; count < section->reloc_count; count++)
|
||||
{
|
||||
*relptr++ = &chain->relent;
|
||||
chain = chain->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tblptr = section->relocation;
|
||||
|
||||
for (count = 0; count++ < section->reloc_count;)
|
||||
{
|
||||
*relptr++ = tblptr++;
|
||||
}
|
||||
}
|
||||
*relptr = 0;
|
||||
|
||||
return section->reloc_count;
|
||||
}
|
||||
|
||||
#define MY_canonicalize_reloc NAME(lynx,canonicalize_reloc)
|
||||
|
||||
#include "aout-target.h"
|
@ -1,65 +0,0 @@
|
||||
/* BFD back-end for i386 a.out binaries.
|
||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This is for Mach 3, which uses a.out, not Mach-O. */
|
||||
|
||||
/* There is no magic number or anything which lets us distinguish this target
|
||||
from i386aout or i386bsd. So this target is only useful if it is the
|
||||
default target. */
|
||||
|
||||
#define TARGET_PAGE_SIZE 1
|
||||
#define SEGMENT_SIZE 0x1000
|
||||
#define TEXT_START_ADDR 0x10000
|
||||
#define ARCH 32
|
||||
#define BYTES_IN_WORD 4
|
||||
/* This macro is only relevant when N_MAGIC(x) == ZMAGIC. */
|
||||
#define N_HEADER_IN_TEXT(x) 1
|
||||
|
||||
#define N_TXTSIZE(x) ((x).a_text)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
#define DEFAULT_ARCH bfd_arch_i386
|
||||
#define MY(OP) CAT(i386mach3_,OP)
|
||||
#define TARGETNAME "a.out-mach3"
|
||||
|
||||
static boolean MY(set_sizes)();
|
||||
#define MY_backend_data &MY(backend_data)
|
||||
static CONST struct aout_backend_data MY(backend_data) = {
|
||||
0, /* zmagic contiguous */
|
||||
1, /* text incl header */
|
||||
0, /* exec_hdr_flags */
|
||||
0, /* text vma? */
|
||||
MY(set_sizes),
|
||||
1, /* exec header not counted */
|
||||
0, /* add_dynamic_symbols */
|
||||
0, /* add_one_symbol */
|
||||
0, /* link_dynamic_object */
|
||||
0, /* write_dynamic_symbol */
|
||||
0, /* check_dynamic_reloc */
|
||||
0 /* finish_dynamic_link */
|
||||
};
|
||||
|
||||
#include "aout-target.h"
|
@ -1,243 +0,0 @@
|
||||
/* BFD back-end for MS-DOS executables.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Bryan Ford of the University of Utah.
|
||||
|
||||
Contributed by the Center for Software Science at the
|
||||
University of Utah (pa-gdb-bugs@cs.utah.edu).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "libaout.h"
|
||||
|
||||
#if 0
|
||||
struct exe_header
|
||||
{
|
||||
unsigned short magic;
|
||||
unsigned short bytes_in_last_page;
|
||||
unsigned short npages; /* number of 512-byte "pages" including this header */
|
||||
unsigned short nrelocs;
|
||||
unsigned short header_paras; /* number of 16-byte paragraphs in header */
|
||||
unsigned short reserved;
|
||||
unsigned short load_switch;
|
||||
unsigned short ss_ofs;
|
||||
unsigned short sp;
|
||||
unsigned short checksum;
|
||||
unsigned short ip;
|
||||
unsigned short cs_ofs;
|
||||
unsigned short reloc_ofs;
|
||||
unsigned short reserved2;
|
||||
unsigned short something1;
|
||||
unsigned short something2;
|
||||
unsigned short something3;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define EXE_MAGIC 0x5a4d
|
||||
#define EXE_LOAD_HIGH 0x0000
|
||||
#define EXE_LOAD_LOW 0xffff
|
||||
#define EXE_PAGE_SIZE 512
|
||||
|
||||
|
||||
static int
|
||||
msdos_sizeof_headers (abfd, exec)
|
||||
bfd *abfd;
|
||||
boolean exec;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static boolean
|
||||
msdos_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
static char hdr[EXE_PAGE_SIZE];
|
||||
file_ptr outfile_size = sizeof(hdr);
|
||||
bfd_vma high_vma = 0;
|
||||
asection *sec;
|
||||
|
||||
/* Find the total size of the program on disk and in memory. */
|
||||
for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
|
||||
{
|
||||
if (bfd_get_section_size_before_reloc (sec) == 0)
|
||||
continue;
|
||||
if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
|
||||
{
|
||||
bfd_vma sec_vma = bfd_get_section_vma (abfd, sec)
|
||||
+ bfd_get_section_size_before_reloc (sec);
|
||||
if (sec_vma > high_vma)
|
||||
high_vma = sec_vma;
|
||||
}
|
||||
if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
|
||||
{
|
||||
file_ptr sec_end = sizeof(hdr)
|
||||
+ bfd_get_section_vma (abfd, sec)
|
||||
+ bfd_get_section_size_before_reloc (sec);
|
||||
if (sec_end > outfile_size)
|
||||
outfile_size = sec_end;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the program isn't too big. */
|
||||
if (high_vma > (bfd_vma)0xffff)
|
||||
{
|
||||
bfd_set_error(bfd_error_file_too_big);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* constants */
|
||||
bfd_h_put_16(abfd, EXE_MAGIC, &hdr[0]);
|
||||
bfd_h_put_16(abfd, EXE_PAGE_SIZE / 16, &hdr[8]);
|
||||
bfd_h_put_16(abfd, EXE_LOAD_LOW, &hdr[12]);
|
||||
bfd_h_put_16(abfd, 0x3e, &hdr[24]);
|
||||
bfd_h_put_16(abfd, 0x0001, &hdr[28]); /* XXX??? */
|
||||
bfd_h_put_16(abfd, 0x30fb, &hdr[30]); /* XXX??? */
|
||||
bfd_h_put_16(abfd, 0x726a, &hdr[32]); /* XXX??? */
|
||||
|
||||
/* bytes in last page (0 = full page) */
|
||||
bfd_h_put_16(abfd, outfile_size & (EXE_PAGE_SIZE - 1), &hdr[2]);
|
||||
|
||||
/* number of pages */
|
||||
bfd_h_put_16(abfd, (outfile_size + EXE_PAGE_SIZE - 1) / EXE_PAGE_SIZE,
|
||||
&hdr[4]);
|
||||
|
||||
/* Set the initial stack pointer to the end of the bss.
|
||||
The program's crt0 code must relocate it to a real stack. */
|
||||
bfd_h_put_16(abfd, high_vma, &hdr[16]);
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| bfd_write (hdr, 1, sizeof(hdr), abfd) != sizeof(hdr))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
msdos_set_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type count;
|
||||
{
|
||||
|
||||
if (count == 0)
|
||||
return true;
|
||||
|
||||
section->filepos = EXE_PAGE_SIZE + bfd_get_section_vma (abfd, section);
|
||||
|
||||
if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
|
||||
{
|
||||
if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
|
||||
|| bfd_write (location, 1, count, abfd) != count)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define msdos_mkobject aout_32_mkobject
|
||||
#define msdos_make_empty_symbol aout_32_make_empty_symbol
|
||||
#define msdos_bfd_reloc_type_lookup aout_32_reloc_type_lookup
|
||||
|
||||
#define msdos_close_and_cleanup _bfd_generic_close_and_cleanup
|
||||
#define msdos_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
|
||||
#define msdos_new_section_hook _bfd_generic_new_section_hook
|
||||
#define msdos_get_section_contents _bfd_generic_get_section_contents
|
||||
#define msdos_get_section_contents_in_window \
|
||||
_bfd_generic_get_section_contents_in_window
|
||||
#define msdos_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define msdos_bfd_relax_section bfd_generic_relax_section
|
||||
#define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define msdos_bfd_final_link _bfd_generic_final_link
|
||||
#define msdos_bfd_link_split_section _bfd_generic_link_split_section
|
||||
#define msdos_set_arch_mach _bfd_generic_set_arch_mach
|
||||
|
||||
#define msdos_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
|
||||
#define msdos_get_symtab _bfd_nosymbols_get_symtab
|
||||
#define msdos_print_symbol _bfd_nosymbols_print_symbol
|
||||
#define msdos_get_symbol_info _bfd_nosymbols_get_symbol_info
|
||||
#define msdos_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define msdos_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define msdos_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
|
||||
#define msdos_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define msdos_read_minisymbols _bfd_nosymbols_read_minisymbols
|
||||
#define msdos_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
|
||||
|
||||
#define msdos_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
|
||||
#define msdos_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
|
||||
#define msdos_32_bfd_link_split_section _bfd_generic_link_split_section
|
||||
|
||||
const bfd_target i386msdos_vec =
|
||||
{
|
||||
"msdos", /* name */
|
||||
bfd_target_msdos_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* target byte order */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order */
|
||||
(EXEC_P), /* object flags */
|
||||
(SEC_CODE | SEC_DATA | SEC_HAS_CONTENTS
|
||||
| SEC_ALLOC | SEC_LOAD), /* section flags */
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{
|
||||
_bfd_dummy_target,
|
||||
_bfd_dummy_target, /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
_bfd_dummy_target,
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
msdos_mkobject,
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false,
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false,
|
||||
msdos_write_object_contents,
|
||||
_bfd_write_archive_contents,
|
||||
bfd_false,
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (msdos),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (msdos),
|
||||
BFD_JUMP_TABLE_RELOCS (msdos),
|
||||
BFD_JUMP_TABLE_WRITE (msdos),
|
||||
BFD_JUMP_TABLE_LINK (msdos),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0
|
||||
};
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
/* BFD back-end for NetBSD/386 a.out-ish binaries.
|
||||
Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
#undef TARGET_IS_BIG_ENDIAN_P
|
||||
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
|
||||
#define DEFAULT_ARCH bfd_arch_i386
|
||||
#define MACHTYPE_OK(mtype) ((mtype) == M_386_NETBSD || (mtype) == M_UNKNOWN)
|
||||
|
||||
#define MY(OP) CAT(i386netbsd_,OP)
|
||||
/* This needs to start with a.out so GDB knows it is an a.out variant. */
|
||||
#define TARGETNAME "a.out-i386-netbsd"
|
||||
|
||||
#include "netbsd.h"
|
@ -1,370 +0,0 @@
|
||||
/* BFD back-end for os9000 i386 binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
#include "os9k.h"
|
||||
|
||||
static const bfd_target *os9k_callback PARAMS ((bfd *));
|
||||
|
||||
/* Swaps the information in an executable header taken from a raw byte
|
||||
stream memory image, into the internal exec_header structure. */
|
||||
boolean
|
||||
os9k_swap_exec_header_in (abfd, raw_bytes, execp)
|
||||
bfd *abfd;
|
||||
mh_com *raw_bytes;
|
||||
struct internal_exec *execp;
|
||||
{
|
||||
mh_com *bytes = (mh_com *) raw_bytes;
|
||||
unsigned int dload, dmemsize, dmemstart;
|
||||
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = bfd_h_get_16 (abfd, bytes->m_sync);
|
||||
execp->a_syms = 0;
|
||||
execp->a_entry = bfd_h_get_32 (abfd, bytes->m_exec);
|
||||
execp->a_talign = 2;
|
||||
execp->a_dalign = 2;
|
||||
execp->a_balign = 2;
|
||||
|
||||
dload = bfd_h_get_32 (abfd, bytes->m_idata);
|
||||
execp->a_data = dload + 8;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0
|
||||
|| (bfd_read (&dmemstart, sizeof (dmemstart), 1, abfd)
|
||||
!= sizeof (dmemstart))
|
||||
|| (bfd_read (&dmemsize, sizeof (dmemsize), 1, abfd)
|
||||
!= sizeof (dmemsize)))
|
||||
return false;
|
||||
|
||||
execp->a_tload = 0;
|
||||
execp->a_dload = bfd_h_get_32 (abfd, (unsigned char *) &dmemstart);
|
||||
execp->a_text = dload - execp->a_tload;
|
||||
execp->a_data = bfd_h_get_32 (abfd, (unsigned char *) &dmemsize);
|
||||
execp->a_bss = bfd_h_get_32 (abfd, bytes->m_data) - execp->a_data;
|
||||
|
||||
execp->a_trsize = 0;
|
||||
execp->a_drsize = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Swaps the information in an internal exec header structure into the
|
||||
supplied buffer ready for writing to disk. */
|
||||
|
||||
PROTO (void, os9k_swap_exec_header_out,
|
||||
(bfd * abfd,
|
||||
struct internal_exec * execp,
|
||||
struct mh_com * raw_bytes));
|
||||
void
|
||||
os9k_swap_exec_header_out (abfd, execp, raw_bytes)
|
||||
bfd *abfd;
|
||||
struct internal_exec *execp;
|
||||
mh_com *raw_bytes;
|
||||
{
|
||||
mh_com *bytes = (mh_com *) raw_bytes;
|
||||
|
||||
/* Now fill in fields in the raw data, from the fields in the exec struct. */
|
||||
bfd_h_put_32 (abfd, execp->a_info, bytes->e_info);
|
||||
bfd_h_put_32 (abfd, execp->a_text, bytes->e_text);
|
||||
bfd_h_put_32 (abfd, execp->a_data, bytes->e_data);
|
||||
bfd_h_put_32 (abfd, execp->a_bss, bytes->e_bss);
|
||||
bfd_h_put_32 (abfd, execp->a_syms, bytes->e_syms);
|
||||
bfd_h_put_32 (abfd, execp->a_entry, bytes->e_entry);
|
||||
bfd_h_put_32 (abfd, execp->a_trsize, bytes->e_trsize);
|
||||
bfd_h_put_32 (abfd, execp->a_drsize, bytes->e_drsize);
|
||||
bfd_h_put_32 (abfd, execp->a_tload, bytes->e_tload);
|
||||
bfd_h_put_32 (abfd, execp->a_dload, bytes->e_dload);
|
||||
bytes->e_talign[0] = execp->a_talign;
|
||||
bytes->e_dalign[0] = execp->a_dalign;
|
||||
bytes->e_balign[0] = execp->a_balign;
|
||||
bytes->e_relaxable[0] = execp->a_relaxable;
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
static const bfd_target *
|
||||
os9k_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec anexec;
|
||||
mh_com exec_bytes;
|
||||
|
||||
if (bfd_read ((PTR) & exec_bytes, MHCOM_BYTES_SIZE, 1, abfd)
|
||||
!= MHCOM_BYTES_SIZE)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
anexec.a_info = bfd_h_get_16 (abfd, exec_bytes.m_sync);
|
||||
if (N_BADMAG (anexec))
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! os9k_swap_exec_header_in (abfd, &exec_bytes, &anexec))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
return aout_32_some_aout_object_p (abfd, &anexec, os9k_callback);
|
||||
}
|
||||
|
||||
|
||||
/* Finish up the opening of a b.out file for reading. Fill in all the
|
||||
fields that are not handled by common code. */
|
||||
|
||||
static const bfd_target *
|
||||
os9k_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
unsigned long bss_start;
|
||||
|
||||
/* Architecture and machine type */
|
||||
bfd_set_arch_mach (abfd, bfd_arch_i386, 0);
|
||||
|
||||
/* The positions of the string table and symbol table. */
|
||||
obj_str_filepos (abfd) = 0;
|
||||
obj_sym_filepos (abfd) = 0;
|
||||
|
||||
/* The alignments of the sections */
|
||||
obj_textsec (abfd)->alignment_power = execp->a_talign;
|
||||
obj_datasec (abfd)->alignment_power = execp->a_dalign;
|
||||
obj_bsssec (abfd)->alignment_power = execp->a_balign;
|
||||
|
||||
/* The starting addresses of the sections. */
|
||||
obj_textsec (abfd)->vma = execp->a_tload;
|
||||
obj_datasec (abfd)->vma = execp->a_dload;
|
||||
|
||||
/* And reload the sizes, since the aout module zaps them */
|
||||
obj_textsec (abfd)->_raw_size = execp->a_text;
|
||||
|
||||
bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
|
||||
obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
|
||||
|
||||
/* The file positions of the sections */
|
||||
obj_textsec (abfd)->filepos = execp->a_entry;
|
||||
obj_datasec (abfd)->filepos = execp->a_dload;
|
||||
|
||||
/* The file positions of the relocation info ***
|
||||
obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
|
||||
obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
|
||||
*/
|
||||
|
||||
adata (abfd).page_size = 1; /* Not applicable. */
|
||||
adata (abfd).segment_size = 1;/* Not applicable. */
|
||||
adata (abfd).exec_bytes_size = MHCOM_BYTES_SIZE;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct bout_data_struct
|
||||
{
|
||||
struct aoutdata a;
|
||||
struct internal_exec e;
|
||||
};
|
||||
|
||||
static boolean
|
||||
os9k_mkobject (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bout_data_struct *rawptr;
|
||||
|
||||
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
|
||||
if (rawptr == NULL)
|
||||
return false;
|
||||
|
||||
abfd->tdata.bout_data = rawptr;
|
||||
exec_hdr (abfd) = &rawptr->e;
|
||||
|
||||
obj_textsec (abfd) = (asection *) NULL;
|
||||
obj_datasec (abfd) = (asection *) NULL;
|
||||
obj_bsssec (abfd) = (asection *) NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
os9k_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec swapped_hdr;
|
||||
|
||||
if (! aout_32_make_sections (abfd))
|
||||
return false;
|
||||
|
||||
exec_hdr (abfd)->a_info = BMAGIC;
|
||||
|
||||
exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
|
||||
exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size;
|
||||
exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_size;
|
||||
exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
|
||||
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
|
||||
exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) *
|
||||
sizeof (struct relocation_info));
|
||||
exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) *
|
||||
sizeof (struct relocation_info));
|
||||
|
||||
exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power;
|
||||
exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power;
|
||||
exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power;
|
||||
|
||||
exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma;
|
||||
exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma;
|
||||
|
||||
bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| (bfd_write ((PTR) & swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE))
|
||||
return false;
|
||||
|
||||
/* Now write out reloc info, followed by syms and strings */
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
if (!aout_32_write_syms (abfd))
|
||||
return false;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) (N_TROFF (*exec_hdr (abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd)))
|
||||
return false;
|
||||
if (bfd_seek (abfd, (file_ptr) (N_DROFF (*exec_hdr (abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
os9k_set_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
unsigned char *location;
|
||||
file_ptr offset;
|
||||
int count;
|
||||
{
|
||||
|
||||
if (abfd->output_has_begun == false)
|
||||
{ /* set by bfd.c handler */
|
||||
if (! aout_32_make_sections (abfd))
|
||||
return false;
|
||||
|
||||
obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
|
||||
obj_datasec (abfd)->filepos = obj_textsec (abfd)->filepos
|
||||
+ obj_textsec (abfd)->_raw_size;
|
||||
|
||||
}
|
||||
/* regardless, once we know what we're doing, we might as well get going */
|
||||
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
static int
|
||||
os9k_sizeof_headers (ignore_abfd, ignore)
|
||||
bfd *ignore_abfd;
|
||||
boolean ignore;
|
||||
{
|
||||
return sizeof (struct internal_exec);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
|
||||
|
||||
#define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
|
||||
#define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
|
||||
|
||||
#define aout_32_get_section_contents_in_window \
|
||||
_bfd_generic_get_section_contents_in_window
|
||||
|
||||
#define os9k_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define os9k_bfd_relax_section bfd_generic_relax_section
|
||||
#define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define os9k_bfd_final_link _bfd_generic_final_link
|
||||
#define os9k_bfd_link_split_section _bfd_generic_link_split_section
|
||||
|
||||
const bfd_target i386os9k_vec =
|
||||
{
|
||||
"i386os9k", /* name */
|
||||
bfd_target_os9k_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* hdr byte order is little */
|
||||
(HAS_RELOC | EXEC_P | WP_TEXT), /* object flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */
|
||||
0, /* symbol leading char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
{_bfd_dummy_target, os9k_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, bfd_false, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, bfd_false, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (aout_32),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
|
||||
BFD_JUMP_TABLE_SYMBOLS (aout_32),
|
||||
BFD_JUMP_TABLE_RELOCS (aout_32),
|
||||
BFD_JUMP_TABLE_WRITE (aout_32),
|
||||
BFD_JUMP_TABLE_LINK (os9k),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,263 +0,0 @@
|
||||
/* BFD back-end for Irix core files.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Stu Grossman, Cygnus Support.
|
||||
Converted to back-end form by Ian Lance Taylor, Cygnus Support
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file can only be compiled on systems which use Irix style core
|
||||
files (namely, Irix 4 and Irix 5, so far). */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#ifdef IRIX_CORE
|
||||
|
||||
#include <core.out.h>
|
||||
|
||||
struct sgi_core_struct
|
||||
{
|
||||
int sig;
|
||||
char cmd[CORE_NAMESIZE];
|
||||
};
|
||||
|
||||
#define core_hdr(bfd) ((bfd)->tdata.sgi_core_data)
|
||||
#define core_signal(bfd) (core_hdr(bfd)->sig)
|
||||
#define core_command(bfd) (core_hdr(bfd)->cmd)
|
||||
|
||||
static asection *
|
||||
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
|
||||
bfd *abfd;
|
||||
CONST char *name;
|
||||
flagword flags;
|
||||
bfd_size_type _raw_size;
|
||||
bfd_vma vma;
|
||||
file_ptr filepos;
|
||||
{
|
||||
asection *asect;
|
||||
|
||||
asect = bfd_make_section_anyway (abfd, name);
|
||||
if (!asect)
|
||||
return NULL;
|
||||
|
||||
asect->flags = flags;
|
||||
asect->_raw_size = _raw_size;
|
||||
asect->vma = vma;
|
||||
asect->filepos = filepos;
|
||||
asect->alignment_power = 4;
|
||||
|
||||
return asect;
|
||||
}
|
||||
|
||||
static const bfd_target *
|
||||
irix_core_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int val;
|
||||
int i;
|
||||
char *secname;
|
||||
struct coreout coreout;
|
||||
struct idesc *idg, *idf, *ids;
|
||||
|
||||
val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd);
|
||||
if (val != sizeof coreout)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (coreout.c_magic != CORE_MAGIC
|
||||
|| coreout.c_version != CORE_VERSION1)
|
||||
return 0;
|
||||
|
||||
core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, sizeof (struct sgi_core_struct));
|
||||
if (!core_hdr (abfd))
|
||||
return NULL;
|
||||
|
||||
strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE);
|
||||
core_signal (abfd) = coreout.c_sigcause;
|
||||
|
||||
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < coreout.c_nvmap; i++)
|
||||
{
|
||||
struct vmap vmap;
|
||||
|
||||
val = bfd_read ((PTR)&vmap, 1, sizeof vmap, abfd);
|
||||
if (val != sizeof vmap)
|
||||
break;
|
||||
|
||||
switch (vmap.v_type)
|
||||
{
|
||||
case VDATA:
|
||||
secname = ".data";
|
||||
break;
|
||||
case VSTACK:
|
||||
secname = ".stack";
|
||||
break;
|
||||
#ifdef VMAPFILE
|
||||
case VMAPFILE:
|
||||
secname = ".mapfile";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
/* A file offset of zero means that the section is not contained
|
||||
in the corefile. */
|
||||
if (vmap.v_offset == 0)
|
||||
continue;
|
||||
|
||||
if (!make_bfd_asection (abfd, secname,
|
||||
SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
|
||||
vmap.v_len,
|
||||
vmap.v_vaddr,
|
||||
vmap.v_offset,
|
||||
2))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Make sure that the regs are contiguous within the core file. */
|
||||
|
||||
idg = &coreout.c_idesc[I_GPREGS];
|
||||
idf = &coreout.c_idesc[I_FPREGS];
|
||||
ids = &coreout.c_idesc[I_SPECREGS];
|
||||
|
||||
if (idg->i_offset + idg->i_len != idf->i_offset
|
||||
|| idf->i_offset + idf->i_len != ids->i_offset)
|
||||
return 0; /* Can't deal with non-contig regs */
|
||||
|
||||
if (bfd_seek (abfd, idg->i_offset, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
make_bfd_asection (abfd, ".reg",
|
||||
SEC_HAS_CONTENTS,
|
||||
idg->i_len + idf->i_len + ids->i_len,
|
||||
0,
|
||||
idg->i_offset);
|
||||
|
||||
/* OK, we believe you. You're a core file (sure, sure). */
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
irix_core_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_command (abfd);
|
||||
}
|
||||
|
||||
static int
|
||||
irix_core_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_signal (abfd);
|
||||
}
|
||||
|
||||
static boolean
|
||||
irix_core_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd, *exec_bfd;
|
||||
{
|
||||
return true; /* XXX - FIXME */
|
||||
}
|
||||
|
||||
static asymbol *
|
||||
irix_core_make_empty_symbol (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
|
||||
if (new)
|
||||
new->the_bfd = abfd;
|
||||
return new;
|
||||
}
|
||||
|
||||
#define irix_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
|
||||
#define irix_core_get_symtab _bfd_nosymbols_get_symtab
|
||||
#define irix_core_print_symbol _bfd_nosymbols_print_symbol
|
||||
#define irix_core_get_symbol_info _bfd_nosymbols_get_symbol_info
|
||||
#define irix_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
|
||||
#define irix_core_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define irix_core_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define irix_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define irix_core_read_minisymbols _bfd_nosymbols_read_minisymbols
|
||||
#define irix_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
void
|
||||
swap_abort()
|
||||
{
|
||||
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
|
||||
}
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET \
|
||||
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
|
||||
|
||||
const bfd_target irix_core_vec =
|
||||
{
|
||||
"irix-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
irix_core_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (irix_core),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (irix_core),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
|
||||
#endif /* IRIX_CORE */
|
@ -1,503 +0,0 @@
|
||||
/* libbfd.h -- Declarations used by bfd library *implementation*.
|
||||
(This include file is not for users of the library.)
|
||||
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
** NOTE: libbfd.h is a GENERATED file. Don't change it; instead,
|
||||
** change libbfd-in.h or the other BFD source files processed to
|
||||
** generate this file.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Align an address upward to a boundary, expressed as a number of bytes.
|
||||
E.g. align to an 8-byte boundary with argument of 8. */
|
||||
#define BFD_ALIGN(this, boundary) \
|
||||
((( (this) + ((boundary) -1)) & (~((boundary)-1))))
|
||||
|
||||
/* If you want to read and write large blocks, you might want to do it
|
||||
in quanta of this amount */
|
||||
#define DEFAULT_BUFFERSIZE 8192
|
||||
|
||||
/* Set a tdata field. Can't use the other macros for this, since they
|
||||
do casts, and casting to the left of assignment isn't portable. */
|
||||
#define set_tdata(bfd, v) ((bfd)->tdata.any = (PTR) (v))
|
||||
|
||||
/* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
|
||||
to an instance of this structure. */
|
||||
|
||||
struct bfd_in_memory
|
||||
{
|
||||
/* Size of buffer. */
|
||||
bfd_size_type size;
|
||||
/* Buffer holding contents of BFD. */
|
||||
bfd_byte *buffer;
|
||||
};
|
||||
|
||||
/* tdata for an archive. For an input archive, cache
|
||||
needs to be free()'d. For an output archive, symdefs do. */
|
||||
|
||||
struct artdata {
|
||||
file_ptr first_file_filepos;
|
||||
/* Speed up searching the armap */
|
||||
struct ar_cache *cache;
|
||||
bfd *archive_head; /* Only interesting in output routines */
|
||||
carsym *symdefs; /* the symdef entries */
|
||||
symindex symdef_count; /* how many there are */
|
||||
char *extended_names; /* clever intel extension */
|
||||
/* when more compilers are standard C, this can be a time_t */
|
||||
long armap_timestamp; /* Timestamp value written into armap.
|
||||
This is used for BSD archives to check
|
||||
that the timestamp is recent enough
|
||||
for the BSD linker to not complain,
|
||||
just before we finish writing an
|
||||
archive. */
|
||||
file_ptr armap_datepos; /* Position within archive to seek to
|
||||
rewrite the date field. */
|
||||
PTR tdata; /* Backend specific information. */
|
||||
};
|
||||
|
||||
#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
|
||||
|
||||
/* Goes in bfd's arelt_data slot */
|
||||
struct areltdata {
|
||||
char * arch_header; /* it's actually a string */
|
||||
unsigned int parsed_size; /* octets of filesize not including ar_hdr */
|
||||
char *filename; /* null-terminated */
|
||||
};
|
||||
|
||||
#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
|
||||
|
||||
extern PTR bfd_malloc PARAMS ((size_t));
|
||||
extern PTR bfd_realloc PARAMS ((PTR, size_t));
|
||||
extern PTR bfd_zmalloc PARAMS ((size_t));
|
||||
|
||||
extern bfd_error_handler_type _bfd_error_handler;
|
||||
|
||||
/* These routines allocate and free things on the BFD's obstack. */
|
||||
|
||||
PTR bfd_alloc PARAMS ((bfd *abfd, size_t size));
|
||||
PTR bfd_zalloc PARAMS ((bfd *abfd, size_t size));
|
||||
void bfd_alloc_grow PARAMS ((bfd *abfd, PTR thing, size_t size));
|
||||
PTR bfd_alloc_finish PARAMS ((bfd *abfd));
|
||||
PTR bfd_alloc_by_size_t PARAMS ((bfd *abfd, size_t wanted));
|
||||
|
||||
#define bfd_release(x,y) (void) obstack_free(&(x->memory),y)
|
||||
|
||||
bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
|
||||
bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
|
||||
boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
|
||||
boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
|
||||
const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
|
||||
boolean bfd_slurp_armap PARAMS ((bfd *abfd));
|
||||
boolean bfd_slurp_bsd_armap_f2 PARAMS ((bfd *abfd));
|
||||
#define bfd_slurp_bsd_armap bfd_slurp_armap
|
||||
#define bfd_slurp_coff_armap bfd_slurp_armap
|
||||
boolean _bfd_slurp_extended_name_table PARAMS ((bfd *abfd));
|
||||
extern boolean _bfd_construct_extended_name_table
|
||||
PARAMS ((bfd *, boolean, char **, bfd_size_type *));
|
||||
boolean _bfd_write_archive_contents PARAMS ((bfd *abfd));
|
||||
boolean _bfd_compute_and_write_armap PARAMS ((bfd *, unsigned int elength));
|
||||
bfd *_bfd_get_elt_at_filepos PARAMS ((bfd *archive, file_ptr filepos));
|
||||
extern bfd *_bfd_generic_get_elt_at_index PARAMS ((bfd *, symindex));
|
||||
bfd * _bfd_new_bfd PARAMS ((void));
|
||||
|
||||
boolean bfd_false PARAMS ((bfd *ignore));
|
||||
boolean bfd_true PARAMS ((bfd *ignore));
|
||||
PTR bfd_nullvoidptr PARAMS ((bfd *ignore));
|
||||
int bfd_0 PARAMS ((bfd *ignore));
|
||||
unsigned int bfd_0u PARAMS ((bfd *ignore));
|
||||
long bfd_0l PARAMS ((bfd *ignore));
|
||||
long _bfd_n1 PARAMS ((bfd *ignore));
|
||||
void bfd_void PARAMS ((bfd *ignore));
|
||||
|
||||
bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
|
||||
const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
|
||||
|
||||
void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
|
||||
char *hdr));
|
||||
void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
|
||||
char *hdr));
|
||||
void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
|
||||
char *hdr));
|
||||
|
||||
boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,
|
||||
struct orl *map, unsigned int orl_count, int stridx));
|
||||
|
||||
boolean coff_write_armap PARAMS ((bfd *arch, unsigned int elength,
|
||||
struct orl *map, unsigned int orl_count, int stridx));
|
||||
|
||||
extern PTR _bfd_generic_read_ar_hdr PARAMS ((bfd *));
|
||||
|
||||
extern PTR _bfd_generic_read_ar_hdr_mag PARAMS ((bfd *, const char *));
|
||||
|
||||
bfd * bfd_generic_openr_next_archived_file PARAMS ((bfd *archive,
|
||||
bfd *last_file));
|
||||
|
||||
int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
|
||||
|
||||
#define _bfd_read_ar_hdr(abfd) \
|
||||
BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
|
||||
|
||||
/* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
|
||||
|
||||
#define _bfd_generic_close_and_cleanup bfd_true
|
||||
#define _bfd_generic_bfd_free_cached_info bfd_true
|
||||
#define _bfd_generic_new_section_hook \
|
||||
((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
|
||||
extern boolean _bfd_generic_get_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
|
||||
bfd_size_type count));
|
||||
extern boolean _bfd_generic_get_section_contents_in_window
|
||||
PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
|
||||
|
||||
/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic). */
|
||||
|
||||
#define _bfd_generic_bfd_copy_private_bfd_data \
|
||||
((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
|
||||
#define _bfd_generic_bfd_merge_private_bfd_data \
|
||||
((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
|
||||
#define _bfd_generic_bfd_set_private_flags \
|
||||
((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
|
||||
#define _bfd_generic_bfd_copy_private_section_data \
|
||||
((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
|
||||
#define _bfd_generic_bfd_copy_private_symbol_data \
|
||||
((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
|
||||
#define _bfd_generic_bfd_print_private_bfd_data \
|
||||
((boolean (*) PARAMS ((bfd *, PTR))) bfd_true)
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
|
||||
support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
|
||||
|
||||
extern char *_bfd_nocore_core_file_failing_command PARAMS ((bfd *));
|
||||
extern int _bfd_nocore_core_file_failing_signal PARAMS ((bfd *));
|
||||
extern boolean _bfd_nocore_core_file_matches_executable_p
|
||||
PARAMS ((bfd *, bfd *));
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
|
||||
file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
|
||||
|
||||
#define _bfd_noarchive_slurp_armap bfd_false
|
||||
#define _bfd_noarchive_slurp_extended_name_table bfd_false
|
||||
#define _bfd_noarchive_construct_extended_name_table \
|
||||
((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
|
||||
bfd_false)
|
||||
#define _bfd_noarchive_truncate_arname \
|
||||
((void (*) PARAMS ((bfd *, const char *, char *))) bfd_void)
|
||||
#define _bfd_noarchive_write_armap \
|
||||
((boolean (*) \
|
||||
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
|
||||
bfd_false)
|
||||
#define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
|
||||
#define _bfd_noarchive_openr_next_archived_file \
|
||||
((bfd *(*) PARAMS ((bfd *, bfd *))) bfd_nullvoidptr)
|
||||
#define _bfd_noarchive_get_elt_at_index \
|
||||
((bfd *(*) PARAMS ((bfd *, symindex))) bfd_nullvoidptr)
|
||||
#define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
||||
#define _bfd_noarchive_update_armap_timestamp bfd_false
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
|
||||
archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
|
||||
|
||||
#define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
|
||||
#define _bfd_archive_bsd_slurp_extended_name_table \
|
||||
_bfd_slurp_extended_name_table
|
||||
extern boolean _bfd_archive_bsd_construct_extended_name_table
|
||||
PARAMS ((bfd *, char **, bfd_size_type *, const char **));
|
||||
#define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
|
||||
#define _bfd_archive_bsd_write_armap bsd_write_armap
|
||||
#define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
|
||||
#define _bfd_archive_bsd_openr_next_archived_file \
|
||||
bfd_generic_openr_next_archived_file
|
||||
#define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
|
||||
#define _bfd_archive_bsd_generic_stat_arch_elt \
|
||||
bfd_generic_stat_arch_elt
|
||||
extern boolean _bfd_archive_bsd_update_armap_timestamp PARAMS ((bfd *));
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
|
||||
archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
|
||||
|
||||
#define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
|
||||
#define _bfd_archive_coff_slurp_extended_name_table \
|
||||
_bfd_slurp_extended_name_table
|
||||
extern boolean _bfd_archive_coff_construct_extended_name_table
|
||||
PARAMS ((bfd *, char **, bfd_size_type *, const char **));
|
||||
#define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
|
||||
#define _bfd_archive_coff_write_armap coff_write_armap
|
||||
#define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
|
||||
#define _bfd_archive_coff_openr_next_archived_file \
|
||||
bfd_generic_openr_next_archived_file
|
||||
#define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
|
||||
#define _bfd_archive_coff_generic_stat_arch_elt \
|
||||
bfd_generic_stat_arch_elt
|
||||
#define _bfd_archive_coff_update_armap_timestamp bfd_true
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
|
||||
support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
|
||||
|
||||
#define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
|
||||
#define _bfd_nosymbols_get_symtab \
|
||||
((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
|
||||
#define _bfd_nosymbols_make_empty_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
|
||||
#define _bfd_nosymbols_print_symbol \
|
||||
((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_void)
|
||||
#define _bfd_nosymbols_get_symbol_info \
|
||||
((void (*) PARAMS ((bfd *, asymbol *, symbol_info *))) bfd_void)
|
||||
#define _bfd_nosymbols_bfd_is_local_label \
|
||||
((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false)
|
||||
#define _bfd_nosymbols_get_lineno \
|
||||
((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
|
||||
#define _bfd_nosymbols_find_nearest_line \
|
||||
((boolean (*) \
|
||||
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, \
|
||||
const char **, unsigned int *))) \
|
||||
bfd_false)
|
||||
#define _bfd_nosymbols_bfd_make_debug_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, PTR, unsigned long))) bfd_nullvoidptr)
|
||||
#define _bfd_nosymbols_read_minisymbols \
|
||||
((long (*) PARAMS ((bfd *, boolean, PTR *, unsigned int *))) _bfd_n1)
|
||||
#define _bfd_nosymbols_minisymbol_to_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, boolean, const PTR, asymbol *))) \
|
||||
bfd_nullvoidptr)
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
|
||||
support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
|
||||
|
||||
#define _bfd_norelocs_get_reloc_upper_bound \
|
||||
((long (*) PARAMS ((bfd *, asection *))) _bfd_n1)
|
||||
#define _bfd_norelocs_canonicalize_reloc \
|
||||
((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) _bfd_n1)
|
||||
#define _bfd_norelocs_bfd_reloc_type_lookup \
|
||||
((reloc_howto_type *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) \
|
||||
bfd_nullvoidptr)
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
|
||||
be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
|
||||
|
||||
#define _bfd_nowrite_set_arch_mach \
|
||||
((boolean (*) PARAMS ((bfd *, enum bfd_architecture, unsigned long))) \
|
||||
bfd_false)
|
||||
#define _bfd_nowrite_set_section_contents \
|
||||
((boolean (*) PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type))) \
|
||||
bfd_false)
|
||||
|
||||
/* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic). */
|
||||
|
||||
#define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
|
||||
extern boolean _bfd_generic_set_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
|
||||
support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
|
||||
|
||||
#define _bfd_nolink_sizeof_headers ((int (*) PARAMS ((bfd *, boolean))) bfd_0)
|
||||
#define _bfd_nolink_bfd_get_relocated_section_contents \
|
||||
((bfd_byte *(*) \
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, \
|
||||
bfd_byte *, boolean, asymbol **))) \
|
||||
bfd_nullvoidptr)
|
||||
#define _bfd_nolink_bfd_relax_section \
|
||||
((boolean (*) \
|
||||
PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *))) \
|
||||
bfd_false)
|
||||
#define _bfd_nolink_bfd_link_hash_table_create \
|
||||
((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
|
||||
#define _bfd_nolink_bfd_link_add_symbols \
|
||||
((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
|
||||
#define _bfd_nolink_bfd_final_link \
|
||||
((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
|
||||
#define _bfd_nolink_bfd_link_split_section \
|
||||
((boolean (*) PARAMS ((bfd *, struct sec *))) bfd_false)
|
||||
|
||||
/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
|
||||
have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
|
||||
(_bfd_nodynamic). */
|
||||
|
||||
#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
|
||||
#define _bfd_nodynamic_canonicalize_dynamic_symtab \
|
||||
((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
|
||||
#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
|
||||
#define _bfd_nodynamic_canonicalize_dynamic_reloc \
|
||||
((long (*) PARAMS ((bfd *, arelent **, asymbol **))) _bfd_n1)
|
||||
|
||||
/* Generic routine to determine of the given symbol is a local
|
||||
label. */
|
||||
extern boolean bfd_generic_is_local_label PARAMS ((bfd *, asymbol *));
|
||||
|
||||
/* Generic minisymbol routines. */
|
||||
extern long _bfd_generic_read_minisymbols
|
||||
PARAMS ((bfd *, boolean, PTR *, unsigned int *));
|
||||
extern asymbol *_bfd_generic_minisymbol_to_symbol
|
||||
PARAMS ((bfd *, boolean, const PTR, asymbol *));
|
||||
|
||||
/* Find the nearest line using .stab/.stabstr sections. */
|
||||
extern boolean _bfd_stab_section_find_nearest_line
|
||||
PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
|
||||
const char **, unsigned int *, PTR *));
|
||||
|
||||
/* A routine to create entries for a bfd_link_hash_table. */
|
||||
extern struct bfd_hash_entry *_bfd_link_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *entry,
|
||||
struct bfd_hash_table *table,
|
||||
const char *string));
|
||||
|
||||
/* Initialize a bfd_link_hash_table. */
|
||||
extern boolean _bfd_link_hash_table_init
|
||||
PARAMS ((struct bfd_link_hash_table *, bfd *,
|
||||
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *)));
|
||||
|
||||
/* Generic link hash table creation routine. */
|
||||
extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
|
||||
PARAMS ((bfd *));
|
||||
|
||||
/* Generic add symbol routine. */
|
||||
extern boolean _bfd_generic_link_add_symbols
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
/* Generic add symbol routine. This version is used by targets for
|
||||
which the linker must collect constructors and destructors by name,
|
||||
as the collect2 program does. */
|
||||
extern boolean _bfd_generic_link_add_symbols_collect
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
/* Generic archive add symbol routine. */
|
||||
extern boolean _bfd_generic_link_add_archive_symbols
|
||||
PARAMS ((bfd *, struct bfd_link_info *,
|
||||
boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *)));
|
||||
|
||||
/* Forward declaration to avoid prototype errors. */
|
||||
typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
|
||||
|
||||
/* Generic routine to add a single symbol. */
|
||||
extern boolean _bfd_generic_link_add_one_symbol
|
||||
PARAMS ((struct bfd_link_info *, bfd *, const char *name, flagword,
|
||||
asection *, bfd_vma, const char *, boolean copy,
|
||||
boolean constructor, struct bfd_link_hash_entry **));
|
||||
|
||||
/* Generic link routine. */
|
||||
extern boolean _bfd_generic_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
extern boolean _bfd_generic_link_split_section
|
||||
PARAMS ((bfd *, struct sec *));
|
||||
|
||||
/* Generic reloc_link_order processing routine. */
|
||||
extern boolean _bfd_generic_reloc_link_order
|
||||
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
||||
struct bfd_link_order *));
|
||||
|
||||
/* Default link order processing routine. */
|
||||
extern boolean _bfd_default_link_order
|
||||
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
||||
struct bfd_link_order *));
|
||||
|
||||
/* Count the number of reloc entries in a link order list. */
|
||||
extern unsigned int _bfd_count_link_order_relocs
|
||||
PARAMS ((struct bfd_link_order *));
|
||||
|
||||
/* Final link relocation routine. */
|
||||
extern bfd_reloc_status_type _bfd_final_link_relocate
|
||||
PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
|
||||
bfd_vma address, bfd_vma value, bfd_vma addend));
|
||||
|
||||
/* Relocate a particular location by a howto and a value. */
|
||||
extern bfd_reloc_status_type _bfd_relocate_contents
|
||||
PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
|
||||
|
||||
/* Create a string table. */
|
||||
extern struct bfd_strtab_hash *_bfd_stringtab_init PARAMS ((void));
|
||||
|
||||
/* Create an XCOFF .debug section style string table. */
|
||||
extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init PARAMS ((void));
|
||||
|
||||
/* Free a string table. */
|
||||
extern void _bfd_stringtab_free PARAMS ((struct bfd_strtab_hash *));
|
||||
|
||||
/* Get the size of a string table. */
|
||||
extern bfd_size_type _bfd_stringtab_size PARAMS ((struct bfd_strtab_hash *));
|
||||
|
||||
/* Add a string to a string table. */
|
||||
extern bfd_size_type _bfd_stringtab_add
|
||||
PARAMS ((struct bfd_strtab_hash *, const char *, boolean hash,
|
||||
boolean copy));
|
||||
|
||||
/* Write out a string table. */
|
||||
extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *));
|
||||
|
||||
/* Macros to tell if bfds are read or write enabled.
|
||||
|
||||
Note that bfds open for read may be scribbled into if the fd passed
|
||||
to bfd_fdopenr is actually open both for read and write
|
||||
simultaneously. However an output bfd will never be open for
|
||||
read. Therefore sometimes you want to check bfd_read_p or
|
||||
!bfd_read_p, and only sometimes bfd_write_p.
|
||||
*/
|
||||
|
||||
#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction)
|
||||
#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction)
|
||||
|
||||
void bfd_assert PARAMS ((const char*,int));
|
||||
|
||||
#define BFD_ASSERT(x) \
|
||||
{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
|
||||
|
||||
#define BFD_FAIL() \
|
||||
{ bfd_assert(__FILE__,__LINE__); }
|
||||
|
||||
FILE * bfd_cache_lookup_worker PARAMS ((bfd *));
|
||||
|
||||
extern bfd *bfd_last_cache;
|
||||
|
||||
/* Now Steve, what's the story here? */
|
||||
#ifdef lint
|
||||
#define itos(x) "l"
|
||||
#define stoi(x) 1
|
||||
#else
|
||||
#define itos(x) ((char*)(x))
|
||||
#define stoi(x) ((int)(x))
|
||||
#endif
|
||||
|
||||
/* List of supported target vectors, and the default vector (if
|
||||
bfd_default_vector[0] is NULL, there is no default). */
|
||||
extern const bfd_target * const bfd_target_vector[];
|
||||
extern const bfd_target * const bfd_default_vector[];
|
||||
|
||||
/* Functions shared by the ECOFF and MIPS ELF backends, which have no
|
||||
other common header files. */
|
||||
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
struct ecoff_find_line;
|
||||
#endif
|
||||
|
||||
extern boolean _bfd_ecoff_locate_line
|
||||
PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
|
||||
const struct ecoff_debug_swap * const, struct ecoff_find_line *,
|
||||
const char **, const char **, unsigned int *));
|
||||
extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
|
||||
extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
|
||||
extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
|
||||
|
||||
extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *));
|
||||
extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma));
|
||||
|
||||
/* And more follows */
|
||||
|
@ -1,482 +0,0 @@
|
||||
/* BFD COFF object file private structure.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
** NOTE: libcoff.h is a GENERATED file. Don't change it; instead,
|
||||
** change libcoff-in.h or coffcode.h.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfdlink.h"
|
||||
|
||||
/* Object file tdata; access macros */
|
||||
|
||||
#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
|
||||
#define exec_hdr(bfd) (coff_data(bfd)->hdr)
|
||||
#define obj_pe(bfd) (coff_data(bfd)->pe)
|
||||
#define obj_symbols(bfd) (coff_data(bfd)->symbols)
|
||||
#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
|
||||
|
||||
#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
|
||||
#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
|
||||
#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
|
||||
#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
|
||||
#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
|
||||
|
||||
#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
|
||||
#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
|
||||
#define obj_coff_strings(bfd) (coff_data (bfd)->strings)
|
||||
#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
|
||||
#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
|
||||
|
||||
#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
|
||||
|
||||
/* `Tdata' information kept for COFF files. */
|
||||
|
||||
typedef struct coff_tdata
|
||||
{
|
||||
struct coff_symbol_struct *symbols; /* symtab for input bfd */
|
||||
unsigned int *conversion_table;
|
||||
int conv_table_size;
|
||||
file_ptr sym_filepos;
|
||||
|
||||
struct coff_ptr_struct *raw_syments;
|
||||
unsigned int raw_syment_count;
|
||||
|
||||
/* These are only valid once writing has begun */
|
||||
long int relocbase;
|
||||
|
||||
/* These members communicate important constants about the symbol table
|
||||
to GDB's symbol-reading code. These `constants' unfortunately vary
|
||||
from coff implementation to implementation... */
|
||||
unsigned local_n_btmask;
|
||||
unsigned local_n_btshft;
|
||||
unsigned local_n_tmask;
|
||||
unsigned local_n_tshift;
|
||||
unsigned local_symesz;
|
||||
unsigned local_auxesz;
|
||||
unsigned local_linesz;
|
||||
|
||||
/* The unswapped external symbols. May be NULL. Read by
|
||||
_bfd_coff_get_external_symbols. */
|
||||
PTR external_syms;
|
||||
/* If this is true, the external_syms may not be freed. */
|
||||
boolean keep_syms;
|
||||
|
||||
/* The string table. May be NULL. Read by
|
||||
_bfd_coff_read_string_table. */
|
||||
char *strings;
|
||||
/* If this is true, the strings may not be freed. */
|
||||
boolean keep_strings;
|
||||
|
||||
/* is this a PE format coff file */
|
||||
int pe;
|
||||
/* Used by the COFF backend linker. */
|
||||
struct coff_link_hash_entry **sym_hashes;
|
||||
|
||||
/* used by the pe linker for PowerPC */
|
||||
int *local_toc_sym_map;
|
||||
|
||||
struct bfd_link_info *link_info;
|
||||
|
||||
/* Used by coff_find_nearest_line. */
|
||||
PTR line_info;
|
||||
} coff_data_type;
|
||||
|
||||
/* Tdata for pe image files. */
|
||||
typedef struct pe_tdata
|
||||
{
|
||||
coff_data_type coff;
|
||||
struct internal_extra_pe_aouthdr pe_opthdr;
|
||||
int dll;
|
||||
int has_reloc_section;
|
||||
boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
|
||||
flagword real_flags;
|
||||
} pe_data_type;
|
||||
|
||||
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
|
||||
|
||||
/* Tdata for XCOFF files. */
|
||||
|
||||
struct xcoff_tdata
|
||||
{
|
||||
/* Basic COFF information. */
|
||||
coff_data_type coff;
|
||||
|
||||
/* True if a large a.out header should be generated. */
|
||||
boolean full_aouthdr;
|
||||
|
||||
/* TOC value. */
|
||||
bfd_vma toc;
|
||||
|
||||
/* Index of section holding TOC. */
|
||||
int sntoc;
|
||||
|
||||
/* Index of section holding entry point. */
|
||||
int snentry;
|
||||
|
||||
/* .text alignment from optional header. */
|
||||
int text_align_power;
|
||||
|
||||
/* .data alignment from optional header. */
|
||||
int data_align_power;
|
||||
|
||||
/* modtype from optional header. */
|
||||
short modtype;
|
||||
|
||||
/* cputype from optional header. */
|
||||
short cputype;
|
||||
|
||||
/* maxdata from optional header. */
|
||||
bfd_size_type maxdata;
|
||||
|
||||
/* maxstack from optional header. */
|
||||
bfd_size_type maxstack;
|
||||
|
||||
/* Used by the XCOFF backend linker. */
|
||||
asection **csects;
|
||||
unsigned long *debug_indices;
|
||||
unsigned int import_file_id;
|
||||
};
|
||||
|
||||
#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
|
||||
|
||||
/* We take the address of the first element of a asymbol to ensure that the
|
||||
* macro is only ever applied to an asymbol. */
|
||||
#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
|
||||
|
||||
/* The used_by_bfd field of a section may be set to a pointer to this
|
||||
structure. */
|
||||
|
||||
struct coff_section_tdata
|
||||
{
|
||||
/* The relocs, swapped into COFF internal form. This may be NULL. */
|
||||
struct internal_reloc *relocs;
|
||||
/* If this is true, the relocs entry may not be freed. */
|
||||
boolean keep_relocs;
|
||||
/* The section contents. This may be NULL. */
|
||||
bfd_byte *contents;
|
||||
/* If this is true, the contents entry may not be freed. */
|
||||
boolean keep_contents;
|
||||
/* Information cached by coff_find_nearest_line. */
|
||||
bfd_vma offset;
|
||||
unsigned int i;
|
||||
const char *function;
|
||||
int line_base;
|
||||
/* Available for individual backends. */
|
||||
PTR tdata;
|
||||
};
|
||||
|
||||
/* An accessor macro for the coff_section_tdata structure. */
|
||||
#define coff_section_data(abfd, sec) \
|
||||
((struct coff_section_tdata *) (sec)->used_by_bfd)
|
||||
|
||||
/* Tdata for sections in XCOFF files. This is used by the linker. */
|
||||
|
||||
struct xcoff_section_tdata
|
||||
{
|
||||
/* Used for XCOFF csects created by the linker; points to the real
|
||||
XCOFF section which contains this csect. */
|
||||
asection *enclosing;
|
||||
/* The lineno_count field for the enclosing section, because we are
|
||||
going to clobber it there. */
|
||||
unsigned int lineno_count;
|
||||
/* The first and one past the last symbol indices for symbols used
|
||||
by this csect. */
|
||||
unsigned long first_symndx;
|
||||
unsigned long last_symndx;
|
||||
};
|
||||
|
||||
/* An accessor macro the xcoff_section_tdata structure. */
|
||||
#define xcoff_section_data(abfd, sec) \
|
||||
((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
|
||||
|
||||
/* COFF linker hash table entries. */
|
||||
|
||||
struct coff_link_hash_entry
|
||||
{
|
||||
struct bfd_link_hash_entry root;
|
||||
|
||||
/* Symbol index in output file. Set to -1 initially. Set to -2 if
|
||||
there is a reloc against this symbol. */
|
||||
long indx;
|
||||
|
||||
/* Symbol type. */
|
||||
unsigned short type;
|
||||
|
||||
/* Symbol class. */
|
||||
unsigned char class;
|
||||
|
||||
/* Number of auxiliary entries. */
|
||||
char numaux;
|
||||
|
||||
/* BFD to take auxiliary entries from. */
|
||||
bfd *auxbfd;
|
||||
|
||||
/* Pointer to array of auxiliary entries, if any. */
|
||||
union internal_auxent *aux;
|
||||
};
|
||||
|
||||
/* COFF linker hash table. */
|
||||
|
||||
struct coff_link_hash_table
|
||||
{
|
||||
struct bfd_link_hash_table root;
|
||||
};
|
||||
|
||||
/* Look up an entry in a COFF linker hash table. */
|
||||
|
||||
#define coff_link_hash_lookup(table, string, create, copy, follow) \
|
||||
((struct coff_link_hash_entry *) \
|
||||
bfd_link_hash_lookup (&(table)->root, (string), (create), \
|
||||
(copy), (follow)))
|
||||
|
||||
/* Traverse a COFF linker hash table. */
|
||||
|
||||
#define coff_link_hash_traverse(table, func, info) \
|
||||
(bfd_link_hash_traverse \
|
||||
(&(table)->root, \
|
||||
(boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
|
||||
(info)))
|
||||
|
||||
/* Get the COFF linker hash table from a link_info structure. */
|
||||
|
||||
#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
|
||||
|
||||
/* Functions in coffgen.c. */
|
||||
extern const bfd_target *coff_object_p PARAMS ((bfd *));
|
||||
extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
|
||||
extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern int coff_count_linenumbers PARAMS ((bfd *));
|
||||
extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
|
||||
extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
|
||||
extern void coff_mangle_symbols PARAMS ((bfd *));
|
||||
extern boolean coff_write_symbols PARAMS ((bfd *));
|
||||
extern boolean coff_write_linenumbers PARAMS ((bfd *));
|
||||
extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
|
||||
extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
|
||||
extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
|
||||
extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
|
||||
extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
|
||||
extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
|
||||
extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
|
||||
extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
|
||||
extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
|
||||
bfd_print_symbol_type how));
|
||||
extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
|
||||
symbol_info *ret));
|
||||
extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
|
||||
unsigned long));
|
||||
extern boolean coff_find_nearest_line PARAMS ((bfd *,
|
||||
asection *,
|
||||
asymbol **,
|
||||
bfd_vma offset,
|
||||
CONST char **filename_ptr,
|
||||
CONST char **functionname_ptr,
|
||||
unsigned int *line_ptr));
|
||||
extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
|
||||
extern boolean bfd_coff_reloc16_relax_section
|
||||
PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
|
||||
extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
|
||||
bfd_byte *, boolean relocateable, asymbol **));
|
||||
extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
|
||||
struct bfd_link_info *,
|
||||
asection *));
|
||||
extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
|
||||
asection *input_section,
|
||||
bfd_vma val));
|
||||
|
||||
/* Functions and types in cofflink.c. */
|
||||
|
||||
#define STRING_SIZE_SIZE (4)
|
||||
|
||||
/* We use a hash table to merge identical enum, struct, and union
|
||||
definitions in the linker. */
|
||||
|
||||
/* Information we keep for a single element (an enum value, a
|
||||
structure or union field) in the debug merge hash table. */
|
||||
|
||||
struct coff_debug_merge_element
|
||||
{
|
||||
/* Next element. */
|
||||
struct coff_debug_merge_element *next;
|
||||
|
||||
/* Name. */
|
||||
const char *name;
|
||||
|
||||
/* Type. */
|
||||
unsigned int type;
|
||||
|
||||
/* Symbol index for complex type. */
|
||||
long tagndx;
|
||||
};
|
||||
|
||||
/* A linked list of debug merge entries for a given name. */
|
||||
|
||||
struct coff_debug_merge_type
|
||||
{
|
||||
/* Next type with the same name. */
|
||||
struct coff_debug_merge_type *next;
|
||||
|
||||
/* Class of type. */
|
||||
int class;
|
||||
|
||||
/* Symbol index where this type is defined. */
|
||||
long indx;
|
||||
|
||||
/* List of elements. */
|
||||
struct coff_debug_merge_element *elements;
|
||||
};
|
||||
|
||||
/* Information we store in the debug merge hash table. */
|
||||
|
||||
struct coff_debug_merge_hash_entry
|
||||
{
|
||||
struct bfd_hash_entry root;
|
||||
|
||||
/* A list of types with this name. */
|
||||
struct coff_debug_merge_type *types;
|
||||
};
|
||||
|
||||
/* The debug merge hash table. */
|
||||
|
||||
struct coff_debug_merge_hash_table
|
||||
{
|
||||
struct bfd_hash_table root;
|
||||
};
|
||||
|
||||
/* Initialize a COFF debug merge hash table. */
|
||||
|
||||
#define coff_debug_merge_hash_table_init(table) \
|
||||
(bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
|
||||
|
||||
/* Free a COFF debug merge hash table. */
|
||||
|
||||
#define coff_debug_merge_hash_table_free(table) \
|
||||
(bfd_hash_table_free (&(table)->root))
|
||||
|
||||
/* Look up an entry in a COFF debug merge hash table. */
|
||||
|
||||
#define coff_debug_merge_hash_lookup(table, string, create, copy) \
|
||||
((struct coff_debug_merge_hash_entry *) \
|
||||
bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
|
||||
|
||||
/* Information we keep for each section in the output file when doing
|
||||
a relocateable link. */
|
||||
|
||||
struct coff_link_section_info
|
||||
{
|
||||
/* The relocs to be output. */
|
||||
struct internal_reloc *relocs;
|
||||
/* For each reloc against a global symbol whose index was not known
|
||||
when the reloc was handled, the global hash table entry. */
|
||||
struct coff_link_hash_entry **rel_hashes;
|
||||
};
|
||||
|
||||
/* Information that we pass around while doing the final link step. */
|
||||
|
||||
struct coff_final_link_info
|
||||
{
|
||||
/* General link information. */
|
||||
struct bfd_link_info *info;
|
||||
/* Output BFD. */
|
||||
bfd *output_bfd;
|
||||
/* Used to indicate failure in traversal routine. */
|
||||
boolean failed;
|
||||
/* Hash table for long symbol names. */
|
||||
struct bfd_strtab_hash *strtab;
|
||||
/* When doing a relocateable link, an array of information kept for
|
||||
each output section, indexed by the target_index field. */
|
||||
struct coff_link_section_info *section_info;
|
||||
/* Symbol index of last C_FILE symbol (-1 if none). */
|
||||
long last_file_index;
|
||||
/* Contents of last C_FILE symbol. */
|
||||
struct internal_syment last_file;
|
||||
/* Hash table used to merge debug information. */
|
||||
struct coff_debug_merge_hash_table debug_merge;
|
||||
/* Buffer large enough to hold swapped symbols of any input file. */
|
||||
struct internal_syment *internal_syms;
|
||||
/* Buffer large enough to hold sections of symbols of any input file. */
|
||||
asection **sec_ptrs;
|
||||
/* Buffer large enough to hold output indices of symbols of any
|
||||
input file. */
|
||||
long *sym_indices;
|
||||
/* Buffer large enough to hold output symbols for any input file. */
|
||||
bfd_byte *outsyms;
|
||||
/* Buffer large enough to hold external line numbers for any input
|
||||
section. */
|
||||
bfd_byte *linenos;
|
||||
/* Buffer large enough to hold any input section. */
|
||||
bfd_byte *contents;
|
||||
/* Buffer large enough to hold external relocs of any input section. */
|
||||
bfd_byte *external_relocs;
|
||||
/* Buffer large enough to hold swapped relocs of any input section. */
|
||||
struct internal_reloc *internal_relocs;
|
||||
};
|
||||
|
||||
extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
||||
extern boolean _bfd_coff_link_hash_table_init
|
||||
PARAMS ((struct coff_link_hash_table *, bfd *,
|
||||
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *)));
|
||||
extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
|
||||
PARAMS ((bfd *));
|
||||
extern const char *_bfd_coff_internal_syment_name
|
||||
PARAMS ((bfd *, const struct internal_syment *, char *));
|
||||
extern boolean _bfd_coff_link_add_symbols
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean _bfd_coff_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern struct internal_reloc *_bfd_coff_read_internal_relocs
|
||||
PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
|
||||
struct internal_reloc *));
|
||||
extern boolean _bfd_coff_generic_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
|
||||
extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
||||
extern boolean _bfd_coff_write_global_sym
|
||||
PARAMS ((struct coff_link_hash_entry *, PTR));
|
||||
extern boolean _bfd_coff_link_input_bfd
|
||||
PARAMS ((struct coff_final_link_info *, bfd *));
|
||||
extern boolean _bfd_coff_reloc_link_order
|
||||
PARAMS ((bfd *, struct coff_final_link_info *, asection *,
|
||||
struct bfd_link_order *));
|
||||
|
||||
|
||||
#define coff_get_section_contents_in_window \
|
||||
_bfd_generic_get_section_contents_in_window
|
||||
|
||||
/* Functions in xcofflink.c. */
|
||||
|
||||
extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
|
||||
PARAMS ((bfd *));
|
||||
extern boolean _bfd_xcoff_bfd_link_add_symbols
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean _bfd_xcoff_bfd_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean _bfd_ppc_xcoff_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
|
||||
/* And more taken from the source .. */
|
||||
|
@ -1,549 +0,0 @@
|
||||
/* HP PA-RISC SOM object file format: definitions internal to BFD.
|
||||
Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by the Center for Software Science at the
|
||||
University of Utah (pa-gdb-bugs@cs.utah.edu).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _HPPA_H
|
||||
#define _HPPA_H
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
#define PA_PAGESIZE 0x1000
|
||||
|
||||
#ifndef INLINE
|
||||
#ifdef __GNUC__
|
||||
#define INLINE inline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif /* GNU C? */
|
||||
#endif /* INLINE */
|
||||
|
||||
/* The PA instruction set variants. */
|
||||
enum pa_arch {pa10 = 10, pa11 = 11, pa20 = 20};
|
||||
|
||||
/* HP PA-RISC relocation types */
|
||||
|
||||
enum hppa_reloc_field_selector_type
|
||||
{
|
||||
R_HPPA_FSEL = 0x0,
|
||||
R_HPPA_LSSEL = 0x1,
|
||||
R_HPPA_RSSEL = 0x2,
|
||||
R_HPPA_LSEL = 0x3,
|
||||
R_HPPA_RSEL = 0x4,
|
||||
R_HPPA_LDSEL = 0x5,
|
||||
R_HPPA_RDSEL = 0x6,
|
||||
R_HPPA_LRSEL = 0x7,
|
||||
R_HPPA_RRSEL = 0x8,
|
||||
R_HPPA_NSEL = 0x9,
|
||||
R_HPPA_NLSEL = 0xa,
|
||||
R_HPPA_NLRSEL = 0xb,
|
||||
R_HPPA_PSEL = 0xc,
|
||||
R_HPPA_LPSEL = 0xd,
|
||||
R_HPPA_RPSEL = 0xe,
|
||||
R_HPPA_TSEL = 0xf,
|
||||
R_HPPA_LTSEL = 0x10,
|
||||
R_HPPA_RTSEL = 0x11
|
||||
};
|
||||
|
||||
/* /usr/include/reloc.h defines these to constants. We want to use
|
||||
them in enums, so #undef them before we start using them. We might
|
||||
be able to fix this another way by simply managing not to include
|
||||
/usr/include/reloc.h, but currently GDB picks up these defines
|
||||
somewhere. */
|
||||
#undef e_fsel
|
||||
#undef e_lssel
|
||||
#undef e_rssel
|
||||
#undef e_lsel
|
||||
#undef e_rsel
|
||||
#undef e_ldsel
|
||||
#undef e_rdsel
|
||||
#undef e_lrsel
|
||||
#undef e_rrsel
|
||||
#undef e_nsel
|
||||
#undef e_nlsel
|
||||
#undef e_nlrsel
|
||||
#undef e_psel
|
||||
#undef e_lpsel
|
||||
#undef e_rpsel
|
||||
#undef e_tsel
|
||||
#undef e_ltsel
|
||||
#undef e_rtsel
|
||||
#undef e_one
|
||||
#undef e_two
|
||||
#undef e_pcrel
|
||||
#undef e_con
|
||||
#undef e_plabel
|
||||
#undef e_abs
|
||||
|
||||
/* for compatibility */
|
||||
enum hppa_reloc_field_selector_type_alt
|
||||
{
|
||||
e_fsel = R_HPPA_FSEL,
|
||||
e_lssel = R_HPPA_LSSEL,
|
||||
e_rssel = R_HPPA_RSSEL,
|
||||
e_lsel = R_HPPA_LSEL,
|
||||
e_rsel = R_HPPA_RSEL,
|
||||
e_ldsel = R_HPPA_LDSEL,
|
||||
e_rdsel = R_HPPA_RDSEL,
|
||||
e_lrsel = R_HPPA_LRSEL,
|
||||
e_rrsel = R_HPPA_RRSEL,
|
||||
e_nsel = R_HPPA_NSEL,
|
||||
e_nlsel = R_HPPA_NLSEL,
|
||||
e_nlrsel = R_HPPA_NLRSEL,
|
||||
e_psel = R_HPPA_PSEL,
|
||||
e_lpsel = R_HPPA_LPSEL,
|
||||
e_rpsel = R_HPPA_RPSEL,
|
||||
e_tsel = R_HPPA_TSEL,
|
||||
e_ltsel = R_HPPA_LTSEL,
|
||||
e_rtsel = R_HPPA_RTSEL
|
||||
};
|
||||
|
||||
enum hppa_reloc_expr_type
|
||||
{
|
||||
R_HPPA_E_ONE = 0,
|
||||
R_HPPA_E_TWO = 1,
|
||||
R_HPPA_E_PCREL = 2,
|
||||
R_HPPA_E_CON = 3,
|
||||
R_HPPA_E_PLABEL = 7,
|
||||
R_HPPA_E_ABS = 18
|
||||
};
|
||||
|
||||
/* for compatibility */
|
||||
enum hppa_reloc_expr_type_alt
|
||||
{
|
||||
e_one = R_HPPA_E_ONE,
|
||||
e_two = R_HPPA_E_TWO,
|
||||
e_pcrel = R_HPPA_E_PCREL,
|
||||
e_con = R_HPPA_E_CON,
|
||||
e_plabel = R_HPPA_E_PLABEL,
|
||||
e_abs = R_HPPA_E_ABS
|
||||
};
|
||||
|
||||
|
||||
/* Relocations for function calls must be accompanied by parameter
|
||||
relocation bits. These bits describe exactly where the caller has
|
||||
placed the function's arguments and where it expects to find a return
|
||||
value.
|
||||
|
||||
Both ELF and SOM encode this information within the addend field
|
||||
of the call relocation. (Note this could break very badly if one
|
||||
was to make a call like bl foo + 0x12345678).
|
||||
|
||||
The high order 10 bits contain parameter relocation information,
|
||||
the low order 22 bits contain the constant offset. */
|
||||
|
||||
#define HPPA_R_ARG_RELOC(a) (((a) >> 22) & 0x3FF)
|
||||
#define HPPA_R_CONSTANT(a) ((((int)(a)) << 10) >> 10)
|
||||
#define HPPA_R_ADDEND(r,c) (((r) << 22) + ((c) & 0x3FFFFF))
|
||||
|
||||
/* Some functions to manipulate PA instructions. */
|
||||
static INLINE unsigned int
|
||||
assemble_3 (x)
|
||||
unsigned int x;
|
||||
{
|
||||
return (((x & 1) << 2) | ((x & 6) >> 1)) & 7;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
dis_assemble_3 (x, r)
|
||||
unsigned int x;
|
||||
unsigned int *r;
|
||||
{
|
||||
*r = (((x & 4) >> 2) | ((x & 3) << 1)) & 7;
|
||||
}
|
||||
|
||||
static INLINE unsigned int
|
||||
assemble_12 (x, y)
|
||||
unsigned int x, y;
|
||||
{
|
||||
return (((y & 1) << 11) | ((x & 1) << 10) | ((x & 0x7fe) >> 1)) & 0xfff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
dis_assemble_12 (as12, x, y)
|
||||
unsigned int as12;
|
||||
unsigned int *x, *y;
|
||||
{
|
||||
*y = (as12 & 0x800) >> 11;
|
||||
*x = ((as12 & 0x3ff) << 1) | ((as12 & 0x400) >> 10);
|
||||
}
|
||||
|
||||
static INLINE unsigned long
|
||||
assemble_17 (x, y, z)
|
||||
unsigned int x, y, z;
|
||||
{
|
||||
unsigned long temp;
|
||||
|
||||
temp = ((z & 1) << 16) |
|
||||
((x & 0x1f) << 11) |
|
||||
((y & 1) << 10) |
|
||||
((y & 0x7fe) >> 1);
|
||||
return temp & 0x1ffff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
dis_assemble_17 (as17, x, y, z)
|
||||
unsigned int as17;
|
||||
unsigned int *x, *y, *z;
|
||||
{
|
||||
|
||||
*z = (as17 & 0x10000) >> 16;
|
||||
*x = (as17 & 0x0f800) >> 11;
|
||||
*y = (((as17 & 0x00400) >> 10) | ((as17 & 0x3ff) << 1)) & 0x7ff;
|
||||
}
|
||||
|
||||
static INLINE unsigned long
|
||||
assemble_21 (x)
|
||||
unsigned int x;
|
||||
{
|
||||
unsigned long temp;
|
||||
|
||||
temp = ((x & 1) << 20) |
|
||||
((x & 0xffe) << 8) |
|
||||
((x & 0xc000) >> 7) |
|
||||
((x & 0x1f0000) >> 14) |
|
||||
((x & 0x003000) >> 12);
|
||||
return temp & 0x1fffff;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
dis_assemble_21 (as21, x)
|
||||
unsigned int as21, *x;
|
||||
{
|
||||
unsigned long temp;
|
||||
|
||||
|
||||
temp = (as21 & 0x100000) >> 20;
|
||||
temp |= (as21 & 0x0ffe00) >> 8;
|
||||
temp |= (as21 & 0x000180) << 7;
|
||||
temp |= (as21 & 0x00007c) << 14;
|
||||
temp |= (as21 & 0x000003) << 12;
|
||||
*x = temp;
|
||||
}
|
||||
|
||||
static INLINE unsigned long
|
||||
sign_extend (x, len)
|
||||
unsigned int x, len;
|
||||
{
|
||||
return (int)(x >> (len - 1) ? (-1 << len) | x : x);
|
||||
}
|
||||
|
||||
static INLINE unsigned int
|
||||
ones (n)
|
||||
int n;
|
||||
{
|
||||
unsigned int len_ones;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
len_ones = 0;
|
||||
while (i < n)
|
||||
{
|
||||
len_ones = (len_ones << 1) | 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
return len_ones;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
sign_unext (x, len, result)
|
||||
unsigned int x, len;
|
||||
unsigned int *result;
|
||||
{
|
||||
unsigned int len_ones;
|
||||
|
||||
len_ones = ones (len);
|
||||
|
||||
*result = x & len_ones;
|
||||
}
|
||||
|
||||
static INLINE unsigned long
|
||||
low_sign_extend (x, len)
|
||||
unsigned int x, len;
|
||||
{
|
||||
return (int)((x & 0x1 ? (-1 << (len - 1)) : 0) | x >> 1);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
low_sign_unext (x, len, result)
|
||||
unsigned int x, len;
|
||||
unsigned int *result;
|
||||
{
|
||||
unsigned int temp;
|
||||
unsigned int sign;
|
||||
unsigned int rest;
|
||||
unsigned int one_bit_at_len;
|
||||
unsigned int len_ones;
|
||||
|
||||
len_ones = ones (len);
|
||||
one_bit_at_len = 1 << (len - 1);
|
||||
|
||||
sign_unext (x, len, &temp);
|
||||
sign = temp & one_bit_at_len;
|
||||
sign >>= (len - 1);
|
||||
|
||||
rest = temp & (len_ones ^ one_bit_at_len);
|
||||
rest <<= 1;
|
||||
|
||||
*result = rest | sign;
|
||||
}
|
||||
|
||||
/* Handle field selectors for PA instructions. */
|
||||
|
||||
static INLINE unsigned long
|
||||
hppa_field_adjust (value, constant_value, r_field)
|
||||
unsigned long value;
|
||||
unsigned long constant_value;
|
||||
unsigned short r_field;
|
||||
{
|
||||
switch (r_field)
|
||||
{
|
||||
case e_fsel: /* F : no change */
|
||||
case e_nsel: /* N : no change */
|
||||
value += constant_value;
|
||||
break;
|
||||
|
||||
case e_lssel: /* LS : if (bit 21) then add 0x800
|
||||
arithmetic shift right 11 bits */
|
||||
value += constant_value;
|
||||
if (value & 0x00000400)
|
||||
value += 0x800;
|
||||
value = (value & 0xfffff800) >> 11;
|
||||
break;
|
||||
|
||||
case e_rssel: /* RS : Sign extend from bit 21 */
|
||||
value += constant_value;
|
||||
if (value & 0x00000400)
|
||||
value |= 0xfffff800;
|
||||
else
|
||||
value &= 0x7ff;
|
||||
break;
|
||||
|
||||
case e_lsel: /* L : Arithmetic shift right 11 bits */
|
||||
case e_nlsel: /* NL : Arithmetic shift right 11 bits */
|
||||
value += constant_value;
|
||||
value = (value & 0xfffff800) >> 11;
|
||||
break;
|
||||
|
||||
case e_rsel: /* R : Set bits 0-20 to zero */
|
||||
value += constant_value;
|
||||
value = value & 0x7ff;
|
||||
break;
|
||||
|
||||
case e_ldsel: /* LD : Add 0x800, arithmetic shift
|
||||
right 11 bits */
|
||||
value += constant_value;
|
||||
value += 0x800;
|
||||
value = (value & 0xfffff800) >> 11;
|
||||
break;
|
||||
|
||||
case e_rdsel: /* RD : Set bits 0-20 to one */
|
||||
value += constant_value;
|
||||
value |= 0xfffff800;
|
||||
break;
|
||||
|
||||
case e_lrsel: /* LR : L with "rounded" constant */
|
||||
case e_nlrsel: /* NLR : NL with "rounded" constant */
|
||||
value = value + ((constant_value + 0x1000) & 0xffffe000);
|
||||
value = (value & 0xfffff800) >> 11;
|
||||
break;
|
||||
|
||||
case e_rrsel: /* RR : R with "rounded" constant */
|
||||
value = value + ((constant_value + 0x1000) & 0xffffe000);
|
||||
value = (value & 0x7ff) + constant_value - ((constant_value + 0x1000) & 0xffffe000);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
/* PA-RISC OPCODES */
|
||||
#define get_opcode(insn) ((insn) & 0xfc000000) >> 26
|
||||
|
||||
/* FIXME: this list is incomplete. It should also be an enumerated
|
||||
type rather than #defines. */
|
||||
|
||||
#define LDO 0x0d
|
||||
#define LDB 0x10
|
||||
#define LDH 0x11
|
||||
#define LDW 0x12
|
||||
#define LDWM 0x13
|
||||
#define STB 0x18
|
||||
#define STH 0x19
|
||||
#define STW 0x1a
|
||||
#define STWM 0x1b
|
||||
#define COMICLR 0x24
|
||||
#define SUBI 0x25
|
||||
#define SUBIO 0x25
|
||||
#define ADDIT 0x2c
|
||||
#define ADDITO 0x2c
|
||||
#define ADDI 0x2d
|
||||
#define ADDIO 0x2d
|
||||
#define LDIL 0x08
|
||||
#define ADDIL 0x0a
|
||||
|
||||
#define MOVB 0x32
|
||||
#define MOVIB 0x33
|
||||
#define COMBT 0x20
|
||||
#define COMBF 0x22
|
||||
#define COMIBT 0x21
|
||||
#define COMIBF 0x23
|
||||
#define ADDBT 0x28
|
||||
#define ADDBF 0x2a
|
||||
#define ADDIBT 0x29
|
||||
#define ADDIBF 0x2b
|
||||
#define BVB 0x30
|
||||
#define BB 0x31
|
||||
|
||||
#define BL 0x3a
|
||||
#define BLE 0x39
|
||||
#define BE 0x38
|
||||
|
||||
|
||||
/* Given a machine instruction, return its format.
|
||||
|
||||
FIXME: opcodes which do not map to a known format
|
||||
should return an error of some sort. */
|
||||
|
||||
static INLINE char
|
||||
bfd_hppa_insn2fmt (insn)
|
||||
unsigned long insn;
|
||||
{
|
||||
char fmt = -1;
|
||||
unsigned char op = get_opcode (insn);
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case ADDI:
|
||||
case ADDIT:
|
||||
case SUBI:
|
||||
fmt = 11;
|
||||
break;
|
||||
case MOVB:
|
||||
case MOVIB:
|
||||
case COMBT:
|
||||
case COMBF:
|
||||
case COMIBT:
|
||||
case COMIBF:
|
||||
case ADDBT:
|
||||
case ADDBF:
|
||||
case ADDIBT:
|
||||
case ADDIBF:
|
||||
case BVB:
|
||||
case BB:
|
||||
fmt = 12;
|
||||
break;
|
||||
case LDO:
|
||||
case LDB:
|
||||
case LDH:
|
||||
case LDW:
|
||||
case LDWM:
|
||||
case STB:
|
||||
case STH:
|
||||
case STW:
|
||||
case STWM:
|
||||
fmt = 14;
|
||||
break;
|
||||
case BL:
|
||||
case BE:
|
||||
case BLE:
|
||||
fmt = 17;
|
||||
break;
|
||||
case LDIL:
|
||||
case ADDIL:
|
||||
fmt = 21;
|
||||
break;
|
||||
default:
|
||||
fmt = 32;
|
||||
break;
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
||||
/* Insert VALUE into INSN using R_FORMAT to determine exactly what
|
||||
bits to change. */
|
||||
|
||||
static INLINE unsigned long
|
||||
hppa_rebuild_insn (abfd, insn, value, r_format)
|
||||
bfd *abfd;
|
||||
unsigned long insn;
|
||||
unsigned long value;
|
||||
unsigned long r_format;
|
||||
{
|
||||
unsigned long const_part;
|
||||
unsigned long rebuilt_part;
|
||||
|
||||
switch (r_format)
|
||||
{
|
||||
case 11:
|
||||
{
|
||||
unsigned w1, w;
|
||||
|
||||
const_part = insn & 0xffffe002;
|
||||
dis_assemble_12 (value, &w1, &w);
|
||||
rebuilt_part = (w1 << 2) | w;
|
||||
return const_part | rebuilt_part;
|
||||
}
|
||||
|
||||
case 12:
|
||||
{
|
||||
unsigned w1, w;
|
||||
|
||||
const_part = insn & 0xffffe002;
|
||||
dis_assemble_12 (value, &w1, &w);
|
||||
rebuilt_part = (w1 << 2) | w;
|
||||
return const_part | rebuilt_part;
|
||||
}
|
||||
|
||||
case 14:
|
||||
const_part = insn & 0xffffc000;
|
||||
low_sign_unext (value, 14, &rebuilt_part);
|
||||
return const_part | rebuilt_part;
|
||||
|
||||
case 17:
|
||||
{
|
||||
unsigned w1, w2, w;
|
||||
|
||||
const_part = insn & 0xffe0e002;
|
||||
dis_assemble_17 (value, &w1, &w2, &w);
|
||||
rebuilt_part = (w2 << 2) | (w1 << 16) | w;
|
||||
return const_part | rebuilt_part;
|
||||
}
|
||||
|
||||
case 21:
|
||||
const_part = insn & 0xffe00000;
|
||||
dis_assemble_21 (value, &rebuilt_part);
|
||||
return const_part | rebuilt_part;
|
||||
|
||||
case 32:
|
||||
const_part = 0;
|
||||
return value;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
return insn;
|
||||
}
|
||||
|
||||
#endif /* _HPPA_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user