Bring in the files added by Gary Jennejohn's gdb update.

Submitted by:	gj
This commit is contained in:
jkh 1994-12-30 23:33:10 +00:00
parent 16d72e1e9b
commit d35da972f8
32 changed files with 27183 additions and 0 deletions

View File

@ -0,0 +1,354 @@
/* BFD back-end for Intel 386 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
#include "coff/i386.h"
#include "coff/internal.h"
#include "libcoff.h"
static bfd_reloc_status_type coff_i386_reloc PARAMS ((bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
PTR data,
asection *input_section,
bfd *output_bfd,
char **error_message));
/* The page size is a guess based on ELF. */
#define COFF_PAGE_SIZE 0x1000
/* For some reason when using i386 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_i386_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 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)
{
const 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;
}
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_i386_reloc, /* special_function */
"dir32", /* name */
true, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
false), /* pcrel_offset */
{7},
{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_i386_reloc, /* special_function */
"8", /* name */
true, /* partial_inplace */
0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */
false), /* 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_i386_reloc, /* special_function */
"16", /* name */
true, /* partial_inplace */
0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */
false), /* 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_i386_reloc, /* special_function */
"32", /* name */
true, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
false), /* 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_i386_reloc, /* special_function */
"DISP8", /* name */
true, /* partial_inplace */
0x000000ff, /* src_mask */
0x000000ff, /* dst_mask */
false), /* 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_i386_reloc, /* special_function */
"DISP16", /* name */
true, /* partial_inplace */
0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */
false), /* 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_i386_reloc, /* special_function */
"DISP32", /* name */
true, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
false) /* pcrel_offset */
};
/* Turn a howto into a reloc nunmber */
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
#define BADMAG(x) I386BADMAG(x)
#define I386 1 /* Customize coffcode.h */
#define RTYPE2HOWTO(cache_ptr, dst) \
cache_ptr->howto = howto_table + (dst)->r_type;
/* On SCO Unix 3.2.2 the native assembler generates two .data
sections. We handle that by renaming the second one to .data2. It
does no harm to do this for any 386 COFF target. */
#define TWO_DATA_SECS
/* For 386 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; \
}
#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
i386coff_vec =
#endif
{
#ifdef TARGET_NAME
TARGET_NAME,
#else
"coff-i386", /* name */
#endif
bfd_target_coff_flavour,
false, /* data byte order is little */
false, /* 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 */
0, /* leading underscore */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
2, /* minimum alignment power */
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,
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,741 @@
/* Generic COFF swapping routines, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This file contains routines used to swap COFF data. It is a header
file because the details of swapping depend on the details of the
structures used by each COFF implementation. This is included by
coffcode.h, as well as by the ECOFF backend.
Any file which uses this must first include "coff/internal.h" and
"coff/CPU.h". The functions will then be correct for that CPU. */
#define PUTWORD bfd_h_put_32
#define PUTHALF bfd_h_put_16
#define PUTBYTE bfd_h_put_8
#ifndef GET_FCN_LNNOPTR
#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef GET_FCN_ENDNDX
#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef PUT_FCN_LNNOPTR
#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef PUT_FCN_ENDNDX
#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef GET_LNSZ_LNNO
#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
#endif
#ifndef GET_LNSZ_SIZE
#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
#endif
#ifndef PUT_LNSZ_LNNO
#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
#endif
#ifndef PUT_LNSZ_SIZE
#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
#endif
#ifndef GET_SCN_SCNLEN
#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
#endif
#ifndef GET_SCN_NRELOC
#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
#endif
#ifndef GET_SCN_NLINNO
#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
#endif
#ifndef PUT_SCN_SCNLEN
#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
#endif
#ifndef PUT_SCN_NRELOC
#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
#endif
#ifndef PUT_SCN_NLINNO
#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
#endif
#ifndef GET_LINENO_LNNO
#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
#endif
#ifndef PUT_LINENO_LNNO
#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
#endif
/* The f_symptr field in the filehdr is sometimes 64 bits. */
#ifndef GET_FILEHDR_SYMPTR
#define GET_FILEHDR_SYMPTR bfd_h_get_32
#endif
#ifndef PUT_FILEHDR_SYMPTR
#define PUT_FILEHDR_SYMPTR bfd_h_put_32
#endif
/* Some fields in the aouthdr are sometimes 64 bits. */
#ifndef GET_AOUTHDR_TSIZE
#define GET_AOUTHDR_TSIZE bfd_h_get_32
#endif
#ifndef PUT_AOUTHDR_TSIZE
#define PUT_AOUTHDR_TSIZE bfd_h_put_32
#endif
#ifndef GET_AOUTHDR_DSIZE
#define GET_AOUTHDR_DSIZE bfd_h_get_32
#endif
#ifndef PUT_AOUTHDR_DSIZE
#define PUT_AOUTHDR_DSIZE bfd_h_put_32
#endif
#ifndef GET_AOUTHDR_BSIZE
#define GET_AOUTHDR_BSIZE bfd_h_get_32
#endif
#ifndef PUT_AOUTHDR_BSIZE
#define PUT_AOUTHDR_BSIZE bfd_h_put_32
#endif
#ifndef GET_AOUTHDR_ENTRY
#define GET_AOUTHDR_ENTRY bfd_h_get_32
#endif
#ifndef PUT_AOUTHDR_ENTRY
#define PUT_AOUTHDR_ENTRY bfd_h_put_32
#endif
#ifndef GET_AOUTHDR_TEXT_START
#define GET_AOUTHDR_TEXT_START bfd_h_get_32
#endif
#ifndef PUT_AOUTHDR_TEXT_START
#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
#endif
#ifndef GET_AOUTHDR_DATA_START
#define GET_AOUTHDR_DATA_START bfd_h_get_32
#endif
#ifndef PUT_AOUTHDR_DATA_START
#define PUT_AOUTHDR_DATA_START bfd_h_put_32
#endif
/* Some fields in the scnhdr are sometimes 64 bits. */
#ifndef GET_SCNHDR_PADDR
#define GET_SCNHDR_PADDR bfd_h_get_32
#endif
#ifndef PUT_SCNHDR_PADDR
#define PUT_SCNHDR_PADDR bfd_h_put_32
#endif
#ifndef GET_SCNHDR_VADDR
#define GET_SCNHDR_VADDR bfd_h_get_32
#endif
#ifndef PUT_SCNHDR_VADDR
#define PUT_SCNHDR_VADDR bfd_h_put_32
#endif
#ifndef GET_SCNHDR_SIZE
#define GET_SCNHDR_SIZE bfd_h_get_32
#endif
#ifndef PUT_SCNHDR_SIZE
#define PUT_SCNHDR_SIZE bfd_h_put_32
#endif
#ifndef GET_SCNHDR_SCNPTR
#define GET_SCNHDR_SCNPTR bfd_h_get_32
#endif
#ifndef PUT_SCNHDR_SCNPTR
#define PUT_SCNHDR_SCNPTR bfd_h_put_32
#endif
#ifndef GET_SCNHDR_RELPTR
#define GET_SCNHDR_RELPTR bfd_h_get_32
#endif
#ifndef PUT_SCNHDR_RELPTR
#define PUT_SCNHDR_RELPTR bfd_h_put_32
#endif
#ifndef GET_SCNHDR_LNNOPTR
#define GET_SCNHDR_LNNOPTR bfd_h_get_32
#endif
#ifndef PUT_SCNHDR_LNNOPTR
#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
#endif
#ifndef NO_COFF_RELOCS
static void
bfd_swap_reloc_in (abfd, reloc_src, reloc_dst)
bfd *abfd;
RELOC *reloc_src;
struct internal_reloc *reloc_dst;
{
reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
#ifdef RS6000COFF_C
reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
#else
reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
#endif
#ifdef SWAP_IN_RELOC_OFFSET
reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
(bfd_byte *) reloc_src->r_offset);
#endif
}
static unsigned int
coff_swap_reloc_out (abfd, src, dst)
bfd *abfd;
PTR src;
PTR dst;
{
struct internal_reloc *reloc_src = (struct internal_reloc *)src;
struct external_reloc *reloc_dst = (struct external_reloc *)dst;
bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
#ifdef RS6000COFF_C
bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
#else
bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
reloc_dst->r_type);
#endif
#ifdef SWAP_OUT_RELOC_OFFSET
SWAP_OUT_RELOC_OFFSET(abfd,
reloc_src->r_offset,
(bfd_byte *) reloc_dst->r_offset);
#endif
#ifdef SWAP_OUT_RELOC_EXTRA
SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
#endif
return sizeof(struct external_reloc);
}
#endif /* NO_COFF_RELOCS */
static void
coff_swap_filehdr_in (abfd, src, dst)
bfd *abfd;
PTR src;
PTR dst;
{
FILHDR *filehdr_src = (FILHDR *) src;
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
filehdr_dst->f_symptr =
GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
}
static unsigned int
coff_swap_filehdr_out (abfd, in, out)
bfd *abfd;
PTR in;
PTR out;
{
struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
FILHDR *filehdr_out = (FILHDR *)out;
bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
(bfd_byte *) filehdr_out->f_symptr);
bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
return sizeof(FILHDR);
}
#ifndef NO_COFF_SYMBOLS
static void
coff_swap_sym_in (abfd, ext1, in1)
bfd *abfd;
PTR ext1;
PTR in1;
{
SYMENT *ext = (SYMENT *)ext1;
struct internal_syment *in = (struct internal_syment *)in1;
if( ext->e.e_name[0] == 0) {
in->_n._n_n._n_zeroes = 0;
in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
}
else {
#if SYMNMLEN != E_SYMNMLEN
-> Error, we need to cope with truncating or extending SYMNMLEN!;
#else
memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
#endif
}
in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
if (sizeof(ext->e_type) == 2){
in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
}
else {
in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
}
in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
}
static unsigned int
coff_swap_sym_out (abfd, inp, extp)
bfd *abfd;
PTR inp;
PTR extp;
{
struct internal_syment *in = (struct internal_syment *)inp;
SYMENT *ext =(SYMENT *)extp;
if(in->_n._n_name[0] == 0) {
bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
}
else {
#if SYMNMLEN != E_SYMNMLEN
-> Error, we need to cope with truncating or extending SYMNMLEN!;
#else
memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
#endif
}
bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
if (sizeof(ext->e_type) == 2)
{
bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
}
else
{
bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
}
bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
return sizeof(SYMENT);
}
static void
coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
bfd *abfd;
PTR ext1;
int type;
int class;
int indx;
int numaux;
PTR in1;
{
AUXENT *ext = (AUXENT *)ext1;
union internal_auxent *in = (union internal_auxent *)in1;
switch (class) {
case C_FILE:
if (ext->x_file.x_fname[0] == 0) {
in->x_file.x_n.x_zeroes = 0;
in->x_file.x_n.x_offset =
bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
} else {
#if FILNMLEN != E_FILNMLEN
-> Error, we need to cope with truncating or extending FILNMLEN!;
#else
memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
#endif
}
return;
/* RS/6000 "csect" auxents */
#ifdef RS6000COFF_C
case C_EXT:
case C_HIDEXT:
if (indx + 1 == numaux)
{
in->x_csect.x_scnlen.l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
ext->x_csect.x_parmhash);
in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
/* We don't have to hack bitfields in x_smtyp because it's
defined by shifts-and-ands, which are equivalent on all
byte orders. */
in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
return;
}
break;
#endif
case C_STAT:
#ifdef C_LEAFSTAT
case C_LEAFSTAT:
#endif
case C_HIDDEN:
if (type == T_NULL) {
in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
return;
}
break;
}
in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
#ifndef NO_TVNDX
in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
#endif
if (ISARY(type)) {
#if DIMNUM != E_DIMNUM
-> Error, we need to cope with truncating or extending DIMNUM!;
#else
in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
#endif
}
if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext);
in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext);
}
if (ISFCN(type)) {
in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
}
else {
in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
}
}
static unsigned int
coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
bfd *abfd;
PTR inp;
int type;
int class;
int indx;
int numaux;
PTR extp;
{
union internal_auxent *in = (union internal_auxent *)inp;
AUXENT *ext = (AUXENT *)extp;
memset((PTR)ext, 0, AUXESZ);
switch (class) {
case C_FILE:
if (in->x_file.x_fname[0] == 0) {
PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
PUTWORD(abfd,
in->x_file.x_n.x_offset,
(bfd_byte *) ext->x_file.x_n.x_offset);
}
else {
#if FILNMLEN != E_FILNMLEN
-> Error, we need to cope with truncating or extending FILNMLEN!;
#else
memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
#endif
}
return sizeof (AUXENT);
#ifdef RS6000COFF_C
/* RS/6000 "csect" auxents */
case C_EXT:
case C_HIDEXT:
if (indx + 1 == numaux)
{
PUTWORD (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen);
PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
/* We don't have to hack bitfields in x_smtyp because it's
defined by shifts-and-ands, which are equivalent on all
byte orders. */
PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
return sizeof (AUXENT);
}
break;
#endif
case C_STAT:
#ifdef C_LEAFSTAT
case C_LEAFSTAT:
#endif
case C_HIDDEN:
if (type == T_NULL) {
PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
return sizeof (AUXENT);
}
break;
}
PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
#ifndef NO_TVNDX
bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
#endif
if (class == C_BLOCK || ISFCN(type) || ISTAG(class)) {
PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
}
if (ISFCN(type)) {
PUTWORD(abfd, in->x_sym.x_misc.x_fsize, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
}
else {
if (ISARY(type)) {
#if DIMNUM != E_DIMNUM
-> Error, we need to cope with truncating or extending DIMNUM!;
#else
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
#endif
}
PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
}
return sizeof(AUXENT);
}
#endif /* NO_COFF_SYMBOLS */
#ifndef NO_COFF_LINENOS
static void
coff_swap_lineno_in (abfd, ext1, in1)
bfd *abfd;
PTR ext1;
PTR in1;
{
LINENO *ext = (LINENO *)ext1;
struct internal_lineno *in = (struct internal_lineno *)in1;
in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
in->l_lnno = GET_LINENO_LNNO(abfd, ext);
}
static unsigned int
coff_swap_lineno_out (abfd, inp, outp)
bfd *abfd;
PTR inp;
PTR outp;
{
struct internal_lineno *in = (struct internal_lineno *)inp;
struct external_lineno *ext = (struct external_lineno *)outp;
PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
ext->l_addr.l_symndx);
PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
return sizeof(struct external_lineno);
}
#endif /* NO_COFF_LINENOS */
static void
coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
bfd *abfd;
PTR aouthdr_ext1;
PTR aouthdr_int1;
{
AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
aouthdr_int->tsize =
GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
aouthdr_int->dsize =
GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
aouthdr_int->bsize =
GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
aouthdr_int->entry =
GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
aouthdr_int->text_start =
GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
aouthdr_int->data_start =
GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
#ifdef I960
aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
#endif
#ifdef APOLLO_M68
bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
#endif
#ifdef RS6000COFF_C
aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
#endif
#ifdef MIPSECOFF
aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
#endif
#ifdef ALPHAECOFF
aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
#endif
}
static unsigned int
coff_swap_aouthdr_out (abfd, in, out)
bfd *abfd;
PTR in;
PTR out;
{
struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
AOUTHDR *aouthdr_out = (AOUTHDR *)out;
bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
(bfd_byte *) aouthdr_out->text_start);
PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
(bfd_byte *) aouthdr_out->data_start);
#ifdef I960
bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
#endif
#ifdef MIPSECOFF
bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
#endif
#ifdef ALPHAECOFF
/* FIXME: What does bldrev mean? */
bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
#endif
return sizeof(AOUTHDR);
}
static void
coff_swap_scnhdr_in (abfd, ext, in)
bfd *abfd;
PTR ext;
PTR in;
{
SCNHDR *scnhdr_ext = (SCNHDR *) ext;
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
scnhdr_int->s_vaddr =
GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
scnhdr_int->s_paddr =
GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
scnhdr_int->s_size =
GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
scnhdr_int->s_scnptr =
GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
scnhdr_int->s_relptr =
GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
scnhdr_int->s_lnnoptr =
GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
#if defined(M88)
scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
#else
scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
#endif
#ifdef I960
scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align);
#endif
}
static unsigned int
coff_swap_scnhdr_out (abfd, in, out)
bfd *abfd;
PTR in;
PTR out;
{
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
SCNHDR *scnhdr_ext = (SCNHDR *)out;
memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
(bfd_byte *) scnhdr_ext->s_vaddr);
PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
(bfd_byte *) scnhdr_ext->s_paddr);
PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
(bfd_byte *) scnhdr_ext->s_size);
PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
(bfd_byte *) scnhdr_ext->s_scnptr);
PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
(bfd_byte *) scnhdr_ext->s_relptr);
PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
(bfd_byte *) scnhdr_ext->s_lnnoptr);
PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags);
#if defined(M88)
PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
#else
PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
#endif
#if defined(I960)
PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
#endif
return sizeof(SCNHDR);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,931 @@
/* Intel 80386/80486-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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "libelf.h"
static CONST struct reloc_howto_struct *elf_i386_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static void elf_i386_info_to_howto
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
static void elf_i386_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
static boolean elf_i386_create_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static boolean elf_i386_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
static boolean elf_i386_allocate_dynamic_section
PARAMS ((bfd *, const char *));
static boolean elf_i386_size_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static boolean elf_i386_relocate_section
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **, char *));
static boolean elf_i386_finish_dynamic_symbol
PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
Elf_Internal_Sym *));
static boolean elf_i386_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
#define USE_REL 1 /* 386 uses REL relocations instead of RELA */
enum reloc_type
{
R_386_NONE = 0,
R_386_32,
R_386_PC32,
R_386_GOT32,
R_386_PLT32,
R_386_COPY,
R_386_GLOB_DAT,
R_386_JUMP_SLOT,
R_386_RELATIVE,
R_386_GOTOFF,
R_386_GOTPC,
R_386_max
};
#if 0
static CONST char *CONST reloc_type_names[] =
{
"R_386_NONE",
"R_386_32",
"R_386_PC32",
"R_386_GOT32",
"R_386_PLT32",
"R_386_COPY",
"R_386_GLOB_DAT",
"R_386_JUMP_SLOT",
"R_386_RELATIVE",
"R_386_GOTOFF",
"R_386_GOTPC",
};
#endif
static reloc_howto_type elf_howto_table[]=
{
HOWTO(R_386_NONE, 0,0, 0,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_NONE", true,0x00000000,0x00000000,false),
HOWTO(R_386_32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_32", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_PC32, 0,2,32,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC32", true,0xffffffff,0xffffffff,true),
HOWTO(R_386_GOT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOT32", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_PLT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PLT32", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_COPY, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_COPY", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_GLOB_DAT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GLOB_DAT", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_JUMP_SLOT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_JUMP_SLOT",true,0xffffffff,0xffffffff,false),
HOWTO(R_386_RELATIVE, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_GOTOFF, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false),
HOWTO(R_386_GOTPC, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTPC", true,0xffffffff,0xffffffff,false),
};
#ifdef DEBUG_GEN_RELOC
#define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
#else
#define TRACE(str)
#endif
static CONST struct reloc_howto_struct *
elf_i386_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
{
switch (code)
{
case BFD_RELOC_NONE:
TRACE ("BFD_RELOC_NONE");
return &elf_howto_table[ (int)R_386_NONE ];
case BFD_RELOC_32:
TRACE ("BFD_RELOC_32");
return &elf_howto_table[ (int)R_386_32 ];
case BFD_RELOC_32_PCREL:
TRACE ("BFD_RELOC_PC32");
return &elf_howto_table[ (int)R_386_PC32 ];
case BFD_RELOC_386_GOT32:
TRACE ("BFD_RELOC_386_GOT32");
return &elf_howto_table[ (int)R_386_GOT32 ];
case BFD_RELOC_386_PLT32:
TRACE ("BFD_RELOC_386_PLT32");
return &elf_howto_table[ (int)R_386_PLT32 ];
case BFD_RELOC_386_COPY:
TRACE ("BFD_RELOC_386_COPY");
return &elf_howto_table[ (int)R_386_COPY ];
case BFD_RELOC_386_GLOB_DAT:
TRACE ("BFD_RELOC_386_GLOB_DAT");
return &elf_howto_table[ (int)R_386_GLOB_DAT ];
case BFD_RELOC_386_JUMP_SLOT:
TRACE ("BFD_RELOC_386_JUMP_SLOT");
return &elf_howto_table[ (int)R_386_JUMP_SLOT ];
case BFD_RELOC_386_RELATIVE:
TRACE ("BFD_RELOC_386_RELATIVE");
return &elf_howto_table[ (int)R_386_RELATIVE ];
case BFD_RELOC_386_GOTOFF:
TRACE ("BFD_RELOC_386_GOTOFF");
return &elf_howto_table[ (int)R_386_GOTOFF ];
case BFD_RELOC_386_GOTPC:
TRACE ("BFD_RELOC_386_GOTPC");
return &elf_howto_table[ (int)R_386_GOTPC ];
default:
break;
}
TRACE ("Unknown");
return 0;
}
static void
elf_i386_info_to_howto (abfd, cache_ptr, dst)
bfd *abfd;
arelent *cache_ptr;
Elf32_Internal_Rela *dst;
{
BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
}
static void
elf_i386_info_to_howto_rel (abfd, cache_ptr, dst)
bfd *abfd;
arelent *cache_ptr;
Elf32_Internal_Rel *dst;
{
BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
}
/* Functions for the i386 ELF linker. */
/* The name of the dynamic interpreter. This is put in the .interp
section. */
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
/* The size in bytes of an entry in the procedure linkage table. */
#define PLT_ENTRY_SIZE 16
/* The first entry in an absolute procedure linkage table looks like
this. See the SVR4 ABI i386 supplement to see how this works. */
static bfd_byte elf_i386_plt0_entry[PLT_ENTRY_SIZE] =
{
0xff, 0x35, /* pushl contents of address */
0, 0, 0, 0, /* replaced with address of .got + 4. */
0xff, 0x25, /* jmp indirect */
0, 0, 0, 0, /* replaced with address of .got + 8. */
0, 0, 0, 0 /* pad out to 16 bytes. */
};
/* Subsequent entries in an absolute procedure linkage table look like
this. */
static bfd_byte elf_i386_plt_entry[PLT_ENTRY_SIZE] =
{
0xff, 0x25, /* jmp indirect */
0, 0, 0, 0, /* replaced with address of this symbol in .got. */
0x68, /* pushl immediate */
0, 0, 0, 0, /* replaced with offset into relocation table. */
0xe9, /* jmp relative */
0, 0, 0, 0 /* replaced with offset to start of .plt. */
};
/* Create dynamic sections when linking against a dynamic object. */
static boolean
elf_i386_create_dynamic_sections (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
{
flagword flags;
register asection *s;
struct elf_link_hash_entry *h;
/* We need to create .plt, .rel.plt, .got, .dynbss, and .rel.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_READONLY | SEC_CODE)
|| ! bfd_set_section_alignment (abfd, s, 2))
return false;
s = bfd_make_section (abfd, ".rel.plt");
if (s == NULL
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|| ! bfd_set_section_alignment (abfd, s, 2))
return false;
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;
/* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
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;
/* The first three global offset table entries are reserved. */
s->_raw_size += 3 * 4;
/* 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_386_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.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. If it turns out not to
be needed, we can discard it later. */
s = bfd_make_section (abfd, ".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;
}
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
change the definition to something the rest of the link can
understand. */
static boolean
elf_i386_adjust_dynamic_symbol (info, h)
struct bfd_link_info *info;
struct elf_link_hash_entry *h;
{
bfd *dynobj;
asection *s;
unsigned int power_of_two;
size_t align;
dynobj = elf_hash_table (info)->dynobj;
/* Make sure we know what is going on here. */
BFD_ASSERT (dynobj != NULL
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) != 0
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
&& h->root.type == bfd_link_hash_defined
&& (bfd_get_flavour (h->root.u.def.section->owner)
== bfd_target_elf_flavour)
&& (elf_elfheader (h->root.u.def.section->owner)->e_type
== ET_DYN)
&& h->root.u.def.section->output_section == NULL);
/* If this is a function, put it in the procedure linkage table. We
will fill in the contents of the procedure linkage table later,
when we know the address of the .got section. */
if (h->type == STT_FUNC)
{
s = bfd_get_section_by_name (dynobj, ".plt");
BFD_ASSERT (s != NULL);
/* If this is the first .plt entry, make room for the special
first entry. */
if (s->_raw_size == 0)
s->_raw_size += PLT_ENTRY_SIZE;
/* Set the symbol to this location in the .plt. */
h->root.u.def.section = s;
h->root.u.def.value = s->_raw_size;
/* Make room for this entry. */
s->_raw_size += PLT_ENTRY_SIZE;
/* We also need to make an entry in the .got section. */
s = bfd_get_section_by_name (dynobj, ".got");
BFD_ASSERT (s != NULL);
s->_raw_size += 4;
/* We also need to make an entry in the .rel.plt section. */
s = bfd_get_section_by_name (dynobj, ".rel.plt");
BFD_ASSERT (s != NULL);
s->_raw_size += sizeof (Elf32_External_Rel);
return true;
}
/* If this is a weak symbol, and there is a real definition, the
processor independent code will have arranged for us to see the
real definition first, and we can just use the same value. */
if (h->weakdef != NULL)
{
BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined);
h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value;
h->align = (bfd_size_type) -1;
return true;
}
/* This is a reference to a symbol defined by a dynamic object which
is not a function. We must allocate it in our .dynbss section,
which will become part of the .bss section of the executable.
There will be an entry for this symbol in the .dynsym section.
The dynamic object will contain position independent code, so all
references from the dynamic object to this symbol will go through
the global offset table. The dynamic linker will use the .dynsym
entry to determine the address it must put in the global offset
table, so both the dynamic object and the regular object will
refer to the same memory location for the variable. */
s = bfd_get_section_by_name (dynobj, ".dynbss");
BFD_ASSERT (s != NULL);
/* If the symbol is currently defined in the .bss section of the
dynamic object, then it is OK to simply initialize it to zero.
If the symbol is in some other section, we must generate a
R_386_COPY reloc to tell the dynamic linker to copy the initial
value out of the dynamic object and into the runtime process
image. We need to remember the offset into the .rel.bss section
we are going to use, and we coopt the align field for this
purpose (the align field is only used for common symbols, and
these symbols are always defined). It would be cleaner to use a
new field, but that would waste memory. */
if ((h->root.u.def.section->flags & SEC_LOAD) == 0)
h->align = (bfd_size_type) -1;
else
{
asection *srel;
srel = bfd_get_section_by_name (dynobj, ".rel.bss");
BFD_ASSERT (srel != NULL);
h->align = srel->_raw_size;
srel->_raw_size += sizeof (Elf32_External_Rel);
}
/* We need to figure out the alignment required for this symbol. I
have no idea how ELF linkers handle this. */
switch (h->size)
{
case 0:
case 1:
power_of_two = 0;
align = 1;
break;
case 2:
power_of_two = 1;
align = 2;
break;
case 3:
case 4:
power_of_two = 2;
align = 4;
break;
case 5:
case 6:
case 7:
case 8:
power_of_two = 3;
align = 8;
break;
default:
power_of_two = 4;
align = 16;
break;
}
/* Apply the required alignment. */
s->_raw_size = BFD_ALIGN (s->_raw_size, align);
if (power_of_two > bfd_get_section_alignment (dynobj, s))
{
if (! bfd_set_section_alignment (dynobj, s, power_of_two))
return false;
}
/* Define the symbol as being at this point in the section. */
h->root.u.def.section = s;
h->root.u.def.value = s->_raw_size;
/* Increment the section size to make room for the symbol. */
s->_raw_size += h->size;
return true;
}
/* Allocate contents for a section. */
static INLINE boolean
elf_i386_allocate_dynamic_section (dynobj, name)
bfd *dynobj;
const char *name;
{
register asection *s;
s = bfd_get_section_by_name (dynobj, name);
BFD_ASSERT (s != NULL);
s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
if (s->contents == NULL && s->_raw_size != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return true;
}
/* Set the sizes of the dynamic sections. */
static boolean
elf_i386_size_dynamic_sections (output_bfd, info)
bfd *output_bfd;
struct bfd_link_info *info;
{
bfd *dynobj;
asection *s;
dynobj = elf_hash_table (info)->dynobj;
BFD_ASSERT (dynobj != NULL);
/* Set the contents of the .interp section to the interpreter. */
if (! info->shared)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
}
/* The adjust_dynamic_symbol entry point has determined the sizes of
the various dynamic sections. Allocate some memory for them to
hold contents. */
if (! elf_i386_allocate_dynamic_section (dynobj, ".plt")
|| ! elf_i386_allocate_dynamic_section (dynobj, ".rel.plt")
|| ! elf_i386_allocate_dynamic_section (dynobj, ".got")
|| ! elf_i386_allocate_dynamic_section (dynobj, ".rel.bss"))
return false;
/* Add some entries to the .dynamic section. We fill in the values
later, in elf_i386_finish_dynamic_sections, but we must add the
entries now so that we get the correct size for the .dynamic
section. The DT_DEBUG entry is filled in by the dynamic linker
and used by the debugger. */
if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
return false;
s = bfd_get_section_by_name (dynobj, ".plt");
BFD_ASSERT (s != NULL);
if (s->_raw_size != 0)
{
if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
|| ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
return false;
}
/* If we didn't need the .rel.bss section, then discard it from the
output file. This is a hack. We don't bother to do it for the
other sections because they normally are needed. */
s = bfd_get_section_by_name (dynobj, ".rel.bss");
BFD_ASSERT (s != NULL);
if (s->_raw_size == 0)
{
asection **spp;
for (spp = &s->output_section->owner->sections;
*spp != s->output_section;
spp = &(*spp)->next)
;
*spp = s->output_section->next;
--s->output_section->owner->section_count;
}
else
{
if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
sizeof (Elf32_External_Rel)))
return false;
}
return true;
}
/* Relocate an i386 ELF section. */
static boolean
elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
contents, relocs, local_syms, local_sections,
output_names)
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;
char *output_names;
{
Elf_Internal_Shdr *symtab_hdr;
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
{
int r_type;
const 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 = ELF32_R_TYPE (rel->r_info);
if (r_type < 0 || r_type >= (int) R_386_max)
{
bfd_set_error (bfd_error_bad_value);
return false;
}
howto = elf_howto_table + r_type;
r_symndx = ELF32_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)
{
bfd_vma val;
sec = local_sections[r_symndx];
val = bfd_get_32 (input_bfd, contents + rel->r_offset);
val += sec->output_offset + sym->st_value;
bfd_put_32 (input_bfd, val, contents + rel->r_offset);
}
}
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
{
long indx;
indx = r_symndx - symtab_hdr->sh_info;
h = elf_sym_hashes (input_bfd)[indx];
if (h->root.type == bfd_link_hash_defined)
{
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_weak)
relocation = 0;
else
{
if (! ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd,
input_section, rel->r_offset)))
return false;
relocation = 0;
}
}
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
contents, rel->r_offset,
relocation, (bfd_vma) 0);
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 = output_names + 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;
}
/* Finish up dynamic symbol handling. We set the contents of various
dynamic sections here. */
static boolean
elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym)
bfd *output_bfd;
struct bfd_link_info *info;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
{
/* If this symbol is not defined by a dynamic object, or is not
referenced by a regular object, ignore it. */
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
|| (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|| (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
{
/* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
if (strcmp (h->root.root.string, "_DYNAMIC") == 0
|| strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
sym->st_shndx = SHN_ABS;
return true;
}
BFD_ASSERT (h->root.type == bfd_link_hash_defined);
BFD_ASSERT (h->dynindx != -1);
if (h->type == STT_FUNC)
{
asection *splt;
asection *sgot;
asection *srel;
bfd_vma plt_index;
bfd_vma got_offset;
Elf_Internal_Rel rel;
splt = h->root.u.def.section;
BFD_ASSERT (strcmp (bfd_get_section_name (splt->owner, splt), ".plt")
== 0);
sgot = bfd_get_section_by_name (splt->owner, ".got");
BFD_ASSERT (sgot != NULL);
srel = bfd_get_section_by_name (splt->owner, ".rel.plt");
BFD_ASSERT (srel != NULL);
/* FIXME: This only handles an absolute procedure linkage table.
When producing a dynamic object, we need to generate a
position independent procedure linkage table. */
/* Get the index in the procedure linkage table which
corresponds to this symbol. This is the index of this symbol
in all the symbols for which we are making plt entries. The
first entry in the procedure linkage table is reserved. */
plt_index = h->root.u.def.value / PLT_ENTRY_SIZE - 1;
/* Get the offset into the .got table of the entry that
corresponds to this function. Each .got entry is 4 bytes.
The first three are reserved. */
got_offset = (plt_index + 3) * 4;
/* Fill in the entry in the procedure linkage table. */
memcpy (splt->contents + h->root.u.def.value, elf_i386_plt_entry,
PLT_ENTRY_SIZE);
bfd_put_32 (output_bfd,
(sgot->output_section->vma
+ sgot->output_offset
+ got_offset),
splt->contents + h->root.u.def.value + 2);
bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel),
splt->contents + h->root.u.def.value + 7);
bfd_put_32 (output_bfd, - (h->root.u.def.value + PLT_ENTRY_SIZE),
splt->contents + h->root.u.def.value + 12);
/* Fill in the entry in the global offset table. */
bfd_put_32 (output_bfd,
(splt->output_section->vma
+ splt->output_offset
+ h->root.u.def.value
+ 6),
sgot->contents + got_offset);
/* Fill in the entry in the .rel.plt section. */
rel.r_offset = (sgot->output_section->vma
+ sgot->output_offset
+ got_offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT);
bfd_elf32_swap_reloc_out (output_bfd, &rel,
((Elf32_External_Rel *) srel->contents
+ plt_index));
/* Mark the symbol as undefined, rather than as defined in the
.plt section. Leave the value alone. */
sym->st_shndx = SHN_UNDEF;
}
else
{
/* This is not a function. We have already allocated memory for
it in the .bss section (via .dynbss). All we have to do here
is create a COPY reloc if required. */
if (h->align != (bfd_size_type) -1)
{
asection *s;
Elf_Internal_Rel rel;
s = bfd_get_section_by_name (h->root.u.def.section->owner,
".rel.bss");
BFD_ASSERT (s != NULL);
rel.r_offset = (h->root.u.def.value
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
bfd_elf32_swap_reloc_out (output_bfd, &rel,
((Elf32_External_Rel *)
(s->contents + h->align)));
}
}
return true;
}
/* Finish up the dynamic sections. */
static boolean
elf_i386_finish_dynamic_sections (output_bfd, info)
bfd *output_bfd;
struct bfd_link_info *info;
{
asection *splt;
asection *sgot;
asection *sdyn;
Elf32_External_Dyn *dyncon, *dynconend;
splt = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".plt");
sgot = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".got");
sdyn = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".dynamic");
BFD_ASSERT (splt != NULL && sgot != NULL && sdyn != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
for (; dyncon < dynconend; dyncon++)
{
Elf_Internal_Dyn dyn;
const char *name;
boolean size;
bfd_elf32_swap_dyn_in (elf_hash_table (info)->dynobj, dyncon, &dyn);
/* My reading of the SVR4 ABI indicates that the procedure
linkage table relocs (DT_JMPREL) should be included in the
overall relocs (DT_REL). This is what Solaris does.
However, UnixWare can not handle that case. Therefore, we
override the DT_REL and DT_RELSZ entries here to make them
not include the JMPREL relocs. */
switch (dyn.d_tag)
{
case DT_PLTGOT: name = ".got"; size = false; break;
case DT_PLTRELSZ: name = ".rel.plt"; size = true; break;
case DT_JMPREL: name = ".rel.plt"; size = false; break;
case DT_REL: name = ".rel.bss"; size = false; break;
case DT_RELSZ: name = ".rel.bss"; size = true; break;
default: name = NULL; size = false; break;
}
if (name != NULL)
{
asection *s;
s = bfd_get_section_by_name (output_bfd, name);
BFD_ASSERT (s != NULL);
if (! size)
dyn.d_un.d_ptr = s->vma;
else
{
if (s->_cooked_size != 0)
dyn.d_un.d_val = s->_cooked_size;
else
dyn.d_un.d_val = s->_raw_size;
}
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
}
}
/* Fill in the first entry in the procedure linkage table. */
if (splt->_raw_size > 0)
{
memcpy (splt->contents, elf_i386_plt0_entry, PLT_ENTRY_SIZE);
bfd_put_32 (output_bfd,
sgot->output_section->vma + sgot->output_offset + 4,
splt->contents + 2);
bfd_put_32 (output_bfd,
sgot->output_section->vma + sgot->output_offset + 8,
splt->contents + 8);
}
/* Fill in the first three entries in the global offset table. */
if (sgot->_raw_size > 0)
{
bfd_put_32 (output_bfd,
sdyn->output_section->vma + sdyn->output_offset,
sgot->contents);
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
}
elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
/* UnixWare sets the entsize of .plt to 4, although that doesn't
really seem like the right value. */
elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
return true;
}
#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
#define TARGET_LITTLE_NAME "elf32-i386"
#define ELF_ARCH bfd_arch_i386
#define ELF_MACHINE_CODE EM_386
#define elf_info_to_howto elf_i386_info_to_howto
#define elf_info_to_howto_rel elf_i386_info_to_howto_rel
#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
#define ELF_MAXPAGESIZE 0x1000
#define elf_backend_create_dynamic_sections \
elf_i386_create_dynamic_sections
#define elf_backend_adjust_dynamic_symbol \
elf_i386_adjust_dynamic_symbol
#define elf_backend_size_dynamic_sections \
elf_i386_size_dynamic_sections
#define elf_backend_relocate_section elf_i386_relocate_section
#define elf_backend_finish_dynamic_symbol \
elf_i386_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections \
elf_i386_finish_dynamic_sections
#include "elf32-target.h"

