summaryrefslogtreecommitdiff
path: root/bfd/coffcode.h
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r--bfd/coffcode.h319
1 files changed, 154 insertions, 165 deletions
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 7ce60db76c1..ee50a10993c 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1,24 +1,24 @@
/* Support for the generic parts of most COFF variants, for BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002
+ 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Cygnus Support.
-This file is part of BFD, the Binary File Descriptor library.
+ 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 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.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
Most of this hacked by Steve Chamberlain,
@@ -225,7 +225,7 @@ SUBSUBSECTION
This routine runs though the provided symbol table and uses
the offsets generated by the previous pass and the pointers
generated when the symbol table was read in to create the
- structured hierachy required by coff. It changes each pointer
+ structured hierarchy required by coff. It changes each pointer
to a symbol into the index into the symbol table of the asymbol.
o <<coff_write_symbols>>
@@ -558,15 +558,15 @@ sec_to_styp_flags (sec_name, sec_flags)
/* For now, the read/write bits are mapped onto SEC_READONLY, even
though the semantics don't quite match. The bits from the input
- are retained in pei_section_data(abfd, section)->pe_flags */
+ are retained in pei_section_data(abfd, section)->pe_flags. */
- styp_flags |= IMAGE_SCN_MEM_READ; /* always readable. */
+ styp_flags |= IMAGE_SCN_MEM_READ; /* Always readable. */
if ((sec_flags & SEC_READONLY) == 0)
- styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write */
+ styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write. */
if (sec_flags & SEC_CODE)
- styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE */
+ styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE. */
if (sec_flags & SEC_SHARED)
- styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful */
+ styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful. */
return styp_flags;
}
@@ -693,12 +693,12 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
else
sec_flags |= SEC_ALLOC | SEC_LOAD;
-#ifdef STYP_LIT /* A29k readonly text/data section type */
+#ifdef STYP_LIT /* A29k readonly text/data section type. */
if ((styp_flags & STYP_LIT) == STYP_LIT)
sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
#endif /* STYP_LIT */
-#ifdef STYP_OTHER_LOAD /* Other loaded sections */
+#ifdef STYP_OTHER_LOAD /* Other loaded sections. */
if (styp_flags & STYP_OTHER_LOAD)
sec_flags = (SEC_LOAD | SEC_ALLOC);
#endif /* STYP_SDATA */
@@ -802,7 +802,7 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
gas-generated, and look for <something> (whatever
follows the $) as the comdat symbol. */
- /* All 3 branches use this */
+ /* All 3 branches use this. */
symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
if (symname == NULL)
@@ -930,7 +930,7 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
#ifndef TARGET_UNDERSCORE
#define TARGET_UNDERSCORE 0
#endif
- /* Is this the name we're looking for? */
+ /* Is this the name we're looking for ? */
if (strcmp (target_name,
symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
{
@@ -1344,7 +1344,8 @@ Special entry points for gdb to swap in coff symbol table parts:
.#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
+. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook)\
+. (abfd, filehdr, aouthdr))
.
.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
@@ -1369,7 +1370,8 @@ Special entry points for gdb to swap in coff symbol table parts:
. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
. (abfd, file, base, symbol, aux, indaux))
.
-.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
+.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order,\
+. reloc, data, src_ptr, dst_ptr)\
. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
.
@@ -1397,7 +1399,8 @@ Special entry points for gdb to swap in coff symbol table parts:
.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
. (obfd, info, ibfd, sec, rel, adjustedp))
-.#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
+.#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
+. value, string, cp, coll, hashp)\
. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
.
@@ -1420,14 +1423,13 @@ coff_bad_format_hook (abfd, filehdr)
if (BADMAG (*internal_f))
return FALSE;
- /* if the optional header is NULL or not the correct size then
+ /* If the optional header is NULL or not the correct size then
quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
and Intel 960 readwrite headers (I960WRMAGIC) is that the
optional header is of a different size.
But the mips keeps extra stuff in it's opthdr, so dont check
- when doing that
- */
+ when doing that. */
#if defined(M88) || defined(I960)
if (internal_f->f_opthdr != 0 && bfd_coff_aoutsz (abfd) != internal_f->f_opthdr)
@@ -1453,6 +1455,7 @@ coff_set_custom_section_alignment (abfd, section, alignment_table, table_size)
for (i = 0; i < table_size; ++i)
{
const char *secname = bfd_get_section_name (abfd, section);
+
if (alignment_table[i].comparison_length == (unsigned int) -1
? strcmp (alignment_table[i].name, secname) == 0
: strncmp (alignment_table[i].name, secname,
@@ -1566,13 +1569,13 @@ coff_set_alignment_hook (abfd, section, scnhdr)
unsigned int i;
#ifdef I960
- /* Extract ALIGN from 2**ALIGN stored in section header */
+ /* Extract ALIGN from 2**ALIGN stored in section header. */
for (i = 0; i < 32; i++)
if ((1 << i) >= hdr->s_align)
break;
#endif
#ifdef TIC80COFF
- /* TI tools puts the alignment power in bits 8-11 */
+ /* TI tools puts the alignment power in bits 8-11. */
i = (hdr->s_flags >> 8) & 0xF ;
#endif
#ifdef COFF_DECODE_ALIGNMENT
@@ -1588,7 +1591,7 @@ coff_set_alignment_hook (abfd, section, scnhdr)
#else /* ! COFF_ALIGN_IN_SECTION_HEADER */
#ifdef COFF_WITH_PE
-/* a couple of macros to help setting the alignment power field */
+/* A couple of macros to help setting the alignment power field. */
#define ALIGN_SET(field,x,y) \
if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x )\
{\
@@ -1649,7 +1652,7 @@ coff_set_alignment_hook (abfd, section, scnhdr)
section->lma = hdr->s_vaddr;
- /* check for extended relocs */
+ /* Check for extended relocs. */
if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
{
struct external_reloc dst;
@@ -1745,6 +1748,7 @@ coff_mkobject (abfd)
#endif
/* Create the COFF backend specific information. */
+
#ifndef coff_mkobject_hook
static PTR
coff_mkobject_hook (abfd, filehdr, aouthdr)
@@ -2125,7 +2129,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
#ifdef TICOFF0MAGIC
#ifdef TICOFF_TARGET_ARCH
- /* this TI COFF section should be used by all new TI COFF v0 targets */
+ /* This TI COFF section should be used by all new TI COFF v0 targets. */
case TICOFF0MAGIC:
arch = TICOFF_TARGET_ARCH;
machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
@@ -2134,8 +2138,8 @@ coff_set_arch_mach_hook (abfd, filehdr)
#endif
#ifdef TICOFF1MAGIC
- /* this TI COFF section should be used by all new TI COFF v1/2 targets */
- /* TI COFF1 and COFF2 use the target_id field to specify which arch */
+ /* This TI COFF section should be used by all new TI COFF v1/2 targets. */
+ /* TI COFF1 and COFF2 use the target_id field to specify which arch. */
case TICOFF1MAGIC:
case TICOFF2MAGIC:
switch (internal_f->f_target_id)
@@ -2174,7 +2178,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
break;
#endif
- default: /* Unreadable input file type */
+ default: /* Unreadable input file type. */
arch = bfd_arch_obscure;
break;
}
@@ -2215,7 +2219,6 @@ static bfd_boolean coff_pointerize_aux_hook
PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
unsigned int, combined_entry_type *));
-/*ARGSUSED*/
static bfd_boolean
coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
bfd *abfd ATTRIBUTE_UNUSED;
@@ -2255,7 +2258,6 @@ static bfd_boolean coff_pointerize_aux_hook
PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
unsigned int, combined_entry_type *));
-/*ARGSUSED*/
static bfd_boolean
coff_pointerize_aux_hook (abfd, table_base, symbol, indaux, aux)
bfd *abfd ATTRIBUTE_UNUSED;
@@ -2360,7 +2362,7 @@ SUBSUBSECTION
static int compare_arelent_ptr PARAMS ((const PTR, const PTR));
-/* AUX's ld wants relocations to be sorted */
+/* AUX's ld wants relocations to be sorted. */
static int
compare_arelent_ptr (x, y)
const PTR x;
@@ -2393,7 +2395,7 @@ coff_write_relocs (abfd, first_undef)
p = s->orelocation;
#else
{
- /* sort relocations before we write them out */
+ /* Sort relocations before we write them out. */
bfd_size_type amt;
amt = s->reloc_count;
@@ -2412,10 +2414,11 @@ coff_write_relocs (abfd, first_undef)
#ifdef COFF_WITH_PE
if (obj_pe (abfd) && s->reloc_count >= 0xffff)
{
- /* encode real count here as first reloc */
+ /* Encode real count here as first reloc. */
struct internal_reloc n;
+
memset ((PTR) & n, 0, sizeof (n));
- /* add one to count *this* reloc (grr) */
+ /* Add one to count *this* reloc (grr). */
n.r_vaddr = s->reloc_count + 1;
coff_swap_reloc_out (abfd, &n, &dst);
if (bfd_bwrite ((PTR) & dst, (bfd_size_type) bfd_coff_relsz (abfd),
@@ -2428,6 +2431,7 @@ coff_write_relocs (abfd, first_undef)
{
struct internal_reloc n;
arelent *q = p[i];
+
memset ((PTR) & n, 0, sizeof (n));
/* Now we've renumbered the symbols we know where the
@@ -2445,11 +2449,13 @@ coff_write_relocs (abfd, first_undef)
int j;
const char *sname = q->sym_ptr_ptr[0]->name;
asymbol **outsyms = abfd->outsymbols;
+
for (j = first_undef; outsyms[j]; j++)
{
const char *intable = outsyms[j]->name;
+
if (strcmp (intable, sname) == 0) {
- /* got a hit, so repoint the reloc */
+ /* Got a hit, so repoint the reloc. */
q->sym_ptr_ptr = outsyms + j;
break;
}
@@ -2492,12 +2498,13 @@ coff_write_relocs (abfd, first_undef)
#endif
#ifdef SELECT_RELOC
- /* Work out reloc type from what is required */
+ /* Work out reloc type from what is required. */
SELECT_RELOC (n, q->howto);
#else
n.r_type = q->howto->type;
#endif
coff_swap_reloc_out (abfd, &n, &dst);
+
if (bfd_bwrite ((PTR) & dst, (bfd_size_type) bfd_coff_relsz (abfd),
abfd) != bfd_coff_relsz (abfd))
return FALSE;
@@ -2593,12 +2600,12 @@ coff_set_flags (abfd, magicp, flagsp)
#ifdef TICOFF_DEFAULT_MAGIC
case TICOFF_TARGET_ARCH:
- /* if there's no indication of which version we want, use the default */
+ /* If there's no indication of which version we want, use the default. */
if (!abfd->xvec )
*magicp = TICOFF_DEFAULT_MAGIC;
else
{
- /* we may want to output in a different COFF version */
+ /* We may want to output in a different COFF version. */
switch (abfd->xvec->name[4])
{
case '0':
@@ -3091,8 +3098,8 @@ coff_compute_section_file_positions (abfd)
#ifdef ALIGN_SECTIONS_IN_FILE
if ((abfd->flags & EXEC_P) != 0)
{
- /* make sure this section is aligned on the right boundary - by
- padding the previous section up if necessary */
+ /* Make sure this section is aligned on the right boundary - by
+ padding the previous section up if necessary. */
old_sofar = sofar;
#ifdef RS6000COFF_C
@@ -3128,9 +3135,7 @@ coff_compute_section_file_positions (abfd)
}
#endif
if (previous != (asection *) NULL)
- {
- previous->_raw_size += sofar - old_sofar;
- }
+ previous->_raw_size += sofar - old_sofar;
}
#endif
@@ -3152,7 +3157,7 @@ coff_compute_section_file_positions (abfd)
sofar += current->_raw_size;
#ifdef ALIGN_SECTIONS_IN_FILE
- /* make sure that this section is of the right size too */
+ /* Make sure that this section is of the right size too. */
if ((abfd->flags & EXEC_P) == 0)
{
bfd_size_type old_size;
@@ -3241,10 +3246,11 @@ coff_add_missing_symbols (abfd)
{
coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
const char *name;
+
if (csym)
{
- /* only do this if there is a coff representation of the input
- symbol */
+ /* Only do this if there is a coff representation of the input
+ symbol. */
if (csym->native && csym->native->u.syment.n_sclass == C_FILE)
{
need_file = 0;
@@ -3278,11 +3284,11 @@ coff_add_missing_symbols (abfd)
if (!sympp2)
return FALSE;
memcpy (sympp2, sympp, i * sizeof (asymbol *));
+
if (need_file)
- {
- /* @@ Generate fake .file symbol, in sympp2[i], and increment i. */
- abort ();
- }
+ /* @@ Generate fake .file symbol, in sympp2[i], and increment i. */
+ abort ();
+
if (need_text)
sympp2[i++] = coff_section_symbol (abfd, _TEXT);
if (need_data)
@@ -3419,7 +3425,7 @@ coff_write_object_contents (abfd)
bfd_set_error (bfd_error_system_call);
/* Make a pass through the symbol table to count line number entries and
- put them into the correct asections */
+ put them into the correct asections. */
lnno_size = coff_count_linenumbers (abfd) * bfd_coff_linesz (abfd);
@@ -3431,13 +3437,13 @@ coff_write_object_contents (abfd)
reloc_base = obj_relocbase (abfd);
- /* Work out the size of the reloc and linno areas */
+ /* Work out the size of the reloc and linno areas. */
for (current = abfd->sections; current != NULL; current =
current->next)
{
#ifdef COFF_WITH_PE
- /* we store the actual reloc count in the first reloc's addr */
+ /* We store the actual reloc count in the first reloc's addr. */
if (obj_pe (abfd) && current->reloc_count >= 0xffff)
reloc_count ++;
#endif
@@ -3449,7 +3455,7 @@ coff_write_object_contents (abfd)
lineno_base = reloc_base + reloc_size;
sym_base = lineno_base + lnno_size;
- /* Indicate in each section->line_filepos its actual file address */
+ /* Indicate in each section->line_filepos its actual file address. */
for (current = abfd->sections; current != NULL; current =
current->next)
{
@@ -3468,7 +3474,7 @@ coff_write_object_contents (abfd)
current->rel_filepos = reloc_base;
reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
#ifdef COFF_WITH_PE
- /* extra reloc to hold real count */
+ /* Extra reloc to hold real count. */
if (obj_pe (abfd) && current->reloc_count >= 0xffff)
reloc_base += bfd_coff_relsz (abfd);
#endif
@@ -3564,19 +3570,14 @@ coff_write_object_contents (abfd)
section.s_paddr = 0;
#endif
- /*
- If this section has no size or is unloadable then the scnptr
- will be 0 too
- */
+ /* If this section has no size or is unloadable then the scnptr
+ will be 0 too. */
if (current->_raw_size == 0 ||
(current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- {
- section.s_scnptr = 0;
- }
+ section.s_scnptr = 0;
else
- {
- section.s_scnptr = current->filepos;
- }
+ section.s_scnptr = current->filepos;
+
section.s_relptr = current->rel_filepos;
section.s_lnnoptr = current->line_filepos;
section.s_nreloc = current->reloc_count;
@@ -3606,17 +3607,11 @@ coff_write_object_contents (abfd)
section.s_flags = sec_to_styp_flags (current->name, current->flags);
if (!strcmp (current->name, _TEXT))
- {
- text_sec = current;
- }
+ text_sec = current;
else if (!strcmp (current->name, _DATA))
- {
- data_sec = current;
- }
+ data_sec = current;
else if (!strcmp (current->name, _BSS))
- {
- bss_sec = current;
- }
+ bss_sec = current;
#ifdef I960
section.s_align = (current->alignment_power
@@ -3624,7 +3619,7 @@ coff_write_object_contents (abfd)
: 0);
#endif
#ifdef TIC80COFF
- /* TI COFF puts the alignment power in bits 8-11 of the flags */
+ /* TI COFF puts the alignment power in bits 8-11 of the flags. */
section.s_flags |= (current->alignment_power & 0xF) << 8;
#endif
#ifdef COFF_ENCODE_ALIGNMENT
@@ -3781,14 +3776,11 @@ coff_write_object_contents (abfd)
/* Don't include the internal abs section in the section count */
- /*
- We will NOT put a fucking timestamp in the header here. Every time you
+ /* We will NOT put a fucking timestamp in the header here. Every time you
put it back, I will come in and take it out again. I'm sorry. This
field does not belong here. We fill it with a 0 so it compares the
- same but is not a reasonable time. -- gnu@cygnus.com
- */
+ same but is not a reasonable time. -- gnu@cygnus.com */
internal_f.f_timdat = 0;
-
internal_f.f_flags = 0;
if (abfd->flags & EXEC_P)
@@ -3825,18 +3817,16 @@ coff_write_object_contents (abfd)
#endif
#ifdef TI_TARGET_ID
- /* target id is used in TI COFF v1 and later; COFF0 won't use this field,
- but it doesn't hurt to set it internally */
+ /* Target id is used in TI COFF v1 and later; COFF0 won't use this field,
+ but it doesn't hurt to set it internally. */
internal_f.f_target_id = TI_TARGET_ID;
#endif
#ifdef TIC80_TARGET_ID
internal_f.f_target_id = TIC80_TARGET_ID;
#endif
- /*
- FIXME, should do something about the other byte orders and
- architectures.
- */
+ /* FIXME, should do something about the other byte orders and
+ architectures. */
#ifdef RS6000COFF_C
if ((abfd->flags & DYNAMIC) != 0)
@@ -3847,11 +3837,11 @@ coff_write_object_contents (abfd)
memset (&internal_a, 0, sizeof internal_a);
- /* Set up architecture-dependent stuff */
-
+ /* Set up architecture-dependent stuff. */
{
unsigned int magic = 0;
unsigned short flags = 0;
+
coff_set_flags (abfd, &magic, &flags);
internal_f.f_magic = magic;
internal_f.f_flags |= flags;
@@ -3860,14 +3850,13 @@ coff_write_object_contents (abfd)
#ifdef A29K
#ifdef ULTRA3 /* NYU's machine */
/* FIXME: This is a bogus check. I really want to see if there
- * is a .shbss or a .shdata section, if so then set the magic
- * number to indicate a shared data executable.
- */
+ is a .shbss or a .shdata section, if so then set the magic
+ number to indicate a shared data executable. */
if (internal_f.f_nscns >= 7)
- internal_a.magic = SHMAGIC; /* Shared magic */
+ internal_a.magic = SHMAGIC; /* Shared magic. */
else
#endif /* ULTRA3 */
- internal_a.magic = NMAGIC; /* Assume separate i/d */
+ internal_a.magic = NMAGIC; /* Assume separate i/d. */
#define __A_MAGIC_SET__
#endif /* A29K */
#ifdef TICOFF_AOUT_MAGIC
@@ -3982,7 +3971,7 @@ coff_write_object_contents (abfd)
/* FIXME: Does anybody ever set this to another value? */
internal_a.vstamp = 0;
- /* Now should write relocs, strings, syms */
+ /* Now should write relocs, strings, syms. */
obj_sym_filepos (abfd) = sym_base;
if (bfd_get_symcount (abfd) != 0)
@@ -4165,7 +4154,7 @@ coff_write_object_contents (abfd)
if (abfd->flags & EXEC_P)
{
/* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
- include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)) */
+ include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)). */
char * buff;
bfd_size_type amount = bfd_coff_aoutsz (abfd);
@@ -4214,7 +4203,7 @@ coff_set_section_contents (abfd, section, location, offset, count)
file_ptr offset;
bfd_size_type count;
{
- if (! abfd->output_has_begun) /* set by bfd.c handler */
+ if (! abfd->output_has_begun) /* Set by bfd.c handler. */
{
if (! coff_compute_section_file_positions (abfd))
return FALSE;
@@ -4241,7 +4230,7 @@ coff_set_section_contents (abfd, section, location, offset, count)
code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
<robertl@arnet.com> (Thanks!).
- Gvran Uddeborg <gvran@uddeborg.pp.se> */
+ Gvran Uddeborg <gvran@uddeborg.pp.se>. */
if (strcmp (section->name, _LIB) == 0)
{
@@ -4365,6 +4354,7 @@ coff_slurp_line_table (abfd, asect)
while (counter < asect->lineno_count)
{
struct internal_lineno dst;
+
bfd_coff_swap_lineno_in (abfd, src, &dst);
cache_ptr->line_number = dst.l_lnno;
@@ -4430,19 +4420,16 @@ coff_slurp_symbol_table (abfd)
coff_symbol_type *cached_area;
unsigned int *table_ptr;
bfd_size_type amt;
-
unsigned int number_of_symbols = 0;
if (obj_symbols (abfd))
return TRUE;
- /* Read in the symbol table */
+ /* Read in the symbol table. */
if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
- {
- return FALSE;
- } /* on error */
+ return FALSE;
- /* Allocate enough room for all the symbols in cached form */
+ /* Allocate enough room for all the symbols in cached form. */
amt = obj_raw_syment_count (abfd);
amt *= sizeof (coff_symbol_type);
cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
@@ -4460,6 +4447,7 @@ coff_slurp_symbol_table (abfd)
coff_symbol_type *dst = cached_area;
unsigned int last_native_index = obj_raw_syment_count (abfd);
unsigned int this_index = 0;
+
while (this_index < last_native_index)
{
combined_entry_type *src = native_symbols + this_index;
@@ -4483,8 +4471,7 @@ coff_slurp_symbol_table (abfd)
dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
#endif
- /* Fall through to next case */
-
+ /* Fall through to next case. */
#endif
case C_EXT:
@@ -4497,10 +4484,10 @@ coff_slurp_symbol_table (abfd)
case C_HIDEXT:
#endif
#ifdef C_SYSTEM
- case C_SYSTEM: /* System Wide variable */
+ case C_SYSTEM: /* System Wide variable. */
#endif
#ifdef COFF_WITH_PE
- /* In PE, 0x68 (104) denotes a section symbol */
+ /* In PE, 0x68 (104) denotes a section symbol. */
case C_SECTION:
/* In PE, 0x69 (105) denotes a weak external symbol. */
case C_NT_WEAK:
@@ -4574,16 +4561,16 @@ coff_slurp_symbol_table (abfd)
break;
- case C_STAT: /* static */
+ case C_STAT: /* Static. */
#ifdef I960
- case C_LEAFSTAT: /* static leaf procedure */
+ case C_LEAFSTAT: /* Static leaf procedure. */
#endif
#if defined ARM
- case C_THUMBSTAT: /* Thumb static */
- case C_THUMBLABEL: /* Thumb label */
- case C_THUMBSTATFUNC:/* Thumb static function */
+ case C_THUMBSTAT: /* Thumb static. */
+ case C_THUMBLABEL: /* Thumb label. */
+ case C_THUMBSTATFUNC:/* Thumb static function. */
#endif
- case C_LABEL: /* label */
+ case C_LABEL: /* Label. */
if (src->u.syment.n_scnum == N_DEBUG)
dst->symbol.flags = BSF_DEBUGGING;
else
@@ -4606,35 +4593,35 @@ coff_slurp_symbol_table (abfd)
dst->symbol.value = src->u.syment.n_value;
break;
- case C_MOS: /* member of structure */
- case C_EOS: /* end of structure */
-#ifdef NOTDEF /* C_AUTOARG has the same value */
+ case C_MOS: /* Member of structure. */
+ case C_EOS: /* End of structure. */
+#ifdef NOTDEF /* C_AUTOARG has the same value. */
#ifdef C_GLBLREG
- case C_GLBLREG: /* A29k-specific storage class */
+ case C_GLBLREG: /* A29k-specific storage class. */
#endif
#endif
- case C_REGPARM: /* register parameter */
- case C_REG: /* register variable */
- /* C_AUTOARG conflictes with TI COFF C_UEXT */
+ case C_REGPARM: /* Register parameter. */
+ case C_REG: /* register variable. */
+ /* C_AUTOARG conflictes with TI COFF C_UEXT. */
#if !defined (TIC80COFF) && !defined (TICOFF)
#ifdef C_AUTOARG
- case C_AUTOARG: /* 960-specific storage class */
+ case C_AUTOARG: /* 960-specific storage class. */
#endif
#endif
- case C_TPDEF: /* type definition */
+ case C_TPDEF: /* Type definition. */
case C_ARG:
- case C_AUTO: /* automatic variable */
- case C_FIELD: /* bit field */
- case C_ENTAG: /* enumeration tag */
- case C_MOE: /* member of enumeration */
- case C_MOU: /* member of union */
- case C_UNTAG: /* union tag */
+ case C_AUTO: /* Automatic variable. */
+ case C_FIELD: /* Bit field. */
+ case C_ENTAG: /* Enumeration tag. */
+ case C_MOE: /* Member of enumeration. */
+ case C_MOU: /* Member of union. */
+ case C_UNTAG: /* Union tag. */
dst->symbol.flags = BSF_DEBUGGING;
dst->symbol.value = (src->u.syment.n_value);
break;
- case C_FILE: /* file name */
- case C_STRTAG: /* structure tag */
+ case C_FILE: /* File name. */
+ case C_STRTAG: /* Structure tag. */
#ifdef RS6000COFF_C
case C_GSYM:
case C_LSYM:
@@ -4654,8 +4641,8 @@ coff_slurp_symbol_table (abfd)
break;
#ifdef RS6000COFF_C
- case C_BINCL: /* beginning of include file */
- case C_EINCL: /* ending of include file */
+ case C_BINCL: /* Beginning of include file. */
+ case C_EINCL: /* Ending of include file. */
/* The value is actually a pointer into the line numbers
of the file. We locate the line number entry, and
set the section to the section which contains it, and
@@ -4696,9 +4683,9 @@ coff_slurp_symbol_table (abfd)
break;
#endif
- case C_BLOCK: /* ".bb" or ".eb" */
- case C_FCN: /* ".bf" or ".ef" (or PE ".lf") */
- case C_EFCN: /* physical end of function */
+ case C_BLOCK: /* ".bb" or ".eb". */
+ case C_FCN: /* ".bf" or ".ef" (or PE ".lf"). */
+ case C_EFCN: /* Physical end of function. */
#if defined COFF_WITH_PE
/* PE sets the symbol to a value relative to the start
of the section. */
@@ -4720,7 +4707,7 @@ coff_slurp_symbol_table (abfd)
#endif
break;
- case C_STATLAB: /* Static load time label */
+ case C_STATLAB: /* Static load time label. */
dst->symbol.value = src->u.syment.n_value;
dst->symbol.flags = BSF_GLOBAL;
break;
@@ -4733,22 +4720,22 @@ coff_slurp_symbol_table (abfd)
&& src->u.syment.n_scnum == 0)
break;
/* Fall through. */
- case C_EXTDEF: /* external definition */
- case C_ULABEL: /* undefined label */
- case C_USTATIC: /* undefined static */
+ case C_EXTDEF: /* External definition. */
+ case C_ULABEL: /* Undefined label. */
+ case C_USTATIC: /* Undefined static. */
#ifndef COFF_WITH_PE
/* C_LINE in regular coff is 0x68. NT has taken over this storage
- class to represent a section symbol */
- case C_LINE: /* line # reformatted as symbol table entry */
+ class to represent a section symbol. */
+ case C_LINE: /* line # reformatted as symbol table entry. */
/* NT uses 0x67 for a weak symbol, not C_ALIAS. */
- case C_ALIAS: /* duplicate tag */
+ case C_ALIAS: /* Duplicate tag. */
#endif
- /* New storage classes for TI COFF */
+ /* New storage classes for TI COFF. */
#if defined(TIC80COFF) || defined(TICOFF)
- case C_UEXT: /* Tentative external definition */
+ case C_UEXT: /* Tentative external definition. */
#endif
- case C_EXTLAB: /* External load time label */
- case C_HIDDEN: /* ext symbol in dmert public lib */
+ case C_EXTLAB: /* External load time label. */
+ case C_HIDDEN: /* Ext symbol in dmert public lib. */
default:
(*_bfd_error_handler)
(_("%s: Unrecognized storage class %d for %s symbol `%s'"),
@@ -4768,17 +4755,18 @@ coff_slurp_symbol_table (abfd)
this_index += (src->u.syment.n_numaux) + 1;
dst++;
number_of_symbols++;
- } /* walk the native symtab */
- } /* bfdize the native symtab */
+ }
+ }
obj_symbols (abfd) = cached_area;
obj_raw_syments (abfd) = native_symbols;
bfd_get_symcount (abfd) = number_of_symbols;
obj_convert (abfd) = table_ptr;
- /* Slurp the line tables for each section too */
+ /* Slurp the line tables for each section too. */
{
asection *p;
+
p = abfd->sections;
while (p)
{
@@ -4786,6 +4774,7 @@ coff_slurp_symbol_table (abfd)
p = p->next;
}
}
+
return TRUE;
} /* coff_slurp_symbol_table() */
@@ -5012,15 +5001,15 @@ coff_slurp_reloc_table (abfd, asect, symbols)
refering to the symbols in the raw data have not been
modified, so we have to have a negative addend to compensate.
- Note that symbols which used to be common must be left alone */
+ Note that symbols which used to be common must be left alone. */
- /* Calculate any reloc addend by looking at the symbol */
+ /* Calculate any reloc addend by looking at the symbol. */
CALC_ADDEND (abfd, ptr, dst, cache_ptr);
cache_ptr->address -= asect->vma;
/* !! cache_ptr->section = (asection *) NULL;*/
- /* Fill in the cache_ptr->howto field from dst.r_type */
+ /* Fill in the cache_ptr->howto field from dst.r_type. */
RTYPE2HOWTO (cache_ptr, &dst);
#endif /* RELOC_PROCESSING */
@@ -5088,16 +5077,16 @@ coff_canonicalize_reloc (abfd, section, relptr, symbols)
if (section->flags & SEC_CONSTRUCTOR)
{
- /* this section has relocs made up by us, they are not in the
- file, so take them out of their chain and place them into
- the data area provided */
+ /* This section has relocs made up by us, they are not in the
+ file, so take them out of their chain and place them into
+ the data area provided. */
arelent_chain *chain = section->constructor_chain;
+
for (count = 0; count < section->reloc_count; count++)
{
*relptr++ = &chain->relent;
chain = chain->next;
}
-
}
else
{