/* Generic ECOFF (Extended-COFF) routines.
- Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
Original version by Per Bothner.
Full support added by Ian Lance Taylor, ian@cygnus.com.
#include "libbfd.h"
#include "aout/ar.h"
#include "aout/ranlib.h"
+#include "aout/stab_gnu.h"
/* FIXME: We need the definitions of N_SET[ADTB], but aout64.h defines
some other stuff which we don't want and which conflicts with stuff
/* Prototypes for static functions. */
static int ecoff_get_magic PARAMS ((bfd *abfd));
+static long ecoff_sec_to_styp_flags PARAMS ((const char *name,
+ flagword flags));
static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *abfd));
static boolean ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym,
asymbol *asym, int ext,
/* Create an ECOFF object. */
boolean
-ecoff_mkobject (abfd)
+_bfd_ecoff_mkobject (abfd)
bfd *abfd;
{
abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
specific information. */
PTR
-ecoff_mkobject_hook (abfd, filehdr, aouthdr)
+_bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
bfd *abfd;
PTR filehdr;
PTR aouthdr;
struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr;
ecoff_data_type *ecoff;
- if (ecoff_mkobject (abfd) == false)
+ if (_bfd_ecoff_mkobject (abfd) == false)
return NULL;
ecoff = ecoff_data (abfd);
ecoff->fprmask = internal_a->fprmask;
if (internal_a->magic == ECOFF_AOUT_ZMAGIC)
abfd->flags |= D_PAGED;
+ else
+ abfd->flags &=~ D_PAGED;
}
/* It turns out that no special action is required by the MIPS or
/*ARGSUSED*/
asection *
-ecoff_make_section_hook (abfd, name)
+_bfd_ecoff_make_section_hook (abfd, name)
bfd *abfd;
char *name;
{
/* Initialize a new section. */
boolean
-ecoff_new_section_hook (abfd, section)
+_bfd_ecoff_new_section_hook (abfd, section)
bfd *abfd;
asection *section;
{
/* For the .pdata section, which has a special meaning on the Alpha,
- we set the alignment to 8. We correct this later in
+ we set the alignment power to 3. We correct this later in
ecoff_compute_section_file_positions. We do this hackery because
we need to know the exact unaligned size of the .pdata section in
- order to set the lnnoptr field correctly. */
+ order to set the lnnoptr field correctly. For every other
+ section we use an alignment power of 4; this could be made target
+ dependent by adding a field to ecoff_backend_data, but 4 appears
+ to be correct for both the MIPS and the Alpha. */
if (strcmp (section->name, _PDATA) == 0)
section->alignment_power = 3;
else
- section->alignment_power = abfd->xvec->align_power_min;
+ section->alignment_power = 4;
if (strcmp (section->name, _TEXT) == 0)
section->flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
for each target, but there aren't all that many ECOFF targets. */
boolean
-ecoff_set_arch_mach_hook (abfd, filehdr)
+_bfd_ecoff_set_arch_mach_hook (abfd, filehdr)
bfd *abfd;
PTR filehdr;
{
}
/* Get the magic number to use based on the architecture and machine.
- This is the inverse of ecoff_set_arch_mach_hook, above. */
+ This is the inverse of _bfd_ecoff_set_arch_mach_hook, above. */
static int
ecoff_get_magic (abfd)
/* Get the section s_flags to use for a section. */
-long
+static long
ecoff_sec_to_styp_flags (name, flags)
- CONST char *name;
+ const char *name;
flagword flags;
{
long styp;
/*ARGSUSED*/
flagword
-ecoff_styp_to_sec_flags (abfd, hdr)
+_bfd_ecoff_styp_to_sec_flags (abfd, hdr, name)
bfd *abfd;
PTR hdr;
+ const char *name;
{
struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
long styp_flags = internal_s->s_flags;
return sec_flags;
}
\f
-/* Routines to swap auxiliary information in and out. I am assuming
- that the auxiliary information format is always going to be target
- independent. */
-
-/* Swap in a type information record.
- BIGEND says whether AUX symbols are big-endian or little-endian; this
- info comes from the file header record (fh-fBigendian). */
-
-void
-ecoff_swap_tir_in (bigend, ext_copy, intern)
- int bigend;
- struct tir_ext *ext_copy;
- TIR *intern;
-{
- struct tir_ext ext[1];
-
- *ext = *ext_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
- intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
- intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
- >> TIR_BITS1_BT_SH_BIG;
- intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
- >> TIR_BITS_TQ4_SH_BIG;
- intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
- >> TIR_BITS_TQ5_SH_BIG;
- intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
- >> TIR_BITS_TQ0_SH_BIG;
- intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
- >> TIR_BITS_TQ1_SH_BIG;
- intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
- >> TIR_BITS_TQ2_SH_BIG;
- intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
- >> TIR_BITS_TQ3_SH_BIG;
- } else {
- intern->fBitfield = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
- intern->continued = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
- intern->bt = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
- >> TIR_BITS1_BT_SH_LITTLE;
- intern->tq4 = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
- >> TIR_BITS_TQ4_SH_LITTLE;
- intern->tq5 = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
- >> TIR_BITS_TQ5_SH_LITTLE;
- intern->tq0 = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
- >> TIR_BITS_TQ0_SH_LITTLE;
- intern->tq1 = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
- >> TIR_BITS_TQ1_SH_LITTLE;
- intern->tq2 = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
- >> TIR_BITS_TQ2_SH_LITTLE;
- intern->tq3 = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
- >> TIR_BITS_TQ3_SH_LITTLE;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a type information record.
- BIGEND says whether AUX symbols are big-endian or little-endian; this
- info comes from the file header record (fh-fBigendian). */
-
-void
-ecoff_swap_tir_out (bigend, intern_copy, ext)
- int bigend;
- TIR *intern_copy;
- struct tir_ext *ext;
-{
- TIR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
- | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
- | ((intern->bt << TIR_BITS1_BT_SH_BIG)
- & TIR_BITS1_BT_BIG));
- ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
- & TIR_BITS_TQ4_BIG)
- | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
- & TIR_BITS_TQ5_BIG));
- ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
- & TIR_BITS_TQ0_BIG)
- | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
- & TIR_BITS_TQ1_BIG));
- ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
- & TIR_BITS_TQ2_BIG)
- | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
- & TIR_BITS_TQ3_BIG));
- } else {
- ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
- | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
- | ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
- & TIR_BITS1_BT_LITTLE));
- ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
- & TIR_BITS_TQ4_LITTLE)
- | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
- & TIR_BITS_TQ5_LITTLE));
- ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
- & TIR_BITS_TQ0_LITTLE)
- | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
- & TIR_BITS_TQ1_LITTLE));
- ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
- & TIR_BITS_TQ2_LITTLE)
- | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
- & TIR_BITS_TQ3_LITTLE));
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in a relative symbol record. BIGEND says whether it is in
- big-endian or little-endian format.*/
-
-void
-ecoff_swap_rndx_in (bigend, ext_copy, intern)
- int bigend;
- struct rndx_ext *ext_copy;
- RNDXR *intern;
-{
- struct rndx_ext ext[1];
-
- *ext = *ext_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
- | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
- >> RNDX_BITS1_RFD_SH_BIG);
- intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
- << RNDX_BITS1_INDEX_SH_LEFT_BIG)
- | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
- | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
- } else {
- intern->rfd = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
- | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
- << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
- intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
- >> RNDX_BITS1_INDEX_SH_LITTLE)
- | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
- | ((unsigned int) ext->r_bits[3]
- << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a relative symbol record. BIGEND says whether it is in
- big-endian or little-endian format.*/
-
-void
-ecoff_swap_rndx_out (bigend, intern_copy, ext)
- int bigend;
- RNDXR *intern_copy;
- struct rndx_ext *ext;
-{
- RNDXR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bigend) {
- ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
- ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
- & RNDX_BITS1_RFD_BIG)
- | ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
- & RNDX_BITS1_INDEX_BIG));
- ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
- ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
- } else {
- ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
- ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
- & RNDX_BITS1_RFD_LITTLE)
- | ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
- & RNDX_BITS1_INDEX_LITTLE));
- ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
- ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-\f
/* Read in the symbolic header for an ECOFF object file. */
static boolean
}
/* Read in and swap the important symbolic information for an ECOFF
- object file. This is called by gdb. */
+ object file. This is called by gdb via the read_debug_info entry
+ point in the backend structure. */
+/*ARGSUSED*/
boolean
-ecoff_slurp_symbolic_info (abfd)
+_bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug)
bfd *abfd;
+ asection *ignore;
+ struct ecoff_debug_info *debug;
{
const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
HDRR *internal_symhdr;
bfd_size_type raw_end;
bfd_size_type cb_end;
+ BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info);
+
/* Check whether we've already gotten it, and whether there's any to
get. */
if (ecoff_data (abfd)->raw_syments != (PTR) NULL)
if (! ecoff_slurp_symbolic_header (abfd))
return false;
- internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
+ internal_symhdr = &debug->symbolic_header;
/* Read all the symbolic information at once. */
raw_base = (ecoff_data (abfd)->sym_filepos
/* Get pointers for the numeric offsets in the HDRR structure. */
#define FIX(off1, off2, type) \
if (internal_symhdr->off1 == 0) \
- ecoff_data (abfd)->debug_info.off2 = (type) NULL; \
+ debug->off2 = (type) NULL; \
else \
- ecoff_data (abfd)->debug_info.off2 = (type) ((char *) raw \
- + internal_symhdr->off1 \
- - raw_base)
+ debug->off2 = (type) ((char *) raw \
+ + internal_symhdr->off1 \
+ - raw_base)
FIX (cbLineOffset, line, unsigned char *);
FIX (cbDnOffset, external_dnr, PTR);
FIX (cbPdOffset, external_pdr, PTR);
We need to look at the fdr to deal with a lot of information in
the symbols, so we swap them here. */
- ecoff_data (abfd)->debug_info.fdr =
- (struct fdr *) bfd_alloc (abfd,
- (internal_symhdr->ifdMax *
- sizeof (struct fdr)));
- if (ecoff_data (abfd)->debug_info.fdr == NULL)
+ debug->fdr = (struct fdr *) bfd_alloc (abfd,
+ (internal_symhdr->ifdMax *
+ sizeof (struct fdr)));
+ if (debug->fdr == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
external_fdr_size = backend->debug_swap.external_fdr_size;
- fdr_ptr = ecoff_data (abfd)->debug_info.fdr;
- fraw_src = (char *) ecoff_data (abfd)->debug_info.external_fdr;
+ fdr_ptr = debug->fdr;
+ fraw_src = (char *) debug->external_fdr;
fraw_end = fraw_src + internal_symhdr->ifdMax * external_fdr_size;
for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
(*backend->debug_swap.swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
/* Create an empty symbol. */
asymbol *
-ecoff_make_empty_symbol (abfd)
+_bfd_ecoff_make_empty_symbol (abfd)
bfd *abfd;
{
ecoff_symbol_type *new;
asym->the_bfd = abfd;
asym->value = ecoff_sym->value;
asym->section = &bfd_debug_section;
- asym->udata = NULL;
+ asym->udata.i = 0;
/* An indirect symbol requires two consecutive stabs symbols. */
if (*indirect_ptr_ptr != (asymbol *) NULL)
(*indirect_ptr_ptr)->value = (bfd_vma) asym;
asym->flags = BSF_DEBUGGING;
- asym->section = &bfd_und_section;
+ asym->section = bfd_und_section_ptr;
*indirect_ptr_ptr = NULL;
return true;
}
&& (ECOFF_UNMARK_STAB (ecoff_sym->index) | N_EXT) == (N_INDR | N_EXT))
{
asym->flags = BSF_DEBUGGING | BSF_INDIRECT;
- asym->section = &bfd_ind_section;
+ asym->section = bfd_ind_section_ptr;
/* Pass this symbol on to the next call to this function. */
*indirect_ptr_ptr = asym;
return true;
if (ext)
asym->flags = BSF_EXPORT | BSF_GLOBAL;
else
- asym->flags = BSF_LOCAL;
+ {
+ asym->flags = BSF_LOCAL;
+ /* Normally, a local stProc symbol will have a corresponding
+ external symbol. We mark the local symbol as a debugging
+ symbol, in order to prevent nm from printing both out.
+ Similarly, we mark stLabel and stabs symbols as debugging
+ symbols. In both cases, we do want to set the value
+ correctly based on the symbol class. */
+ if (ecoff_sym->st == stProc
+ || ecoff_sym->st == stLabel
+ || ECOFF_IS_STAB (ecoff_sym))
+ asym->flags |= BSF_DEBUGGING;
+ }
switch (ecoff_sym->sc)
{
case scNil:
asym->flags = BSF_DEBUGGING;
break;
case scAbs:
- asym->section = &bfd_abs_section;
+ asym->section = bfd_abs_section_ptr;
break;
case scUndefined:
- asym->section = &bfd_und_section;
+ asym->section = bfd_und_section_ptr;
asym->flags = 0;
asym->value = 0;
break;
case scCommon:
if (asym->value > ecoff_data (abfd)->gp_size)
{
- asym->section = &bfd_com_section;
+ asym->section = bfd_com_section_ptr;
asym->flags = 0;
break;
}
asym->flags = BSF_DEBUGGING;
break;
case scSUndefined:
- asym->section = &bfd_und_section;
+ asym->section = bfd_und_section_ptr;
asym->flags = 0;
asym->value = 0;
break;
/* Read an ECOFF symbol table. */
boolean
-ecoff_slurp_symbol_table (abfd)
+_bfd_ecoff_slurp_symbol_table (abfd)
bfd *abfd;
{
const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
return true;
/* Get the symbolic information. */
- if (ecoff_slurp_symbolic_info (abfd) == false)
+ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
+ &ecoff_data (abfd)->debug_info))
return false;
if (bfd_get_symcount (abfd) == 0)
return true;
/* Return the amount of space needed for the canonical symbols. */
long
-ecoff_get_symtab_upper_bound (abfd)
+_bfd_ecoff_get_symtab_upper_bound (abfd)
bfd *abfd;
{
- if (! ecoff_slurp_symbolic_info (abfd))
+ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL,
+ &ecoff_data (abfd)->debug_info))
return -1;
if (bfd_get_symcount (abfd) == 0)
/* Get the canonical symbols. */
long
-ecoff_get_symtab (abfd, alocation)
+_bfd_ecoff_get_symtab (abfd, alocation)
bfd *abfd;
asymbol **alocation;
{
ecoff_symbol_type *symbase;
ecoff_symbol_type **location = (ecoff_symbol_type **) alocation;
- if (ecoff_slurp_symbol_table (abfd) == false)
+ if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
return -1;
if (bfd_get_symcount (abfd) == 0)
return 0;
} qualifiers[7];
unsigned int basic_type;
int i;
- static char buffer1[1024];
+ char buffer1[1024];
static char buffer2[1024];
char *p1 = buffer1;
char *p2 = buffer2;
if (AUX_GET_ISYM (bigendian, &aux_ptr[indx]) == -1)
return "-1 (no type)";
- ecoff_swap_tir_in (bigendian, &aux_ptr[indx++].a_ti, &u.ti);
+ _bfd_ecoff_swap_tir_in (bigendian, &aux_ptr[indx++].a_ti, &u.ti);
basic_type = u.ti.bt;
qualifiers[0].type = u.ti.tq0;
2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
case btStruct: /* Structure (Record) */
- ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
+ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
(long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
"struct");
2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
case btUnion: /* Union */
- ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
+ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
(long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
"union");
2nd word is file index if 1st word rfd is ST_RFDESCAPE. */
case btEnum: /* Enumeration */
- ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
+ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx);
ecoff_emit_aggregate (abfd, fdr, p1, &rndx,
(long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]),
"enum");
/*ARGSUSED*/
void
-ecoff_get_symbol_info (abfd, symbol, ret)
+_bfd_ecoff_get_symbol_info (abfd, symbol, ret)
bfd *abfd; /* Ignored. */
asymbol *symbol;
symbol_info *ret;
/* Print information about an ECOFF symbol. */
void
-ecoff_print_symbol (abfd, filep, symbol, how)
+_bfd_ecoff_print_symbol (abfd, filep, symbol, how)
bfd *abfd;
PTR filep;
asymbol *symbol;
|| (section->flags & SEC_CONSTRUCTOR) != 0)
return true;
- if (ecoff_slurp_symbol_table (abfd) == false)
+ if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
return false;
internal_relocs = (arelent *) bfd_alloc (abfd,
else if (intern.r_symndx == RELOC_SECTION_NONE
|| intern.r_symndx == RELOC_SECTION_ABS)
{
- rptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
rptr->addend = 0;
}
else
/* Get a canonical list of relocs. */
long
-ecoff_canonicalize_reloc (abfd, section, relptr, symbols)
+_bfd_ecoff_canonicalize_reloc (abfd, section, relptr, symbols)
bfd *abfd;
asection *section;
arelent **relptr;
/*ARGSUSED*/
boolean
-ecoff_find_nearest_line (abfd,
- section,
- ignore_symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- retline_ptr)
+_bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset,
+ filename_ptr, functionname_ptr, retline_ptr)
bfd *abfd;
asection *section;
asymbol **ignore_symbols;
{
const struct ecoff_debug_swap * const debug_swap
= &ecoff_backend (abfd)->debug_swap;
- FDR *fdr_ptr;
- FDR *fdr_start;
- FDR *fdr_end;
- FDR *fdr_hold;
- bfd_size_type external_pdr_size;
- char *pdr_ptr;
- char *pdr_end;
- PDR pdr;
- unsigned char *line_ptr;
- unsigned char *line_end;
- int lineno;
+ struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info;
+ struct ecoff_find_line *line_info;
/* If we're not in the .text section, we don't have any line
numbers. */
return false;
/* Make sure we have the FDR's. */
- if (ecoff_slurp_symbolic_info (abfd) == false
+ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL, debug_info)
|| bfd_get_symcount (abfd) == 0)
return false;
- /* Each file descriptor (FDR) has a memory address. Here we track
- down which FDR we want. The FDR's are stored in increasing
- memory order. If speed is ever important, this can become a
- binary search. We must ignore FDR's with no PDR entries; they
- will have the adr of the FDR before or after them. */
- fdr_start = ecoff_data (abfd)->debug_info.fdr;
- fdr_end = fdr_start + ecoff_data (abfd)->debug_info.symbolic_header.ifdMax;
- fdr_hold = (FDR *) NULL;
- for (fdr_ptr = fdr_start; fdr_ptr < fdr_end; fdr_ptr++)
- {
- if (fdr_ptr->cpd == 0)
- continue;
- if (offset < fdr_ptr->adr)
- break;
- fdr_hold = fdr_ptr;
- }
- if (fdr_hold == (FDR *) NULL)
- return false;
- fdr_ptr = fdr_hold;
-
- /* Each FDR has a list of procedure descriptors (PDR). PDR's also
- have an address, which is relative to the FDR address, and are
- also stored in increasing memory order. */
- offset -= fdr_ptr->adr;
- external_pdr_size = debug_swap->external_pdr_size;
- pdr_ptr = ((char *) ecoff_data (abfd)->debug_info.external_pdr
- + fdr_ptr->ipdFirst * external_pdr_size);
- pdr_end = pdr_ptr + fdr_ptr->cpd * external_pdr_size;
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
-
- /* The address of the first PDR is an offset which applies to the
- addresses of all the PDR's. */
- offset += pdr.adr;
-
- for (pdr_ptr += external_pdr_size;
- pdr_ptr < pdr_end;
- pdr_ptr += external_pdr_size)
- {
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
- if (offset < pdr.adr)
- break;
- }
-
- /* Now we can look for the actual line number. The line numbers are
- stored in a very funky format, which I won't try to describe.
- Note that right here pdr_ptr and pdr hold the PDR *after* the one
- we want; we need this to compute line_end. */
- line_end = ecoff_data (abfd)->debug_info.line;
- if (pdr_ptr == pdr_end)
- line_end += fdr_ptr->cbLineOffset + fdr_ptr->cbLine;
- else
- line_end += fdr_ptr->cbLineOffset + pdr.cbLineOffset;
-
- /* Now change pdr and pdr_ptr to the one we want. */
- pdr_ptr -= external_pdr_size;
- (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
-
- offset -= pdr.adr;
- lineno = pdr.lnLow;
- line_ptr = (ecoff_data (abfd)->debug_info.line
- + fdr_ptr->cbLineOffset
- + pdr.cbLineOffset);
- while (line_ptr < line_end)
+ if (ecoff_data (abfd)->find_line_info == NULL)
{
- int delta;
- int count;
-
- delta = *line_ptr >> 4;
- if (delta >= 0x8)
- delta -= 0x10;
- count = (*line_ptr & 0xf) + 1;
- ++line_ptr;
- if (delta == -8)
+ ecoff_data (abfd)->find_line_info =
+ ((struct ecoff_find_line *)
+ bfd_alloc (abfd, sizeof (struct ecoff_find_line)));
+ if (ecoff_data (abfd)->find_line_info == NULL)
{
- delta = (((line_ptr[0]) & 0xff) << 8) + ((line_ptr[1]) & 0xff);
- if (delta >= 0x8000)
- delta -= 0x10000;
- line_ptr += 2;
+ bfd_set_error (bfd_error_no_memory);
+ return false;
}
- lineno += delta;
- if (offset < count * 4)
- break;
- offset -= count * 4;
+ ecoff_data (abfd)->find_line_info->find_buffer = NULL;
+ ecoff_data (abfd)->find_line_info->fdrtab_len = 0;
+ ecoff_data (abfd)->find_line_info->fdrtab = NULL;
}
+ line_info = ecoff_data (abfd)->find_line_info;
- /* If fdr_ptr->rss is -1, then this file does not have full symbols,
- at least according to gdb/mipsread.c. */
- if (fdr_ptr->rss == -1)
- {
- *filename_ptr = NULL;
- if (pdr.isym == -1)
- *functionname_ptr = NULL;
- else
- {
- EXTR proc_ext;
-
- (*debug_swap->swap_ext_in)
- (abfd,
- ((char *) ecoff_data (abfd)->debug_info.external_ext
- + pdr.isym * debug_swap->external_ext_size),
- &proc_ext);
- *functionname_ptr = (ecoff_data (abfd)->debug_info.ssext
- + proc_ext.asym.iss);
- }
- }
- else
- {
- SYMR proc_sym;
-
- *filename_ptr = (ecoff_data (abfd)->debug_info.ss
- + fdr_ptr->issBase
- + fdr_ptr->rss);
- (*debug_swap->swap_sym_in)
- (abfd,
- ((char *) ecoff_data (abfd)->debug_info.external_sym
- + (fdr_ptr->isymBase + pdr.isym) * debug_swap->external_sym_size),
- &proc_sym);
- *functionname_ptr = (ecoff_data (abfd)->debug_info.ss
- + fdr_ptr->issBase
- + proc_sym.iss);
- }
- if (lineno == ilineNil)
- lineno = 0;
- *retline_ptr = lineno;
- return true;
+ return _bfd_ecoff_locate_line (abfd, section, offset, debug_info,
+ debug_swap, line_info, filename_ptr,
+ functionname_ptr, retline_ptr);
}
\f
/* Copy private BFD data. This is called by objcopy and strip. We
information. */
boolean
-ecoff_bfd_copy_private_bfd_data (ibfd, obfd)
+_bfd_ecoff_bfd_copy_private_bfd_data (ibfd, obfd)
bfd *ibfd;
bfd *obfd;
{
size_t c;
boolean local;
- BFD_ASSERT (ibfd->xvec == obfd->xvec);
+ /* This function is selected based on the input vector. We only
+ want to copy information over if the output BFD also uses ECOFF
+ format. */
+ if (bfd_get_flavour (obfd) != bfd_target_ecoff_flavour)
+ return true;
/* Copy the GP value and the register masks. */
ecoff_data (obfd)->gp = ecoff_data (ibfd)->gp;
callers ignore the return value. */
boolean
-ecoff_set_arch_mach (abfd, arch, machine)
+_bfd_ecoff_set_arch_mach (abfd, arch, machine)
bfd *abfd;
enum bfd_architecture arch;
unsigned long machine;
/*ARGSUSED*/
int
-ecoff_sizeof_headers (abfd, reloc)
+_bfd_ecoff_sizeof_headers (abfd, reloc)
bfd *abfd;
boolean reloc;
{
/* Get the contents of a section. */
boolean
-ecoff_get_section_contents (abfd, section, location, offset, count)
+_bfd_ecoff_get_section_contents (abfd, section, location, offset, count)
bfd *abfd;
asection *section;
PTR location;
file_ptr old_sofar;
boolean first_data;
- sofar = ecoff_sizeof_headers (abfd, false);
+ sofar = _bfd_ecoff_sizeof_headers (abfd, false);
first_data = true;
for (current = abfd->sections;
/* Set the contents of a section. */
boolean
-ecoff_set_section_contents (abfd, section, location, offset, count)
+_bfd_ecoff_set_section_contents (abfd, section, location, offset, count)
bfd *abfd;
asection *section;
PTR location;
symbol. */
if ((esym->asym.sc == scUndefined
|| esym->asym.sc == scSUndefined)
- && bfd_get_section (sym) != &bfd_und_section)
+ && ! bfd_is_und_section (bfd_get_section (sym)))
esym->asym.sc = scAbs;
/* Adjust the FDR index for the symbol by that used for the input
/* Write out an ECOFF file. */
boolean
-ecoff_write_object_contents (abfd)
+_bfd_ecoff_write_object_contents (abfd)
bfd *abfd;
{
const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
}
if ((abfd->flags & D_PAGED) != 0)
- text_size = ecoff_sizeof_headers (abfd, false);
+ text_size = _bfd_ecoff_sizeof_headers (abfd, false);
else
text_size = 0;
text_start = 0;
section.s_flags = ecoff_sec_to_styp_flags (current->name,
current->flags);
- bfd_coff_swap_scnhdr_out (abfd, (PTR) §ion, buff);
- if (bfd_write (buff, 1, scnhsz, abfd) != scnhsz)
+ if (bfd_coff_swap_scnhdr_out (abfd, (PTR) §ion, buff) == 0
+ || bfd_write (buff, 1, scnhsz, abfd) != scnhsz)
goto error_return;
if ((section.s_flags & STYP_TEXT) != 0
goto error_return;
/* Build the external symbol information. This must be done before
- writing out the relocs so that we know the symbol indices. The
- condition checks makes sure this object was not created by
- ecoff_bfd_final_link, since if it was we do not want to tamper
- with the external symbols. */
- if (bfd_get_outsymbols (abfd) != (asymbol **) NULL)
+ writing out the relocs so that we know the symbol indices. We
+ don't do this if this BFD was created by the backend linker,
+ since it will have already handled the symbols and relocs. */
+ if (! ecoff_data (abfd)->linker)
{
symhdr->iextMax = 0;
symhdr->issExtMax = 0;
/* Read in the armap. */
boolean
-ecoff_slurp_armap (abfd)
+_bfd_ecoff_slurp_armap (abfd)
bfd *abfd;
{
char nextname[17];
/* Write out an armap. */
boolean
-ecoff_write_armap (abfd, elength, map, orl_count, stridx)
+_bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx)
bfd *abfd;
unsigned int elength;
struct orl *map;
/* See whether this BFD is an archive. If it is, read in the armap
and the extended name table. */
-bfd_target *
-ecoff_archive_p (abfd)
+const bfd_target *
+_bfd_ecoff_archive_p (abfd)
bfd *abfd;
{
char armag[SARMAG + 1];
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
/* We are setting bfd_ardata(abfd) here, but since bfd_ardata
if (bfd_ardata (abfd) == (struct artdata *) NULL)
{
bfd_set_error (bfd_error_no_memory);
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
bfd_ardata (abfd)->first_file_filepos = SARMAG;
bfd_ardata (abfd)->extended_names = NULL;
bfd_ardata (abfd)->tdata = NULL;
- if (ecoff_slurp_armap (abfd) == false
- || ecoff_slurp_extended_name_table (abfd) == false)
+ if (_bfd_ecoff_slurp_armap (abfd) == false
+ || _bfd_ecoff_slurp_extended_name_table (abfd) == false)
{
bfd_release (abfd, bfd_ardata (abfd));
abfd->tdata.aout_ar_data = (struct artdata *) NULL;
- return (bfd_target *) NULL;
+ return (const bfd_target *) NULL;
}
return abfd->xvec;
/* Set local fields. */
ret->indx = -1;
ret->abfd = NULL;
+ ret->written = 0;
+ ret->small = 0;
}
memset ((PTR) &ret->esym, 0, sizeof ret->esym);
/* Create an ECOFF link hash table. */
struct bfd_link_hash_table *
-ecoff_bfd_link_hash_table_create (abfd)
+_bfd_ecoff_bfd_link_hash_table_create (abfd)
bfd *abfd;
{
struct ecoff_link_hash_table *ret;
appropriate. */
boolean
-ecoff_bfd_link_add_symbols (abfd, info)
+_bfd_ecoff_bfd_link_add_symbols (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
{
if (! bfd_has_map (abfd))
{
- bfd_set_error (bfd_error_no_symbols);
+ /* An empty archive is a special case. */
+ if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
+ return true;
+ bfd_set_error (bfd_error_no_armap);
return false;
}
value -= section->vma;
break;
case scAbs:
- section = &bfd_abs_section;
+ section = bfd_abs_section_ptr;
break;
case scUndefined:
- section = &bfd_und_section;
+ section = bfd_und_section_ptr;
break;
case scSData:
section = bfd_make_section_old_way (abfd, ".sdata");
case scCommon:
if (value > ecoff_data (abfd)->gp_size)
{
- section = &bfd_com_section;
+ section = bfd_com_section_ptr;
break;
}
/* Fall through. */
section = &ecoff_scom_section;
break;
case scSUndefined:
- section = &bfd_und_section;
+ section = bfd_und_section_ptr;
break;
case scInit:
section = bfd_make_section_old_way (abfd, ".init");
if (info->hash->creator->flavour == bfd_get_flavour (abfd))
{
if (h->abfd == (bfd *) NULL
- || (section != &bfd_und_section
+ || (! bfd_is_und_section (section)
&& (! bfd_is_com_section (section)
- || h->root.type != bfd_link_hash_defined)))
+ || (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak))))
{
h->abfd = abfd;
h->esym = esym;
}
+
+ /* Remember whether this symbol was small undefined. */
+ if (esym.asym.sc == scSUndefined)
+ h->small = 1;
+
+ /* If this symbol was ever small undefined, it needs to wind
+ up in a GP relative section. We can't control the
+ section of a defined symbol, but we can control the
+ section of a common symbol. This case is actually needed
+ on Ultrix 4.2 to handle the symbol cred in -lckrb. */
+ if (h->small
+ && h->root.type == bfd_link_hash_common
+ && strcmp (h->root.u.c.p->section->name, SCOMMON) != 0)
+ {
+ h->root.u.c.p->section = bfd_make_section_old_way (abfd,
+ SCOMMON);
+ h->root.u.c.p->section->flags = SEC_ALLOC;
+ if (h->esym.asym.sc == scCommon)
+ h->esym.asym.sc = scSCommon;
+ }
}
}
close and reopen some input BFDs; I'll see how bad this is. */
boolean
-ecoff_bfd_final_link (abfd, info)
+_bfd_ecoff_bfd_final_link (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
{
bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax;
+ ecoff_data (abfd)->linker = true;
+
return true;
}
}
/* If raw_syments is not NULL, then the data was already by read by
- ecoff_slurp_symbolic_info. */
+ _bfd_ecoff_slurp_symbolic_info. */
if (ecoff_data (input_bfd)->raw_syments == NULL)
{
READ (line, cbLineOffset, cbLine, sizeof (unsigned char),
/* FIXME: We should check if this symbol is being stripped. */
- if (h->root.written)
+ if (h->written)
return true;
if (h->abfd == (bfd *) NULL)
h->esym.asym.value = 0;
h->esym.asym.st = stGlobal;
- if (h->root.type != bfd_link_hash_defined)
+ if (h->root.type != bfd_link_hash_defined
+ && h->root.type != bfd_link_hash_defweak)
h->esym.asym.sc = scAbs;
else
{
case bfd_link_hash_new:
abort ();
case bfd_link_hash_undefined:
- case bfd_link_hash_weak:
+ case bfd_link_hash_undefweak:
if (h->esym.asym.sc != scUndefined
&& h->esym.asym.sc != scSUndefined)
h->esym.asym.sc = scUndefined;
break;
case bfd_link_hash_defined:
+ case bfd_link_hash_defweak:
if (h->esym.asym.sc == scUndefined
|| h->esym.asym.sc == scSUndefined)
h->esym.asym.sc = scAbs;
/* bfd_ecoff_debug_one_external uses iextMax to keep track of the
symbol number. */
h->indx = ecoff_data (output_bfd)->debug_info.symbolic_header.iextMax;
- h->root.written = true;
+ h->written = 1;
return (bfd_ecoff_debug_one_external
(output_bfd, &ecoff_data (output_bfd)->debug_info,
rel.address = link_order->offset;
rel.howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
- if (rel.howto == (const reloc_howto_type *) NULL)
+ if (rel.howto == 0)
{
bfd_set_error (bfd_error_bad_value);
return false;