View File

@ -0,0 +1,358 @@
/* Target definitions for 32-bit ELF
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., 675 Mass Ave, Cambridge, MA 02139, 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_elf32_close_and_cleanup _bfd_generic_close_and_cleanup
#define bfd_elf32_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#ifndef bfd_elf32_get_section_contents
#define bfd_elf32_get_section_contents _bfd_generic_get_section_contents
#endif
#define bfd_elf32_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define bfd_elf32_bfd_relax_section bfd_generic_relax_section
#define bfd_elf32_bfd_make_debug_symbol \
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
#ifndef bfd_elf32_bfd_copy_private_section_data
#define bfd_elf32_bfd_copy_private_section_data \
((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
#endif
#ifndef bfd_elf32_bfd_copy_private_bfd_data
#define bfd_elf32_bfd_copy_private_bfd_data \
((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
#endif
#ifndef bfd_elf32_bfd_is_local_label
#define bfd_elf32_bfd_is_local_label bfd_generic_is_local_label
#endif
#ifndef bfd_elf32_get_dynamic_reloc_upper_bound
#define bfd_elf32_get_dynamic_reloc_upper_bound \
_bfd_nodynamic_get_dynamic_reloc_upper_bound
#endif
#ifndef bfd_elf32_canonicalize_dynamic_reloc
#define bfd_elf32_canonicalize_dynamic_reloc \
_bfd_nodynamic_canonicalize_dynamic_reloc
#endif
#ifdef elf_backend_relocate_section
#ifndef bfd_elf32_bfd_link_hash_table_create
#define bfd_elf32_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_elf32_bfd_link_hash_table_create
#define bfd_elf32_bfd_link_hash_table_create \
_bfd_generic_link_hash_table_create
#endif
#ifndef bfd_elf32_bfd_link_add_symbols
#define bfd_elf32_bfd_link_add_symbols _bfd_generic_link_add_symbols
#endif
#ifndef bfd_elf32_bfd_final_link
#define bfd_elf32_bfd_final_link _bfd_generic_final_link
#endif
#endif /* ! defined (elf_backend_relocate_section) */
#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_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_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_ecoff_debug_swap
#define elf_backend_ecoff_debug_swap 0
#endif
static CONST struct elf_backend_data elf32_bed =
{
#ifdef USE_REL
0, /* use_rela_p */
#else
1, /* use_rela_p */
#endif
0, /* elf_64_p */
ELF_ARCH, /* arch */
ELF_MACHINE_CODE, /* elf_machine_code */
ELF_MAXPAGESIZE, /* maxpagesize */
elf_backend_collect,
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_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_ecoff_debug_swap
};
#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_big_p: data is big endian */
true,
/* header_byteorder_big_p: header is also big endian */
true,
/* 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),
/* leading_symbol_char: is the first char of a user symbol
predictable, and if so what is it */
0,
/* 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,
/* align_power_min: minimum alignment restriction for any section
FIXME: this value may be target machine dependent */
3,
/* 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_elf32_object_p, /* assembler/linker output (object file) */
bfd_generic_archive_p, /* an archive */
bfd_elf32_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_elf32_write_object_contents,
_bfd_write_archive_contents,
bfd_false
},
BFD_JUMP_TABLE_GENERIC (bfd_elf32),
BFD_JUMP_TABLE_COPY (bfd_elf32),
BFD_JUMP_TABLE_CORE (bfd_elf32),
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
BFD_JUMP_TABLE_SYMBOLS (bfd_elf32),
BFD_JUMP_TABLE_RELOCS (bfd_elf32),
BFD_JUMP_TABLE_WRITE (bfd_elf32),
BFD_JUMP_TABLE_LINK (bfd_elf32),
BFD_JUMP_TABLE_DYNAMIC (bfd_elf32),
/* backend_data: */
(PTR) &elf32_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_big_p: data is big endian */
false, /* Nope -- this one's little endian */
/* header_byteorder_big_p: header is also big endian */
false, /* Nope -- this one's little endian */
/* 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),
/* leading_symbol_char: is the first char of a user symbol
predictable, and if so what is it */
0,
/* 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,
/* align_power_min: minimum alignment restriction for any section
FIXME: this value may be target machine dependent */
3,
/* 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_elf32_object_p, /* assembler/linker output (object file) */
bfd_generic_archive_p, /* an archive */
bfd_elf32_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_elf32_write_object_contents,
_bfd_write_archive_contents,
bfd_false
},
BFD_JUMP_TABLE_GENERIC (bfd_elf32),
BFD_JUMP_TABLE_COPY (bfd_elf32),
BFD_JUMP_TABLE_CORE (bfd_elf32),
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
BFD_JUMP_TABLE_SYMBOLS (bfd_elf32),
BFD_JUMP_TABLE_RELOCS (bfd_elf32),
BFD_JUMP_TABLE_WRITE (bfd_elf32),
BFD_JUMP_TABLE_LINK (bfd_elf32),
BFD_JUMP_TABLE_DYNAMIC (bfd_elf32),
/* backend_data: */
(PTR) &elf32_bed,
};
#endif

View File

@ -0,0 +1,23 @@
/* 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define ARCH_SIZE 32
#include "elfcode.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
/* genlink.h -- interface to the BFD generic linker
Copyright 1993, 1994 Free Software Foundation, Inc.
Written 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef GENLINK_H
#define GENLINK_H
/* This header file is internal to BFD. It describes the internal
structures and functions used by the BFD generic linker, in case
any of the more specific linkers want to use or call them. Note
that some functions, such as _bfd_generic_link_hash_table_create,
are declared in libbfd.h, because they are expected to be widely
used. The functions and structures in this file will probably only
be used by a few files besides linker.c itself. In fact, this file
is not particularly complete; I have only put in the interfaces I
actually needed. */
/* The generic linker uses a hash table which is a derived class of
the standard linker hash table, just as the other backend specific
linkers do. Do not confuse the generic linker hash table with the
standard BFD linker hash table it is built upon. */
/* Generic linker hash table entries. */
struct generic_link_hash_entry
{
struct bfd_link_hash_entry root;
/* Whether this symbol has been written out. */
boolean written;
/* Symbol from input BFD. */
asymbol *sym;
};
/* Generic linker hash table. */
struct generic_link_hash_table
{
struct bfd_link_hash_table root;
};
/* Look up an entry in an generic link hash table. */
#define _bfd_generic_link_hash_lookup(table, string, create, copy, follow) \
((struct generic_link_hash_entry *) \
bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
/* Traverse an generic link hash table. */
#define _bfd_generic_link_hash_traverse(table, func, info) \
(bfd_link_hash_traverse \
(&(table)->root, \
(boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
(info)))
/* Get the generic link hash table from the info structure. This is
just a cast. */
#define _bfd_generic_hash_table(p) \
((struct generic_link_hash_table *) ((p)->hash))
/* The generic linker reads in the asymbol structures for an input BFD
and keeps them in the outsymbol and symcount fields. */
#define _bfd_generic_link_get_symbols(abfd) ((abfd)->outsymbols)
#define _bfd_generic_link_get_symcount(abfd) ((abfd)->symcount)
/* Add the symbols of input_bfd to the symbols being built for
output_bfd. */
extern boolean _bfd_generic_link_output_symbols
PARAMS ((bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *,
size_t *psymalloc));
/* This structure is used to pass information to
_bfd_generic_link_write_global_symbol, which may be called via
_bfd_generic_link_hash_traverse. */
struct generic_write_global_symbol_info
{
struct bfd_link_info *info;
bfd *output_bfd;
size_t *psymalloc;
};
/* Write out a single global symbol. This is expected to be called
via _bfd_generic_link_hash_traverse. The second argument must
actually be a struct generic_write_global_symbol_info *. */
extern boolean _bfd_generic_link_write_global_symbol
PARAMS ((struct generic_link_hash_entry *, PTR));
#endif

470
gnu/usr.bin/gdb/bfd/hash.c Normal file
View File

@ -0,0 +1,470 @@
/* hash.c -- hash table routines for BFD
Copyright (C) 1993, 94 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "obstack.h"
/*
SECTION
Hash Tables
@cindex Hash tables
BFD provides a simple set of hash table functions. Routines
are provided to initialize a hash table, to free a hash table,
to look up a string in a hash table and optionally create an
entry for it, and to traverse a hash table. There is
currently no routine to delete an string from a hash table.
The basic hash table does not permit any data to be stored
with a string. However, a hash table is designed to present a
base class from which other types of hash tables may be
derived. These derived types may store additional information
with the string. Hash tables were implemented in this way,
rather than simply providing a data pointer in a hash table
entry, because they were designed for use by the linker back
ends. The linker may create thousands of hash table entries,
and the overhead of allocating private data and storing and
following pointers becomes noticeable.
The basic hash table code is in <<hash.c>>.
@menu
@* Creating and Freeing a Hash Table::
@* Looking Up or Entering a String::
@* Traversing a Hash Table::
@* Deriving a New Hash Table Type::
@end menu
INODE
Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables
SUBSECTION
Creating and freeing a hash table
@findex bfd_hash_table_init
@findex bfd_hash_table_init_n
To create a hash table, create an instance of a <<struct
bfd_hash_table>> (defined in <<bfd.h>>) and call
<<bfd_hash_table_init>> (if you know approximately how many
entries you will need, the function <<bfd_hash_table_init_n>>,
which takes a @var{size} argument, may be used).
<<bfd_hash_table_init>> returns <<false>> if some sort of
error occurs.
@findex bfd_hash_newfunc
The function <<bfd_hash_table_init>> take as an argument a
function to use to create new entries. For a basic hash
table, use the function <<bfd_hash_newfunc>>. @xref{Deriving
a New Hash Table Type} for why you would want to use a
different value for this argument.
@findex bfd_hash_allocate
<<bfd_hash_table_init>> will create an obstack which will be
used to allocate new entries. You may allocate memory on this
obstack using <<bfd_hash_allocate>>.
@findex bfd_hash_table_free
Use <<bfd_hash_table_free>> to free up all the memory that has
been allocated for a hash table. This will not free up the
<<struct bfd_hash_table>> itself, which you must provide.
INODE
Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables
SUBSECTION
Looking up or entering a string
@findex bfd_hash_lookup
The function <<bfd_hash_lookup>> is used both to look up a
string in the hash table and to create a new entry.
If the @var{create} argument is <<false>>, <<bfd_hash_lookup>>
will look up a string. If the string is found, it will
returns a pointer to a <<struct bfd_hash_entry>>. If the
string is not found in the table <<bfd_hash_lookup>> will
return <<NULL>>. You should not modify any of the fields in
the returns <<struct bfd_hash_entry>>.
If the @var{create} argument is <<true>>, the string will be
entered into the hash table if it is not already there.
Either way a pointer to a <<struct bfd_hash_entry>> will be
returned, either to the existing structure or to a newly
created one. In this case, a <<NULL>> return means that an
error occurred.
If the @var{create} argument is <<true>>, and a new entry is
created, the @var{copy} argument is used to decide whether to
copy the string onto the hash table obstack or not. If
@var{copy} is passed as <<false>>, you must be careful not to
deallocate or modify the string as long as the hash table
exists.
INODE
Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables
SUBSECTION
Traversing a hash table
@findex bfd_hash_traverse
The function <<bfd_hash_traverse>> may be used to traverse a
hash table, calling a function on each element. The traversal
is done in a random order.
<<bfd_hash_traverse>> takes as arguments a function and a
generic <<void *>> pointer. The function is called with a
hash table entry (a <<struct bfd_hash_entry *>>) and the
generic pointer passed to <<bfd_hash_traverse>>. The function
must return a <<boolean>> value, which indicates whether to
continue traversing the hash table. If the function returns
<<false>>, <<bfd_hash_traverse>> will stop the traversal and
return immediately.
INODE
Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables
SUBSECTION
Deriving a new hash table type
Many uses of hash tables want to store additional information
which each entry in the hash table. Some also find it
convenient to store additional information with the hash table
itself. This may be done using a derived hash table.
Since C is not an object oriented language, creating a derived
hash table requires sticking together some boilerplate
routines with a few differences specific to the type of hash
table you want to create.
An example of a derived hash table is the linker hash table.
The structures for this are defined in <<bfdlink.h>>. The
functions are in <<linker.c>>.
You may also derive a hash table from an already derived hash
table. For example, the a.out linker backend code uses a hash
table derived from the linker hash table.
@menu
@* Define the Derived Structures::
@* Write the Derived Creation Routine::
@* Write Other Derived Routines::
@end menu
INODE
Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type
SUBSUBSECTION
Define the derived structures
You must define a structure for an entry in the hash table,
and a structure for the hash table itself.
The first field in the structure for an entry in the hash
table must be of the type used for an entry in the hash table
you are deriving from. If you are deriving from a basic hash
table this is <<struct bfd_hash_entry>>, which is defined in
<<bfd.h>>. The first field in the structure for the hash
table itself must be of the type of the hash table you are
deriving from itself. If you are deriving from a basic hash
table, this is <<struct bfd_hash_table>>.
For example, the linker hash table defines <<struct
bfd_link_hash_entry>> (in <<bfdlink.h>>). The first field,
<<root>>, is of type <<struct bfd_hash_entry>>. Similarly,
the first field in <<struct bfd_link_hash_table>>, <<table>>,
is of type <<struct bfd_hash_table>>.
INODE
Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type
SUBSUBSECTION
Write the derived creation routine
You must write a routine which will create and initialize an
entry in the hash table. This routine is passed as the
function argument to <<bfd_hash_table_init>>.
In order to permit other hash tables to be derived from the
hash table you are creating, this routine must be written in a
standard way.
The first argument to the creation routine is a pointer to a
hash table entry. This may be <<NULL>>, in which case the
routine should allocate the right amount of space. Otherwise
the space has already been allocated by a hash table type
derived from this one.
After allocating space, the creation routine must call the
creation routine of the hash table type it is derived from,
passing in a pointer to the space it just allocated. This
will initialize any fields used by the base hash table.
Finally the creation routine must initialize any local fields
for the new hash table type.
Here is a boilerplate example of a creation routine.
@var{function_name} is the name of the routine.
@var{entry_type} is the type of an entry in the hash table you
are creating. @var{base_newfunc} is the name of the creation
routine of the hash table type your hash table is derived
from.
EXAMPLE
.struct bfd_hash_entry *
.@var{function_name} (entry, table, string)
. struct bfd_hash_entry *entry;
. struct bfd_hash_table *table;
. const char *string;
.{
. struct @var{entry_type} *ret = (@var{entry_type} *) entry;
.
. {* Allocate the structure if it has not already been allocated by a
. derived class. *}
. if (ret == (@var{entry_type} *) NULL)
. {
. ret = ((@var{entry_type} *)
. bfd_hash_allocate (table, sizeof (@var{entry_type})));
. if (ret == (@var{entry_type} *) NULL)
. return NULL;
. }
.
. {* Call the allocation method of the base class. *}
. ret = ((@var{entry_type} *)
. @var{base_newfunc} ((struct bfd_hash_entry *) ret, table, string));
.
. {* Initialize the local fields here. *}
.
. return (struct bfd_hash_entry *) ret;
.}
DESCRIPTION
The creation routine for the linker hash table, which is in
<<linker.c>>, looks just like this example.
@var{function_name} is <<_bfd_link_hash_newfunc>>.
@var{entry_type} is <<struct bfd_link_hash_entry>>.
@var{base_newfunc} is <<bfd_hash_newfunc>>, the creation
routine for a basic hash table.
<<_bfd_link_hash_newfunc>> also initializes the local fields
in a linker hash table entry: <<type>>, <<written>> and
<<next>>.
INODE
Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type
SUBSUBSECTION
Write other derived routines
You will want to write other routines for your new hash table,
as well.
You will want an initialization routine which calls the
initialization routine of the hash table you are deriving from
and initializes any other local fields. For the linker hash
table, this is <<_bfd_link_hash_table_init>> in <<linker.c>>.
You will want a lookup routine which calls the lookup routine
of the hash table you are deriving from and casts the result.
The linker hash table uses <<bfd_link_hash_lookup>> in
<<linker.c>> (this actually takes an additional argument which
it uses to decide how to return the looked up value).
You may want a traversal routine. This should just call the
traversal routine of the hash table you are deriving from with
appropriate casts. The linker hash table uses
<<bfd_link_hash_traverse>> in <<linker.c>>.
These routines may simply be defined as macros. For example,
the a.out backend linker hash table, which is derived from the
linker hash table, uses macros for the lookup and traversal
routines. These are <<aout_link_hash_lookup>> and
<<aout_link_hash_traverse>> in aoutx.h.
*/
/* Obstack allocation and deallocation routines. */
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
/* The default number of entries to use when creating a hash table. */
#define DEFAULT_SIZE (4051)
/* Create a new hash table, given a number of entries. */
boolean
bfd_hash_table_init_n (table, newfunc, size)
struct bfd_hash_table *table;
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *));
unsigned int size;
{
unsigned int alloc;
alloc = size * sizeof (struct bfd_hash_entry *);
if (!obstack_begin (&table->memory, alloc))
{
bfd_set_error (bfd_error_no_memory);
return false;
}
table->table = ((struct bfd_hash_entry **)
obstack_alloc (&table->memory, alloc));
if (!table->table)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
memset ((PTR) table->table, 0, alloc);
table->size = size;
table->newfunc = newfunc;
return true;
}
/* Create a new hash table with the default number of entries. */
boolean
bfd_hash_table_init (table, newfunc)
struct bfd_hash_table *table;
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *));
{
return bfd_hash_table_init_n (table, newfunc, DEFAULT_SIZE);
}
/* Free a hash table. */
void
bfd_hash_table_free (table)
struct bfd_hash_table *table;
{
obstack_free (&table->memory, (PTR) NULL);
}
/* Look up a string in a hash table. */
struct bfd_hash_entry *
bfd_hash_lookup (table, string, create, copy)
struct bfd_hash_table *table;
const char *string;
boolean create;
boolean copy;
{
register const unsigned char *s;
register unsigned long hash;
register unsigned int c;
struct bfd_hash_entry *hashp;
unsigned int len;
unsigned int index;
hash = 0;
len = 0;
s = (const unsigned char *) string;
while ((c = *s++) != '\0')
{
hash += c + (c << 17);
hash ^= hash >> 2;
++len;
}
hash += len + (len << 17);
hash ^= hash >> 2;
index = hash % table->size;
for (hashp = table->table[index];
hashp != (struct bfd_hash_entry *) NULL;
hashp = hashp->next)
{
if (hashp->hash == hash
&& strcmp (hashp->string, string) == 0)
return hashp;
}
if (! create)
return (struct bfd_hash_entry *) NULL;
hashp = (*table->newfunc) ((struct bfd_hash_entry *) NULL, table, string);
if (hashp == (struct bfd_hash_entry *) NULL)
return (struct bfd_hash_entry *) NULL;
if (copy)
{
char *new;
new = (char *) obstack_alloc (&table->memory, len + 1);
if (!new)
{
bfd_set_error (bfd_error_no_memory);
return (struct bfd_hash_entry *) NULL;
}
strcpy (new, string);
string = new;
}
hashp->string = string;
hashp->hash = hash;
hashp->next = table->table[index];
table->table[index] = hashp;
return hashp;
}
/* Base method for creating a new hash table entry. */
/*ARGSUSED*/
struct bfd_hash_entry *
bfd_hash_newfunc (entry, table, string)
struct bfd_hash_entry *entry;
struct bfd_hash_table *table;
const char *string;
{
if (entry == (struct bfd_hash_entry *) NULL)
entry = ((struct bfd_hash_entry *)
bfd_hash_allocate (table, sizeof (struct bfd_hash_entry)));
return entry;
}
/* Allocate space in a hash table. */
PTR
bfd_hash_allocate (table, size)
struct bfd_hash_table *table;
unsigned int size;
{
PTR ret;
ret = obstack_alloc (&table->memory, size);
if (ret == NULL && size != 0)
bfd_set_error (bfd_error_no_memory);
return ret;
}
/* Traverse a hash table. */
void
bfd_hash_traverse (table, func, info)
struct bfd_hash_table *table;
boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR));
PTR info;
{
unsigned int i;
for (i = 0; i < table->size; i++)
{
struct bfd_hash_entry *p;
for (p = table->table[i]; p != NULL; p = p->next)
{
if (! (*func) (p, info))
return;
}
}
}

View File

@ -0,0 +1,68 @@
/* BFD back-end for i386 a.out binaries.
Copyright 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* The only 386 aout system we have here is GO32 from DJ.
These numbers make BFD work with that. If your aout 386 system
doesn't work with these, we'll have to split them into different
files. Send me (sac@cygnus.com) the runes to make it work on your
system, and I'll stick it in for the next release. */
#define N_HEADER_IN_TEXT(x) 0
#define BYTES_IN_WORD 4
#define N_TXTOFF(x) 0x20
#define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
#define N_TXTSIZE(x) ((x).a_text)
#if 0
#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
#define NOSUBEXECB
#endif
#define PAGE_SIZE 4096
#define SEGMENT_SIZE 0x400000
#define DEFAULT_ARCH bfd_arch_i386
#define MY(OP) CAT(i386aout_,OP)
#define TARGETNAME "a.out-i386"
#define NO_WRITE_HEADER_KLUDGE 1
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "libaout.h"
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"

2442
gnu/usr.bin/gdb/bfd/linker.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,521 @@
/* Annotation routines for GDB.
Copyright 1986, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "annotate.h"
#include "value.h"
#include "target.h"
#include "gdbtypes.h"
static void print_value_flags PARAMS ((struct type *));
static void
print_value_flags (t)
struct type *t;
{
if (can_dereference (t))
printf_filtered ("*");
else
printf_filtered ("-");
}
void
breakpoints_changed ()
{
if (annotation_level > 1)
{
target_terminal_ours ();
printf_unfiltered ("\n\032\032breakpoints-invalid\n");
}
}
void
annotate_breakpoint (num)
int num;
{
if (annotation_level > 1)
printf_filtered ("\n\032\032breakpoint %d\n", num);
}
void
annotate_watchpoint (num)
int num;
{
if (annotation_level > 1)
printf_filtered ("\n\032\032watchpoint %d\n", num);
}
void
annotate_starting ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032starting\n");
}
void
annotate_stopped ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032stopped\n");
}
void
annotate_exited (exitstatus)
int exitstatus;
{
if (annotation_level > 1)
printf_filtered ("\n\032\032exited %d\n", exitstatus);
}
void
annotate_signalled ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signalled\n");
}
void
annotate_signal_name ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signal-name\n");
}
void
annotate_signal_name_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signal-name-end\n");
}
void
annotate_signal_string ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signal-string\n");
}
void
annotate_signal_string_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signal-string-end\n");
}
void
annotate_signal ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signal\n");
}
void
annotate_breakpoints_headers ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032breakpoints-headers\n");
}
void
annotate_field (num)
int num;
{
if (annotation_level > 1)
printf_filtered ("\n\032\032field %d\n", num);
}
void
annotate_breakpoints_table ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032breakpoints-table\n");
}
void
annotate_record ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032record\n");
}
void
annotate_breakpoints_table_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032breakpoints-table-end\n");
}
void
annotate_frames_invalid ()
{
if (annotation_level > 1)
{
target_terminal_ours ();
printf_unfiltered ("\n\032\032frames-invalid\n");
}
}
void
annotate_field_begin (type)
struct type *type;
{
if (annotation_level > 1)
{
printf_filtered ("\n\032\032field-begin ");
print_value_flags (type);
printf_filtered ("\n");
}
}
void
annotate_field_name_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032field-name-end\n");
}
void
annotate_field_value ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032field-value\n");
}
void
annotate_field_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032field-end\n");
}
void
annotate_quit ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032quit\n");
}
void
annotate_error ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032error\n");
}
void
annotate_error_begin ()
{
if (annotation_level > 1)
fprintf_filtered (gdb_stderr, "\n\032\032error-begin\n");
}
void
annotate_value_history_begin (histindex, type)
int histindex;
struct type *type;
{
if (annotation_level > 1)
{
printf_filtered ("\n\032\032value-history-begin %d ", histindex);
print_value_flags (type);
printf_filtered ("\n");
}
}
void
annotate_value_begin (type)
struct type *type;
{
if (annotation_level > 1)
{
printf_filtered ("\n\032\032value-begin ");
print_value_flags (type);
printf_filtered ("\n");
}
}
void
annotate_value_history_value ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032value-history-value\n");
}
void
annotate_value_history_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032value-history-end\n");
}
void
annotate_value_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032value-end\n");
}
void
annotate_display_begin ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-begin\n");
}
void
annotate_display_number_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-number-end\n");
}
void
annotate_display_format ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-format\n");
}
void
annotate_display_expression ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-expression\n");
}
void
annotate_display_expression_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-expression-end\n");
}
void
annotate_display_value ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-value\n");
}
void
annotate_display_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032display-end\n");
}
void
annotate_arg_begin ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032arg-begin\n");
}
void
annotate_arg_name_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032arg-name-end\n");
}
void
annotate_arg_value (type)
struct type *type;
{
if (annotation_level > 1)
{
printf_filtered ("\n\032\032arg-value ");
print_value_flags (type);
printf_filtered ("\n");
}
}
void
annotate_arg_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032arg-end\n");
}
void
annotate_source (filename, line, character, mid, pc)
char *filename;
int line;
int character;
int mid;
CORE_ADDR pc;
{
if (annotation_level > 1)
printf_filtered ("\n\032\032source ");
else
printf_filtered ("\032\032");
printf_filtered ("%s:%d:%d:%s:", filename,
line, character,
mid ? "middle" : "beg");
print_address_numeric (pc, 0, gdb_stdout);
printf_filtered ("\n");
}
void
annotate_frame_begin (level, pc)
int level;
CORE_ADDR pc;
{
if (annotation_level > 1)
{
printf_filtered ("\n\032\032frame-begin %d ", level);
print_address_numeric (pc, 0, gdb_stdout);
printf_filtered ("\n");
}
}
void
annotate_function_call ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032function-call\n");
}
void
annotate_signal_handler_caller ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032signal-handler-caller\n");
}
void
annotate_frame_address ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-address\n");
}
void
annotate_frame_address_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-address-end\n");
}
void
annotate_frame_function_name ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-function-name\n");
}
void
annotate_frame_args ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-args\n");
}
void
annotate_frame_source_begin ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-source-begin\n");
}
void
annotate_frame_source_file ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-source-file\n");
}
void
annotate_frame_source_file_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-source-file-end\n");
}
void
annotate_frame_source_line ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-source-line\n");
}
void
annotate_frame_source_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-source-end\n");
}
void
annotate_frame_where ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-where\n");
}
void
annotate_frame_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032frame-end\n");
}
void
annotate_array_section_begin (index, elttype)
int index;
struct type *elttype;
{
if (annotation_level > 1)
{
printf_filtered ("\n\032\032array-section-begin %d ", index);
print_value_flags (elttype);
printf_filtered ("\n");
}
}
void
annotate_elt_rep (repcount)
unsigned int repcount;
{
if (annotation_level > 1)
printf_filtered ("\n\032\032elt-rep %u\n", repcount);
}
void
annotate_elt_rep_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032elt-rep-end\n");
}
void
annotate_elt ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032elt\n");
}
void
annotate_array_section_end ()
{
if (annotation_level > 1)
printf_filtered ("\n\032\032array-section-end\n");
}

View File

@ -0,0 +1,95 @@
/* Annotation routines for GDB.
Copyright 1986, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
extern void breakpoints_changed PARAMS ((void));
extern void annotate_breakpoint PARAMS ((int));
extern void annotate_watchpoint PARAMS ((int));
extern void annotate_starting PARAMS ((void));
extern void annotate_stopped PARAMS ((void));
extern void annotate_exited PARAMS ((int));
extern void annotate_signalled PARAMS ((void));
extern void annotate_signal_name PARAMS ((void));
extern void annotate_signal_name_end PARAMS ((void));
extern void annotate_signal_string PARAMS ((void));
extern void annotate_signal_string_end PARAMS ((void));
extern void annotate_signal PARAMS ((void));
extern void annotate_breakpoints_headers PARAMS ((void));
extern void annotate_field PARAMS ((int));
extern void annotate_breakpoints_table PARAMS ((void));
extern void annotate_record PARAMS ((void));
extern void annotate_breakpoints_table_end PARAMS ((void));
extern void annotate_frames_invalid PARAMS ((void));
#ifdef __STDC__
struct type;
#endif
extern void annotate_field_begin PARAMS ((struct type *));
extern void annotate_field_name_end PARAMS ((void));
extern void annotate_field_value PARAMS ((void));
extern void annotate_field_end PARAMS ((void));
extern void annotate_quit PARAMS ((void));
extern void annotate_error PARAMS ((void));
extern void annotate_error_begin PARAMS ((void));
extern void annotate_value_history_begin PARAMS ((int, struct type *));
extern void annotate_value_begin PARAMS ((struct type *));
extern void annotate_value_history_value PARAMS ((void));
extern void annotate_value_history_end PARAMS ((void));
extern void annotate_value_end PARAMS ((void));
extern void annotate_display_begin PARAMS ((void));
extern void annotate_display_number_end PARAMS ((void));
extern void annotate_display_format PARAMS ((void));
extern void annotate_display_expression PARAMS ((void));
extern void annotate_display_expression_end PARAMS ((void));
extern void annotate_display_value PARAMS ((void));
extern void annotate_display_end PARAMS ((void));
extern void annotate_arg_begin PARAMS ((void));
extern void annotate_arg_name_end PARAMS ((void));
extern void annotate_arg_value PARAMS ((struct type *));
extern void annotate_arg_end PARAMS ((void));
extern void annotate_source PARAMS ((char *, int, int, int, CORE_ADDR));
extern void annotate_frame_begin PARAMS ((int, CORE_ADDR));
extern void annotate_function_call PARAMS ((void));
extern void annotate_signal_handler_caller PARAMS ((void));
extern void annotate_frame_address PARAMS ((void));
extern void annotate_frame_address_end PARAMS ((void));
extern void annotate_frame_function_name PARAMS ((void));
extern void annotate_frame_args PARAMS ((void));
extern void annotate_frame_source_begin PARAMS ((void));
extern void annotate_frame_source_file PARAMS ((void));
extern void annotate_frame_source_file_end PARAMS ((void));
extern void annotate_frame_source_line PARAMS ((void));
extern void annotate_frame_source_end PARAMS ((void));
extern void annotate_frame_where PARAMS ((void));
extern void annotate_frame_end PARAMS ((void));
extern void annotate_array_section_begin PARAMS ((int, struct type *));
extern void annotate_elt_rep PARAMS ((unsigned int));
extern void annotate_elt_rep_end PARAMS ((void));
extern void annotate_elt PARAMS ((void));
extern void annotate_array_section_end PARAMS ((void));

View File

@ -0,0 +1,135 @@
/* Yet Another Try at encapsulating bsd object files in coff.
Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
Written by Pace Willisson 12/9/88
This file is obsolete. It needs to be converted to just define a bunch
of stuff that BFD can use to do coff-encapsulated files. --gnu@cygnus.com
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* We only use the coff headers to tell the kernel
* how to exec the file. Therefore, the only fields that need to
* be filled in are the scnptr and vaddr for the text and data
* sections, and the vaddr for the bss. As far as coff is concerned,
* there is no symbol table, relocation, or line numbers.
*
* A normal bsd header (struct exec) is placed after the coff headers,
* and before the real text. I defined a the new fields 'a_machtype'
* and a_flags. If a_machtype is M_386, and a_flags & A_ENCAP is
* true, then the bsd header is preceeded by a coff header. Macros
* like N_TXTOFF and N_TXTADDR use this field to find the bsd header.
*
* The only problem is to track down the bsd exec header. The
* macros HEADER_OFFSET, etc do this.
*/
#define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */
/* Describe the COFF header used for encapsulation. */
struct coffheader
{
/* filehdr */
unsigned short f_magic;
unsigned short f_nscns;
long f_timdat;
long f_symptr;
long f_nsyms;
unsigned short f_opthdr;
unsigned short f_flags;
/* aouthdr */
short magic;
short vstamp;
long tsize;
long dsize;
long bsize;
long entry;
long text_start;
long data_start;
struct coffscn
{
char s_name[8];
long s_paddr;
long s_vaddr;
long s_size;
long s_scnptr;
long s_relptr;
long s_lnnoptr;
unsigned short s_nreloc;
unsigned short s_nlnno;
long s_flags;
} scns[3];
};
/* Describe some of the parameters of the encapsulation,
including how to find the encapsulated BSD header. */
/* FIXME, this is dumb. The same tools can't handle a.outs for different
architectures, just because COFF_MAGIC is different; so you need a
separate GNU nm for every architecture!!? Unfortunately, it needs to
be this way, since the COFF_MAGIC value is determined by the kernel
we're trying to fool here. */
#define COFF_MAGIC_I386 0514 /* I386MAGIC */
#define COFF_MAGIC_M68K 0520 /* MC68MAGIC */
#define COFF_MAGIC_A29K 0x17A /* Used by asm29k cross-tools */
#ifdef COFF_MAGIC
short __header_offset_temp;
#define HEADER_OFFSET(f) \
(__header_offset_temp = 0, \
fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \
fseek ((f), -sizeof (short), 1), \
__header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
#else
#define HEADER_OFFSET(f) 0
#endif
#define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1))
/* Describe the characteristics of the BSD header
that appears inside the encapsulation. */
/* Encapsulated coff files that are linked ZMAGIC have a text segment
offset just past the header (and a matching TXTADDR), excluding
the headers from the text segment proper but keeping the physical
layout and the virtual memory layout page-aligned.
Non-encapsulated a.out files that are linked ZMAGIC have a text
segment that starts at 0 and an N_TXTADR similarly offset to 0.
They too are page-aligned with each other, but they include the
a.out header as part of the text.
The _N_HDROFF gets sizeof struct exec added to it, so we have
to compensate here. See <a.out.gnu.h>. */
#undef _N_HDROFF
#undef N_TXTADDR
#undef N_DATADDR
#define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
sizeof (struct coffheader) : 0)
/* Address of text segment in memory after it is loaded. */
#define N_TXTADDR(x) \
((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
sizeof (struct coffheader) + sizeof (struct exec) : 0)
#define SEGMENT_SIZE 0x400000
#define N_DATADDR(x) \
((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
(SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
(N_TXTADDR(x)+(x).a_text))

View File

@ -0,0 +1,22 @@
/* Parameters about the a.out format, based on the host system on which
the program is compiled. */
/* Address of data segment in memory after it is loaded.
It is up to you to define SEGMENT_SIZE
on machines not listed here. */
#ifndef SEGMENT_SIZE
#if defined(hp300) || defined(pyr)
#define SEGMENT_SIZE page_size
#endif
#ifdef sony
#define SEGMENT_SIZE 0x1000
#endif /* Sony. */
#ifdef is68k
#define SEGMENT_SIZE 0x20000
#endif
#if defined(m68k) && defined(PORTAR)
#define PAGE_SIZE 0x400
#define SEGMENT_SIZE PAGE_SIZE
#endif
#endif /*!defined(SEGMENT_SIZE)*/

View File

@ -0,0 +1,66 @@
/* reloc.h -- Header file for relocation information.
Copyright 1989-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Relocation types for a.out files using reloc_info_extended
(SPARC and AMD 29000). */
#ifndef _RELOC_H_READ_
#define _RELOC_H_READ_ 1
enum reloc_type
{
RELOC_8, RELOC_16, RELOC_32, /* simple relocations */
RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */
RELOC_WDISP30, RELOC_WDISP22,
RELOC_HI22, RELOC_22,
RELOC_13, RELOC_LO10,
RELOC_SFA_BASE, RELOC_SFA_OFF13,
RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */
RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */
RELOC_JMP_TBL, /* P.I.C. jump table */
RELOC_SEGOFF16, /* reputedly for shared libraries somehow */
RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE,
RELOC_11,
RELOC_WDISP2_14,
RELOC_WDISP19,
RELOC_HHI22,
RELOC_HLO10,
/* 29K relocation types */
RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH,
RELOC_WDISP14, RELOC_WDISP21,
NO_RELOC
};
#define RELOC_TYPE_NAMES \
"8", "16", "32", "DISP8", \
"DISP16", "DISP32", "WDISP30", "WDISP22", \
"HI22", "22", "13", "LO10", \
"SFA_BASE", "SFAOFF13", "BASE10", "BASE13", \
"BASE22", "PC10", "PC22", "JMP_TBL", \
"SEGOFF16", "GLOB_DAT", "JMP_SLOT", "RELATIVE", \
"11", "WDISP2_14", "WDISP19", "HHI22", \
"HLO10", \
"JUMPTARG", "CONST", "CONSTH", "WDISP14", \
"WDISP21", \
"NO_RELOC"
#endif /* _RELOC_H_READ_ */
/* end of reloc.h */

View File

@ -0,0 +1,411 @@
/* bfdlink.h -- header file for BFD link routines
Copyright 1993 Free Software Foundation, Inc.
Written by Steve Chamberlain and 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef BFDLINK_H
#define BFDLINK_H
/* Which symbols to strip during a link. */
enum bfd_link_strip
{
strip_none, /* Don't strip any symbols. */
strip_debugger, /* Strip debugging symbols. */
strip_some, /* keep_hash is the list of symbols to keep. */
strip_all /* Strip all symbols. */
};
/* Which local symbols to discard during a link. This is irrelevant
if strip_all is used. */
enum bfd_link_discard
{
discard_none, /* Don't discard any locals. */
discard_l, /* Discard locals with a certain prefix. */
discard_all /* Discard all locals. */
};
/* These are the possible types of an entry in the BFD link hash
table. */
enum bfd_link_hash_type
{
bfd_link_hash_new, /* Symbol is new. */
bfd_link_hash_undefined, /* Symbol seen before, but undefined. */
bfd_link_hash_weak, /* Symbol is weak and undefined. */
bfd_link_hash_defined, /* Symbol is defined. */
bfd_link_hash_common, /* Symbol is common. */
bfd_link_hash_indirect, /* Symbol is an indirect link. */
bfd_link_hash_warning /* Like indirect, but warn if referenced. */
};
/* The linking routines use a hash table which uses this structure for
its elements. */
struct bfd_link_hash_entry
{
/* Base hash table entry structure. */
struct bfd_hash_entry root;
/* Type of this entry. */
enum bfd_link_hash_type type;
/* Undefined and common symbols are kept in a linked list through
this field. This field is not in the union because that would
force us to remove entries from the list when we changed their
type, which would force the list to be doubly linked, which would
waste more memory. When an undefined or common symbol is
created, it should be added to this list, the head of which is in
the link hash table itself. As symbols are defined, they need
not be removed from the list; anything which reads the list must
doublecheck the symbol type.
Weak symbols are not kept on this list.
Defined symbols use this field as a reference marker. If the
field is not NULL, or this structure is the tail of the undefined
symbol list, the symbol has been referenced. If the symbol is
undefined and becomes defined, this field will automatically be
non-NULL since the symbol will have been on the undefined symbol
list. */
struct bfd_link_hash_entry *next;
/* A union of information depending upon the type. */
union
{
/* Nothing is kept for bfd_hash_new. */
/* bfd_link_hash_undefined, bfd_link_hash_weak. */
struct
{
bfd *abfd; /* BFD symbol was found in. */
} undef;
/* bfd_link_hash_defined. */
struct
{
bfd_vma value; /* Symbol value. */
asection *section; /* Symbol section. */
} def;
/* bfd_link_hash_indirect, bfd_link_hash_warning. */
struct
{
struct bfd_link_hash_entry *link; /* Real symbol. */
const char *warning; /* Warning (bfd_link_hash_warning only). */
} i;
/* bfd_link_hash_common. */
struct
{
bfd_vma size; /* Common symbol size. */
asection *section; /* Symbol section. */
} c;
} u;
};
/* This is the link hash table. It is a derived class of
bfd_hash_table. */
struct bfd_link_hash_table
{
/* The hash table itself. */
struct bfd_hash_table table;
/* The back end which created this hash table. This indicates the
type of the entries in the hash table, which is sometimes
important information when linking object files of different
types together. */
const bfd_target *creator;
/* A linked list of undefined and common symbols, linked through the
next field in the bfd_link_hash_entry structure. */
struct bfd_link_hash_entry *undefs;
/* Entries are added to the tail of the undefs list. */
struct bfd_link_hash_entry *undefs_tail;
};
/* Look up an entry in a link hash table. If FOLLOW is true, this
follows bfd_link_hash_indirect and bfd_link_hash_warning links to
the real symbol. */
extern struct bfd_link_hash_entry *bfd_link_hash_lookup
PARAMS ((struct bfd_link_hash_table *, const char *, boolean create,
boolean copy, boolean follow));
/* Traverse a link hash table. */
extern void bfd_link_hash_traverse
PARAMS ((struct bfd_link_hash_table *,
boolean (*) (struct bfd_link_hash_entry *, PTR),
PTR));
/* Add an entry to the undefs list. */
extern void bfd_link_add_undef
PARAMS ((struct bfd_link_hash_table *, struct bfd_link_hash_entry *));
/* This structure holds all the information needed to communicate
between BFD and the linker when doing a link. */
struct bfd_link_info
{
/* Function callbacks. */
const struct bfd_link_callbacks *callbacks;
/* true if BFD should generate a relocateable object file. */
boolean relocateable;
/* true if BFD should generate a shared object. */
boolean shared;
/* Which symbols to strip. */
enum bfd_link_strip strip;
/* Which local symbols to discard. */
enum bfd_link_discard discard;
/* The local symbol prefix to discard if using discard_l. */
unsigned int lprefix_len;
const char *lprefix;
/* true if symbols should be retained in memory, false if they
should be freed and reread. */
boolean keep_memory;
/* The list of input BFD's involved in the link. These are chained
together via the link_next field. */
bfd *input_bfds;
/* If a symbol should be created for each input BFD, this is section
where those symbols should be placed. It must be a section in
the output BFD. It may be NULL, in which case no such symbols
will be created. This is to support CREATE_OBJECT_SYMBOLS in the
linker command language. */
asection *create_object_symbols_section;
/* Hash table handled by BFD. */
struct bfd_link_hash_table *hash;
/* Hash table of symbols to keep. This is NULL unless strip is
strip_some. */
struct bfd_hash_table *keep_hash;
/* Hash table of symbols to report back via notice_callback. If
this is NULL no symbols are reported back. */
struct bfd_hash_table *notice_hash;
};
/* This structures holds a set of callback functions. These are
called by the BFD linker routines. The first argument to each
callback function is the bfd_link_info structure being used. Each
function returns a boolean value. If the function returns false,
then the BFD function which called it will return with a failure
indication. */
struct bfd_link_callbacks
{
/* A function which is called when an object is added from an
archive. ABFD is the archive element being added. NAME is the
name of the symbol which caused the archive element to be pulled
in. */
boolean (*add_archive_element) PARAMS ((struct bfd_link_info *,
bfd *abfd,
const char *name));
/* A function which is called when a symbol is found with multiple
definitions. NAME is the symbol which is defined multiple times.
OBFD is the old BFD, OSEC is the old section, OVAL is the old
value, NBFD is the new BFD, NSEC is the new section, and NVAL is
the new value. OBFD may be NULL. OSEC and NSEC may be
bfd_com_section or bfd_ind_section. */
boolean (*multiple_definition) PARAMS ((struct bfd_link_info *,
const char *name,
bfd *obfd,
asection *osec,
bfd_vma oval,
bfd *nbfd,
asection *nsec,
bfd_vma nval));
/* A function which is called when a common symbol is defined
multiple times. NAME is the symbol appearing multiple times.
OBFD is the BFD of the existing symbol. OTYPE is the type of the
existing symbol, either bfd_link_hash_defined or
bfd_link_hash_common. If OTYPE is bfd_link_hash_common, OSIZE is
the size of the existing symbol. NBFD is the BFD of the new
symbol. NTYPE is the type of the new symbol, either
bfd_link_hash_defined or bfd_link_hash_common. If NTYPE is
bfd_link_hash_common, NSIZE is the size of the new symbol. */
boolean (*multiple_common) PARAMS ((struct bfd_link_info *,
const char *name,
bfd *obfd,
enum bfd_link_hash_type otype,
bfd_vma osize,
bfd *nbfd,
enum bfd_link_hash_type ntype,
bfd_vma nsize));
/* A function which is called to add a symbol to a set. ENTRY is
the link hash table entry for the set itself (e.g.,
__CTOR_LIST__). RELOC is the relocation to use for an entry in
the set when generating a relocateable file, and is also used to
get the size of the entry when generating an executable file.
ABFD, SEC and VALUE identify the value to add to the set. */
boolean (*add_to_set) PARAMS ((struct bfd_link_info *,
struct bfd_link_hash_entry *entry,
bfd_reloc_code_real_type reloc,
bfd *abfd, asection *sec, bfd_vma value));
/* A function which is called when the name of a g++ constructor or
destructor is found. This is only called by some object file
formats. CONSTRUCTOR is true for a constructor, false for a
destructor. This will use BFD_RELOC_CTOR when generating a
relocateable file. NAME is the name of the symbol found. ABFD,
SECTION and VALUE are the value of the symbol. */
boolean (*constructor) PARAMS ((struct bfd_link_info *,
boolean constructor,
const char *name, bfd *abfd, asection *sec,
bfd_vma value));
/* A function which is called when there is a reference to a warning
symbol. WARNING is the warning to be issued. */
boolean (*warning) PARAMS ((struct bfd_link_info *,
const char *warning));
/* A function which is called when a relocation is attempted against
an undefined symbol. NAME is the symbol which is undefined.
ABFD, SECTION and ADDRESS identify the location from which the
reference is made. */
boolean (*undefined_symbol) PARAMS ((struct bfd_link_info *,
const char *name, bfd *abfd,
asection *section, bfd_vma address));
/* A function which is called when a reloc overflow occurs. NAME is
the name of the symbol or section the reloc is against,
RELOC_NAME is the name of the relocation, and ADDEND is any
addend that is used. ABFD, SECTION and ADDRESS identify the
location at which the overflow occurs; if this is the result of a
bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
ABFD will be NULL. */
boolean (*reloc_overflow) PARAMS ((struct bfd_link_info *,
const char *name,
const char *reloc_name, bfd_vma addend,
bfd *abfd, asection *section,
bfd_vma address));
/* A function which is called when a dangerous reloc is performed.
The canonical example is an a29k IHCONST reloc which does not
follow an IHIHALF reloc. MESSAGE is an appropriate message.
ABFD, SECTION and ADDRESS identify the location at which the
problem occurred; if this is the result of a
bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
ABFD will be NULL. */
boolean (*reloc_dangerous) PARAMS ((struct bfd_link_info *,
const char *message,
bfd *abfd, asection *section,
bfd_vma address));
/* A function which is called when a reloc is found to be attached
to a symbol which is not being written out. NAME is the name of
the symbol. ABFD, SECTION and ADDRESS identify the location of
the reloc; if this is the result of a
bfd_section_reloc_link_order or bfd_symbol_reloc_link_order, then
ABFD will be NULL. */
boolean (*unattached_reloc) PARAMS ((struct bfd_link_info *,
const char *name,
bfd *abfd, asection *section,
bfd_vma address));
/* A function which is called when a symbol in notice_hash is
defined or referenced. NAME is the symbol. ABFD, SECTION and
ADDRESS are the value of the symbol. If SECTION is
bfd_und_section, this is a reference. */
boolean (*notice) PARAMS ((struct bfd_link_info *, const char *name,
bfd *abfd, asection *section, bfd_vma address));
};
/* The linker builds link_order structures which tell the code how to
include input data in the output file. */
/* These are the types of link_order structures. */
enum bfd_link_order_type
{
bfd_undefined_link_order, /* Undefined. */
bfd_indirect_link_order, /* Built from a section. */
bfd_fill_link_order, /* Fill with a 16 bit constant. */
bfd_data_link_order, /* Set to explicit data. */
bfd_section_reloc_link_order, /* Relocate against a section. */
bfd_symbol_reloc_link_order /* Relocate against a symbol. */
};
/* This is the link_order structure itself. These form a chain
attached to the section whose contents they are describing. */
struct bfd_link_order
{
/* Next link_order in chain. */
struct bfd_link_order *next;
/* Type of link_order. */
enum bfd_link_order_type type;
/* Offset within output section. */
bfd_vma offset;
/* Size within output section. */
bfd_size_type size;
/* Type specific information. */
union
{
struct
{
/* Section to include. If this is used, then
section->output_section must be the section the
link_order is attached to, section->output_offset must
equal the link_order offset field, and section->_raw_size
must equal the link_order size field. Maybe these
restrictions should be relaxed someday. */
asection *section;
} indirect;
struct
{
/* Value to fill with. */
unsigned int value;
} fill;
struct
{
/* Data to put into file. The size field gives the number
of bytes which this field points to. */
bfd_byte *contents;
} data;
struct
{
/* Description of reloc to generate. Used for
bfd_section_reloc_link_order and
bfd_symbol_reloc_link_order. */
struct bfd_link_order_reloc *p;
} reloc;
} u;
};
/* A linker order of type bfd_section_reloc_link_order or
bfd_symbol_reloc_link_order means to create a reloc against a
section or symbol, respectively. This is used to implement -Ur to
generate relocs for the constructor tables. The
bfd_link_order_reloc structure describes the reloc that BFD should
create. It is similar to a arelent, but I didn't use arelent
because the linker does not know anything about most symbols, and
any asymbol structure it creates will be partially meaningless.
This information could logically be in the bfd_link_order struct,
but I didn't want to waste the space since these types of relocs
are relatively rare. */
struct bfd_link_order_reloc
{
/* Reloc type. */
bfd_reloc_code_real_type reloc;
union
{
/* For type bfd_section_reloc_link_order, this is the section
the reloc should be against. This must be a section in the
output BFD, not any of the input BFDs. */
asection *section;
/* For type bfd_symbol_reloc_link_order, this is the name of the
symbol the reloc should be against. */
const char *name;
} u;
/* Addend to use. The object file should contain zero. The BFD
backend is responsible for filling in the contents of the object
file correctly. For some object file formats (e.g., COFF) the
addend must be stored into in the object file, and for some
(e.g., SPARC a.out) it is kept in the reloc. */
bfd_vma addend;
};
/* Allocate a new link_order for a section. */
extern struct bfd_link_order *bfd_new_link_order PARAMS ((bfd *, asection *));
#endif

View File

@ -0,0 +1,221 @@
/*** coff information for Intel 386/486. */
/********************** FILE HEADER **********************/
struct external_filehdr {
char f_magic[2]; /* magic number */
char f_nscns[2]; /* number of sections */
char f_timdat[4]; /* time & date stamp */
char f_symptr[4]; /* file pointer to symtab */
char f_nsyms[4]; /* number of symtab entries */
char f_opthdr[2]; /* sizeof(optional hdr) */
char f_flags[2]; /* flags */
};
/* Bits for f_flags:
* F_RELFLG relocation info stripped from file
* F_EXEC file is executable (no unresolved external references)
* F_LNNO line numbers stripped from file
* F_LSYMS local symbols stripped from file
* F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
*/
#define F_RELFLG (0x0001)
#define F_EXEC (0x0002)
#define F_LNNO (0x0004)
#define F_LSYMS (0x0008)
#define I386MAGIC 0x14c
#define I386PTXMAGIC 0x154
#define I386AIXMAGIC 0x175
/* This is Lynx's all-platform magic number for executables. */
#define LYNXCOFFMAGIC 0415
#define I386BADMAG(x) (((x).f_magic != I386MAGIC) \
&& (x).f_magic != I386AIXMAGIC \
&& (x).f_magic != I386PTXMAGIC \
&& (x).f_magic != LYNXCOFFMAGIC)
#define FILHDR struct external_filehdr
#define FILHSZ sizeof(FILHDR)
/********************** AOUT "OPTIONAL HEADER" **********************/
typedef struct
{
char magic[2]; /* type of file */
char vstamp[2]; /* version stamp */
char tsize[4]; /* text size in bytes, padded to FW bdry*/
char dsize[4]; /* initialized data " " */
char bsize[4]; /* uninitialized data " " */
char entry[4]; /* entry pt. */
char text_start[4]; /* base of text used for this file */
char data_start[4]; /* base of data used for this file */
}
AOUTHDR;
#define AOUTSZ (sizeof(AOUTHDR))
#define OMAGIC 0404 /* object files, eg as output */
#define ZMAGIC 0413 /* demand load format, eg normal ld output */
#define STMAGIC 0401 /* target shlib */
#define SHMAGIC 0443 /* host shlib */
/********************** SECTION HEADER **********************/
struct external_scnhdr {
char s_name[8]; /* section name */
char s_paddr[4]; /* physical address, aliased s_nlib */
char s_vaddr[4]; /* virtual address */
char s_size[4]; /* section size */
char s_scnptr[4]; /* file ptr to raw data for section */
char s_relptr[4]; /* file ptr to relocation */
char s_lnnoptr[4]; /* file ptr to line numbers */
char s_nreloc[2]; /* number of relocation entries */
char s_nlnno[2]; /* number of line number entries*/
char s_flags[4]; /* flags */
};
#define SCNHDR struct external_scnhdr
#define SCNHSZ sizeof(SCNHDR)
/*
* names of "special" sections
*/
#define _TEXT ".text"
#define _DATA ".data"
#define _BSS ".bss"
#define _COMMENT ".comment"
#define _LIB ".lib"
/********************** LINE NUMBERS **********************/
/* 1 line number entry for every "breakpointable" source line in a section.
* Line numbers are grouped on a per function basis; first entry in a function
* grouping will have l_lnno = 0 and in place of physical address will be the
* symbol table index of the function name.
*/
struct external_lineno {
union {
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
char l_paddr[4]; /* (physical) address of line number */
} l_addr;
char l_lnno[2]; /* line number */
};
#define LINENO struct external_lineno
#define LINESZ 6
/********************** SYMBOLS **********************/
#define E_SYMNMLEN 8 /* # characters in a symbol name */
#define E_FILNMLEN 14 /* # characters in a file name */
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
struct external_syment
{
union {
char e_name[E_SYMNMLEN];
struct {
char e_zeroes[4];
char e_offset[4];
} e;
} e;
char e_value[4];
char e_scnum[2];
char e_type[2];
char e_sclass[1];
char e_numaux[1];
};
#define N_BTMASK (0xf)
#define N_TMASK (0x30)
#define N_BTSHFT (4)
#define N_TSHIFT (2)
union external_auxent {
struct {
char x_tagndx[4]; /* str, un, or enum tag indx */
union {
struct {
char x_lnno[2]; /* declaration line number */
char x_size[2]; /* str/union/array size */
} x_lnsz;
char x_fsize[4]; /* size of function */
} x_misc;
union {
struct { /* if ISFCN, tag, or .bb */
char x_lnnoptr[4]; /* ptr to fcn line # */
char x_endndx[4]; /* entry ndx past block end */
} x_fcn;
struct { /* if ISARY, up to 4 dimen. */
char x_dimen[E_DIMNUM][2];
} x_ary;
} x_fcnary;
char x_tvndx[2]; /* tv index */
} x_sym;
union {
char x_fname[E_FILNMLEN];
struct {
char x_zeroes[4];
char x_offset[4];
} x_n;
} x_file;
struct {
char x_scnlen[4]; /* section length */
char x_nreloc[2]; /* # relocation entries */
char x_nlinno[2]; /* # line numbers */
} x_scn;
struct {
char x_tvfill[4]; /* tv fill value */
char x_tvlen[2]; /* length of .tv */
char x_tvran[2][2]; /* tv range */
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
};
#define SYMENT struct external_syment
#define SYMESZ 18
#define AUXENT union external_auxent
#define AUXESZ 18
# define _ETEXT "etext"
/********************** RELOCATION DIRECTIVES **********************/
struct external_reloc {
char r_vaddr[4];
char r_symndx[4];
char r_type[2];
};
#define RELOC struct external_reloc
#define RELSZ 10
#define DEFAULT_DATA_SECTION_ALIGNMENT 4
#define DEFAULT_BSS_SECTION_ALIGNMENT 4
#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
/* For new sections we havn't heard of before */
#define DEFAULT_SECTION_ALIGNMENT 4

View File

@ -0,0 +1,148 @@
/* Select disassembly routine for specified architecture.
Copyright 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ansidecl.h"
#include "dis-asm.h"
#ifdef ARCH_all
#define ARCH_a29k
#define ARCH_alpha
#define ARCH_h8300
#define ARCH_h8500
#define ARCH_hppa
#define ARCH_i386
#define ARCH_i960
#define ARCH_m68k
#define ARCH_m88k
#define ARCH_mips
#define ARCH_ns32k
#define ARCH_powerpc
#define ARCH_rs6000
#define ARCH_sh
#define ARCH_sparc
#define ARCH_z8k
#endif
disassembler_ftype
disassembler (abfd)
bfd *abfd;
{
enum bfd_architecture a = bfd_get_arch (abfd);
disassembler_ftype disassemble;
switch (a)
{
/* If you add a case to this table, also add it to the
ARCH_all definition right above this function. */
#ifdef ARCH_a29k
case bfd_arch_a29k:
/* As far as I know we only handle big-endian 29k objects. */
disassemble = print_insn_big_a29k;
break;
#endif
#ifdef ARCH_alpha
case bfd_arch_alpha:
disassemble = print_insn_alpha;
break;
#endif
#ifdef ARCH_h8300
case bfd_arch_h8300:
if (bfd_get_mach(abfd) == bfd_mach_h8300h)
disassemble = print_insn_h8300h;
else
disassemble = print_insn_h8300;
break;
#endif
#ifdef ARCH_h8500
case bfd_arch_h8500:
disassemble = print_insn_h8500;
break;
#endif
#ifdef ARCH_hppa
case bfd_arch_hppa:
disassemble = print_insn_hppa;
break;
#endif
#ifdef ARCH_i386
case bfd_arch_i386:
disassemble = print_insn_i386;
break;
#endif
#ifdef ARCH_i960
case bfd_arch_i960:
disassemble = print_insn_i960;
break;
#endif
#ifdef ARCH_m68k
case bfd_arch_m68k:
disassemble = print_insn_m68k;
break;
#endif
#ifdef ARCH_m88k
case bfd_arch_m88k:
disassemble = print_insn_m88k;
break;
#endif
#ifdef ARCH_ns32k
case bfd_arch_ns32k:
disassemble = print_insn_ns32k;
break;
#endif
#ifdef ARCH_mips
case bfd_arch_mips:
if (abfd->xvec->byteorder_big_p)
disassemble = print_insn_big_mips;
else
disassemble = print_insn_little_mips;
break;
#endif
#ifdef ARCH_powerpc
case bfd_arch_powerpc:
if (abfd->xvec->byteorder_big_p)
disassemble = print_insn_big_powerpc;
else
disassemble = print_insn_little_powerpc;
break;
#endif
#ifdef ARCH_rs6000
case bfd_arch_rs6000:
disassemble = print_insn_rs6000;
break;
#endif
#ifdef ARCH_sh
case bfd_arch_sh:
disassemble = print_insn_sh;
break;
#endif
#ifdef ARCH_sparc
case bfd_arch_sparc:
disassemble = print_insn_sparc;
break;
#endif
#ifdef ARCH_z8k
case bfd_arch_z8k:
if (bfd_get_mach(abfd) == bfd_mach_z8001)
disassemble = print_insn_z8001;
else
disassemble = print_insn_z8002;
break;
#endif
default:
return 0;
}
return disassemble;
}

View File

@ -0,0 +1,87 @@
/* IEEE floating point support declarations, for GDB, the GNU Debugger.
Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of GDB.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
#if !defined (FLOATFORMAT_H)
#define FLOATFORMAT_H 1
#include "ansidecl.h"
/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
bytes are concatenated according to the byteorder flag, then each of those
fields is contiguous. We number the bits with 0 being the most significant
(i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
contains with the *_start and *_len fields. */
enum floatformat_byteorders { floatformat_little, floatformat_big };
enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
struct floatformat
{
enum floatformat_byteorders byteorder;
unsigned int totalsize; /* Total size of number in bits */
/* Sign bit is always one bit long. 1 means negative, 0 means positive. */
unsigned int sign_start;
unsigned int exp_start;
unsigned int exp_len;
/* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */
unsigned int exp_bias;
/* Exponent value which indicates NaN. This is the actual value stored in
the float, not adjusted by the exp_bias. This usually consists of all
one bits. */
unsigned int exp_nan;
unsigned int man_start;
unsigned int man_len;
/* Is the integer bit explicit or implicit? */
enum floatformat_intbit intbit;
};
/* floatformats for IEEE single and double, big and little endian. */
extern const struct floatformat floatformat_ieee_single_big;
extern const struct floatformat floatformat_ieee_single_little;
extern const struct floatformat floatformat_ieee_double_big;
extern const struct floatformat floatformat_ieee_double_little;
/* floatformats for various extendeds. */
extern const struct floatformat floatformat_i387_ext;
extern const struct floatformat floatformat_m68881_ext;
extern const struct floatformat floatformat_i960_ext;
extern const struct floatformat floatformat_m88110_ext;
/* Convert from FMT to a double.
FROM is the address of the extended float.
Store the double in *TO. */
extern void
floatformat_to_double PARAMS ((const struct floatformat *, char *, double *));
/* The converse: convert the double *FROM to FMT
and store where TO points. */
extern void
floatformat_from_double PARAMS ((const struct floatformat *,
double *, char *));
#endif /* defined (FLOATFORMAT_H) */

View File

@ -0,0 +1,27 @@
/* Macros for the 'type' part of an fopen, freopen or fdopen.
<Read|Write>[Update]<Binary file|text file>
This version is for "binary" systems, where text and binary files are
different. An example is Mess-Dose. Many Unix systems could also
cope with a "b" in the string, indicating binary files, but some reject this
(and thereby don't conform to ANSI C, but what else is new?).
This file is designed for inclusion by host-dependent .h files. No
user application should include it directly, since that would make
the application unable to be configured for both "same" and "binary"
variant systems. */
#define FOPEN_RB "rb"
#define FOPEN_WB "wb"
#define FOPEN_AB "ab"
#define FOPEN_RUB "r+b"
#define FOPEN_WUB "w+b"
#define FOPEN_AUB "a+b"
#define FOPEN_RT "r"
#define FOPEN_WT "w"
#define FOPEN_AT "a"
#define FOPEN_RUT "r+"
#define FOPEN_WUT "w+"
#define FOPEN_AUT "a+"

View File

@ -0,0 +1,91 @@
/* GNU DBM - DataBase Manager include file
Copyright 1989, 1991 Free Software Foundation, Inc.
Written by Philip A. Nelson.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* You may contact the author by:
e-mail: phil@wwu.edu
us-mail: Philip A. Nelson
Computer Science Department
Western Washington University
Bellingham, WA 98226
phone: (206) 676-3035
*************************************************************************/
/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who
can create the database. */
#define GDBM_READER 0
#define GDBM_WRITER 1
#define GDBM_WRCREAT 2
#define GDBM_NEWDB 3
/* Parameters to gdbm_store for simple insertion or replacement. */
#define GDBM_INSERT 0
#define GDBM_REPLACE 1
/* The data and key structure. This structure is defined for compatibility. */
typedef struct {
char *dptr;
int dsize;
} datum;
/* The file information header. This is good enough for most applications. */
typedef struct {int dummy[10];} *GDBM_FILE;
/* These are the routines! */
extern GDBM_FILE gdbm_open ();
extern void gdbm_close ();
extern datum gdbm_fetch ();
extern int gdbm_store ();
extern int gdbm_delete ();
extern datum gdbm_firstkey ();
extern datum gdbm_nextkey ();
extern int gdbm_reorganize ();
/* gdbm sends back the following error codes in the variable gdbm_errno. */
typedef enum { NO_ERROR,
MALLOC_ERROR,
BLOCK_SIZE_ERROR,
FILE_OPEN_ERROR,
FILE_WRITE_ERROR,
FILE_SEEK_ERROR,
FILE_READ_ERROR,
BAD_MAGIC_NUMBER,
EMPTY_DATABASE,
CANT_BE_READER,
CANT_BE_WRITER,
READER_CANT_RECOVER,
READER_CANT_DELETE,
READER_CANT_STORE,
READER_CANT_REORGANIZE,
UNKNOWN_UPDATE,
ITEM_NOT_FOUND,
REORGANIZE_FAILED,
CANNOT_REPLACE}
gdbm_error;

132
gnu/usr.bin/gdb/gdb/ieee.h Normal file
View File

@ -0,0 +1,132 @@
/* IEEE Standard 695-1980 "Universal Format for Object Modules" header file
Contributed by Cygnus Support. */
#define N_W_VARIABLES 8
#define Module_Beginning 0xe0
typedef struct ieee_module {
char *processor;
char *module_name;
} ieee_module_begin_type;
#define Address_Descriptor 0xec
typedef struct ieee_address {
bfd_vma number_of_bits_mau;
bfd_vma number_of_maus_in_address;
unsigned char byte_order;
#define IEEE_LITTLE 0xcc
#define IEEE_BIG 0xcd
} ieee_address_descriptor_type;
typedef union ieee_w_variable {
file_ptr offset[N_W_VARIABLES];
struct {
file_ptr extension_record;
file_ptr environmental_record;
file_ptr section_part;
file_ptr external_part;
file_ptr debug_information_part;
file_ptr data_part;
file_ptr trailer_part;
file_ptr me_record;
} r;
} ieee_w_variable_type;
typedef enum ieee_record
{
ieee_number_start_enum = 0x00,
ieee_number_end_enum=0x7f,
ieee_number_repeat_start_enum = 0x80,
ieee_number_repeat_end_enum = 0x88,
ieee_number_repeat_4_enum = 0x84,
ieee_number_repeat_3_enum = 0x83,
ieee_number_repeat_2_enum = 0x82,
ieee_number_repeat_1_enum = 0x81,
ieee_module_beginning_enum = 0xe0,
ieee_module_end_enum = 0xe1,
ieee_extension_length_1_enum = 0xde,
ieee_extension_length_2_enum = 0xdf,
ieee_section_type_enum = 0xe6,
ieee_section_alignment_enum = 0xe7,
ieee_external_symbol_enum = 0xe8,
ieee_attribute_record_enum = 0xf1c9,
ieee_comma = 0x90,
ieee_external_reference_enum = 0xe9,
ieee_set_current_section_enum = 0xe5,
ieee_address_descriptor_enum = 0xec,
ieee_load_constant_bytes_enum = 0xed,
ieee_load_with_relocation_enum = 0xe4,
ieee_variable_A_enum = 0xc1,
ieee_variable_B_enum = 0xc2,
ieee_variable_C_enum = 0xc3,
ieee_variable_D_enum = 0xc4,
ieee_variable_E_enum = 0xc5,
ieee_variable_F_enum = 0xc6,
ieee_variable_G_enum = 0xc7,
ieee_variable_H_enum = 0xc8,
ieee_variable_I_enum = 0xc9,
ieee_variable_J_enum = 0xca,
ieee_variable_K_enum = 0xcb,
ieee_variable_L_enum = 0xcc,
ieee_variable_M_enum = 0xcd,
ieee_variable_N_enum = 0xce,
ieee_variable_O_enum = 0xcf,
ieee_variable_P_enum = 0xd0,
ieee_variable_Q_enum = 0xd1,
ieee_variable_R_enum = 0xd2,
ieee_variable_S_enum = 0xd3,
ieee_variable_T_enum = 0xd4,
ieee_variable_U_enum = 0xd5,
ieee_variable_V_enum = 0xd6,
ieee_variable_W_enum = 0xd7,
ieee_variable_X_enum = 0xd8,
ieee_variable_Y_enum = 0xd9,
ieee_variable_Z_enum = 0xda,
ieee_function_plus_enum = 0xa5,
ieee_function_minus_enum = 0xa6,
ieee_function_signed_open_b_enum = 0xba,
ieee_function_signed_close_b_enum = 0xbb,
ieee_function_unsigned_open_b_enum = 0xbc,
ieee_function_unsigned_close_b_enum = 0xbd,
ieee_function_either_open_b_enum = 0xbe,
ieee_function_either_close_b_enum = 0xbf,
ieee_record_seperator_enum = 0xdb,
ieee_e2_first_byte_enum = 0xe2,
ieee_section_size_enum = 0xe2d3,
ieee_physical_region_size_enum = 0xe2c1,
ieee_region_base_address_enum = 0xe2c2,
ieee_mau_size_enum = 0xe2c6,
ieee_m_value_enum = 0xe2cd,
ieee_section_base_address_enum = 0xe2cc,
ieee_section_offset_enum = 0xe2d2,
ieee_value_starting_address_enum = 0xe2c7,
ieee_assign_value_to_variable_enum = 0xe2d7,
ieee_set_current_pc_enum = 0xe2d0,
ieee_value_record_enum = 0xe2c9,
ieee_nn_record = 0xf0,
ieee_weak_external_reference_enum= 0xf4,
ieee_repeat_data_enum = 0xf7
} ieee_record_enum_type;
typedef struct ieee_section {
unsigned int section_index;
unsigned int section_type;
char *section_name;
unsigned int parent_section_index;
unsigned int sibling_section_index;
unsigned int context_index;
} ieee_section_type;
#define IEEE_REFERENCE_BASE 11
#define IEEE_PUBLIC_BASE 32
#define IEEE_SECTION_NUMBER_BASE 1

View File

@ -0,0 +1,353 @@
/* Core dump and executable file functions below target vector, for GDB.
Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: kcorelow.c,v 1.2 1994/05/18 12:42:15 pk Exp $
*/
#include "defs.h"
#ifdef KERNEL_DEBUG
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/proc.h>
#include <sys/user.h>
#include "frame.h" /* required by inferior.h */
#include "inferior.h"
#include "symtab.h"
#include "command.h"
#include "bfd.h"
#include "target.h"
#include "gdbcore.h"
static void
kcore_files_info PARAMS ((struct target_ops *));
static void
kcore_close PARAMS ((int));
static void
get_kcore_registers PARAMS ((int));
static int
xfer_mem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
static int
xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
static char *core_file;
static int core_kd = -1;
static struct proc *cur_proc;
static CORE_ADDR kernel_start;
/*
* Read the "thing" at kernel address 'addr' into the space pointed to
* by point. The length of the "thing" is determined by the type of p.
* Result is non-zero if transfer fails.
*/
#define kvread(addr, p) \
(target_read_memory((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
extern read_pcb (int, CORE_ADDR);
CORE_ADDR
ksym_lookup(name)
const char *name;
{
struct minimal_symbol *sym;
sym = lookup_minimal_symbol(name, (struct objfile *)NULL);
if (sym == NULL)
error("kernel symbol `%s' not found.", name);
return SYMBOL_VALUE_ADDRESS(sym);
}
static struct proc *
curProc()
{
struct proc *p;
CORE_ADDR addr = ksym_lookup("curproc");
if (kvread(addr, &p))
error("cannot read proc pointer at %x\n", addr);
return p;
}
/*
* Set the process context to that of the proc structure at
* system address paddr.
*/
static int
set_proc_context(paddr)
CORE_ADDR paddr;
{
struct proc p;
if (paddr < kernel_start)
return (1);
cur_proc = (struct proc *)paddr;
#ifdef notyet
set_kernel_boundaries(cur_proc);
#endif
/* Fetch all registers from core file */
target_fetch_registers (-1);
/* Now, set up the frame cache, and print the top of stack */
flush_cached_frames();
set_current_frame (create_new_frame (read_fp (), read_pc ()));
select_frame (get_current_frame (), 0);
return (0);
}
/* Discard all vestiges of any previous core file
and mark data and stack spaces as empty. */
/* ARGSUSED */
static void
kcore_close (quitting)
int quitting;
{
inferior_pid = 0; /* Avoid confusion from thread stuff */
if (core_kd) {
kvm_close(core_kd);
free(core_file);
core_file = NULL;
core_kd = -1;
}
}
/* This routine opens and sets up the core file bfd */
void
kcore_open (filename, from_tty)
char *filename;
int from_tty;
{
const char *p;
struct cleanup *old_chain;
char buf[256], *cp;
int ontop;
CORE_ADDR addr;
struct pcb pcb;
target_preopen (from_tty);
if (!filename) {
/*error (core_kd?*/
error ((core_kd >= 0)?
"No core file specified. (Use `detach' to stop debugging a core file.)"
: "No core file specified.");
}
filename = tilde_expand (filename);
if (filename[0] != '/') {
cp = concat (current_directory, "/", filename, NULL);
free (filename);
filename = cp;
}
old_chain = make_cleanup (free, filename);
core_kd = kvm_open (exec_bfd->filename, filename, NULL,
write_files? O_RDWR: O_RDONLY, 0);
if (core_kd < 0)
perror_with_name (filename);
/* Looks semi-reasonable. Toss the old core file and work on the new. */
discard_cleanups (old_chain); /* Don't free filename any more */
core_file = filename;
unpush_target (&kcore_ops);
ontop = !push_target (&kcore_ops);
kernel_start = bfd_get_start_address (exec_bfd); /* XXX */
/* print out the panic string if there is one */
if (kvread(ksym_lookup("panicstr"), &addr) == 0 &&
addr != 0 &&
target_read_memory(addr, buf, sizeof(buf)) == 0) {
for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++)
if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp)))
*cp = '?';
*cp = '\0';
if (buf[0] != '\0')
printf("panic: %s\n", buf);
}
if (!ontop) {
warning (
"you won't be able to access this core file until you terminate\n\
your %s; do ``info files''", current_target->to_longname);
return;
}
/* we may need this later */
cur_proc = (struct proc *)curProc();
/* Now, set up the frame cache, and print the top of stack */
flush_cached_frames();
set_current_frame (create_new_frame (read_fp (), read_pc ()));
select_frame (get_current_frame (), 0);
print_stack_frame (selected_frame, selected_frame_level, 1);
}
void
kcore_detach (args, from_tty)
char *args;
int from_tty;
{
if (args)
error ("Too many arguments");
unpush_target (&kcore_ops);
reinit_frame_cache ();
if (from_tty)
printf_filtered ("No kernel core file now.\n");
}
/* Get the registers out of a core file. This is the machine-
independent part. Fetch_core_registers is the machine-dependent
part, typically implemented in the xm-file for each architecture. */
/* We just get all the registers, so we don't use regno. */
/* ARGSUSED */
static void
get_kcore_registers (regno)
int regno;
{
struct user *uaddr;
/* find the pcb for the current process */
if (kvread(&cur_proc->p_addr, &uaddr))
error("cannot read u area ptr for proc at %#x", cur_proc);
if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
error("cannot read pcb at %#x", &uaddr->u_pcb);
}
/* If mourn is being called in all the right places, this could be say
`gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
static int
ignore (addr, contents)
CORE_ADDR addr;
char *contents;
{
return 0;
}
static void
kcore_files_info (t)
struct target_ops *t;
{
printf("\t`%s'\n", core_file);
}
static int
xfer_kmem (memaddr, myaddr, len, write, target)
CORE_ADDR memaddr;
char *myaddr;
int len;
int write;
struct target_ops *target;
{
int n;
if (!memaddr)
return (0);
if (memaddr < kernel_start)
return xfer_umem(memaddr, myaddr, len, write);
n = write ?
kvm_write(core_kd, memaddr, myaddr, len) :
kvm_read(core_kd, memaddr, myaddr, len) ;
if (n < 0)
return 0;
return n;
}
static int
xfer_umem (memaddr, myaddr, len, write)
CORE_ADDR memaddr;
char *myaddr;
int len;
int write; /* ignored */
{
int n;
struct proc proc;
if (kvread(cur_proc, &proc))
error("cannot read proc at %#x", cur_proc);
n = kvm_uread(core_kd, &proc, memaddr, myaddr, len) ;
if (n < 0)
return 0;
return n;
}
static void
set_proc_cmd(arg)
char *arg;
{
CORE_ADDR paddr;
if (!arg)
error_no_arg("proc address for new current process");
if (!kernel_debugging)
error("not debugging kernel");
paddr = (CORE_ADDR)parse_and_eval_address(arg);
if (set_proc_context(paddr))
error("invalid proc address");
}
struct target_ops kcore_ops = {
"kcore", "Kernel core dump file",
"Use a core file as a target. Specify the filename of the core file.",
kcore_open, kcore_close,
find_default_attach, kcore_detach, 0, 0, /* resume, wait */
get_kcore_registers,
0, 0, /* store_regs, prepare_to_store */
xfer_kmem, kcore_files_info,
ignore, ignore, /* core_insert_breakpoint, core_remove_breakpoint, */
0, 0, 0, 0, 0, /* terminal stuff */
0, 0, 0, /* kill, load, lookup sym */
find_default_create_inferior, 0, /* mourn_inferior */
0, /* can_run */
0, /* notice_signals */
kcore_stratum, 0, /* next */
0, 1, 1, 1, 0, /* all mem, mem, stack, regs, exec */
0, 0, /* section pointers */
OPS_MAGIC, /* Always the last thing */
};
void
_initialize_kcorelow()
{
add_target (&kcore_ops);
add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
}
#endif /* KERNEL_DEBUG */

View File

@ -0,0 +1,107 @@
/* Function declarations for libiberty.
Written by Cygnus Support, 1994.
The libiberty library provides a number of functions which are
missing on some operating systems. We do not declare those here,
to avoid conflicts with the system header files on operating
systems that do support those functions. In this file we only
declare those functions which are specific to libiberty. */
#ifndef LIBIBERTY_H
#define LIBIBERTY_H
#include "ansidecl.h"
/* Build an argument vector from a string. Allocates memory using
malloc. Use freeargv to free the vector. */
extern char **buildargv PARAMS ((char *));
/* Free a vector returned by buildargv. */
extern void freeargv PARAMS ((char **));
/* Return the last component of a path name. */
extern char *basename PARAMS ((char *));
/* Concatenate an arbitrary number of strings, up to (char *) NULL.
Allocates memory using xmalloc. */
extern char *concat PARAMS ((const char *, ...));
/* Check whether two file descriptors refer to the same file. */
extern int fdmatch PARAMS ((int fd1, int fd2));
/* Get the amount of time the process has run, in microseconds. */
extern long get_run_time PARAMS ((void));
/* Allocate memory filled with spaces. Allocates using malloc. */
extern const char *spaces PARAMS ((int count));
/* Return the maximum error number for which strerror will return a
string. */
extern int errno_max PARAMS ((void));
/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
"EINVAL"). */
extern const char *strerrno PARAMS ((int));
/* Given the name of an errno value, return the value. */
extern int strtoerrno PARAMS ((const char *));
/* Return the maximum signal number for which strsignal will return a
string. */
extern int signo_max PARAMS ((void));
/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
"SIGHUP"). */
extern const char *strsigno PARAMS ((int));
/* Given the name of a signal, return its number. */
extern int strtosigno PARAMS ((const char *));
/* Register a function to be run by xexit. Returns 0 on success. */
extern int xatexit PARAMS ((void (*fn) (void)));
/* Exit, calling all the functions registered with xatexit. */
#ifndef __GNUC__
extern void xexit PARAMS ((int status));
#else
typedef void libiberty_voidfn PARAMS ((int status));
__volatile__ libiberty_voidfn xexit;
#endif
/* Set the program name used by xmalloc. */
extern void xmalloc_set_program_name PARAMS ((const char *));
/* Allocate memory without fail. If malloc fails, this will print a
message to stderr (using the name set by xmalloc_set_program_name,
if any) and then call xexit.
FIXME: We do not declare the parameter type (size_t) in order to
avoid conflicts with other declarations of xmalloc that exist in
programs which use libiberty. */
extern PTR xmalloc ();
/* Reallocate memory without fail. This works like xmalloc.
FIXME: We do not declare the parameter types for the same reason as
xmalloc. */
extern PTR xrealloc ();
#endif /* ! defined (LIBIBERTY_H) */

File diff suppressed because it is too large Load Diff

1549
gnu/usr.bin/gdb/gdb/solib.c Normal file

File diff suppressed because it is too large Load Diff

2493
gnu/usr.bin/gdb/gdb/top.c Normal file

File diff suppressed because it is too large Load Diff

48
gnu/usr.bin/gdb/gdb/top.h Normal file
View File

@ -0,0 +1,48 @@
/* Top level stuff for GDB, the GNU debugger.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
Free Software Foundation, Inc.
This file is part of GDB.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* From top.c. */
extern char *line;
extern int linesize;
extern FILE *instream;
extern char gdb_dirbuf[1024];
extern int inhibit_gdbinit;
extern int epoch_interface;
extern char gdbinit[];
/* Generally one should use catch_errors rather than manipulating these
directly. The exception is main(). */
extern jmp_buf error_return;
extern jmp_buf quit_return;
extern void print_gdb_version PARAMS ((GDB_FILE *));
extern void print_gnu_advertisement PARAMS ((void));
extern void source_command PARAMS ((char *, int));
extern void cd_command PARAMS ((char *, int));
extern void read_command_file PARAMS ((FILE *));
extern void init_history PARAMS ((void));
extern void command_loop PARAMS ((void));
extern void quit_command PARAMS ((char *, int));
/* From random places. */
extern int mapped_symbol_files;
extern int readnow_symbol_files;
#define ALL_CLEANUPS ((struct cleanup *)0)

View File

@ -0,0 +1,139 @@
/* Like vsprintf but provides a pointer to malloc'd storage, which must
be freed by the caller.
Copyright (C) 1994 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <varargs.h>
#ifdef TEST
int global_total_width;
#endif
unsigned long strtoul ();
char *malloc ();
int
vasprintf (result, format, args)
char **result;
char *format;
va_list args;
{
char *p = format;
/* Add one to make sure that it is never zero, which might cause malloc
to return NULL. */
int total_width = strlen (format) + 1;
va_list ap = args;
while (*p != '\0')
{
if (*p++ == '%')
{
while (strchr ("-+ #0", *p))
++p;
if (*p == '*')
{
++p;
total_width += abs (va_arg (ap, int));
}
else
total_width += strtoul (p, &p, 10);
if (*p == '.')
{
++p;
if (*p == '*')
{
++p;
total_width += abs (va_arg (ap, int));
}
else
total_width += strtoul (p, &p, 10);
}
while (strchr ("hlL", *p))
++p;
/* Should be big enough for any format specifier except %s. */
total_width += 30;
switch (*p)
{
case 'd':
case 'i':
case 'o':
case 'u':
case 'x':
case 'X':
case 'c':
va_arg (ap, int);
break;
case 'f':
case 'e':
case 'E':
case 'g':
case 'G':
va_arg (ap, double);
break;
case 's':
total_width += strlen (va_arg (ap, char *));
break;
case 'p':
case 'n':
va_arg (ap, char *);
break;
}
}
}
#ifdef TEST
global_total_width = total_width;
#endif
*result = malloc (total_width);
if (*result != NULL)
return vsprintf (*result, format, args);
else
return 0;
}
#ifdef TEST
void
checkit (va_alist)
va_dcl
{
va_list args;
char *format;
char *result;
va_start (args);
format = va_arg (args, char *);
vasprintf (&result, format, args);
if (strlen (result) < global_total_width)
printf ("PASS: ");
else
printf ("FAIL: ");
printf ("%d %s\n", global_total_width, result);
}
int
main ()
{
checkit ("%d", 0x12345678);
checkit ("%200d", 5);
checkit ("%.300d", 6);
checkit ("%100.150d", 7);
checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
777777777777777777333333333333366666666666622222222222777777777777733333");
checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx");
}
#endif /* TEST */

View File

@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!