* stabs.c (struct stab_link_includes_table): Delete.
(stab_link_includes_lookup): Delete.
(_bfd_write_section_stabs, _bfd_write_stab_strings): Remove one
level of indirection from sinfo parm.
(_bfd_link_section_stabs): Likewise. Set SEC_LINKER_CREATED on
stabstr section. Adjust hash table accesses.
* coff-ppc.c (ppc_bfd_coff_final_link): Do include rawsize in contents
alloc. Adjust stab_info test.
* cofflink.c (_bfd_coff_link_hash_table_init): Clear stab_info.
(_bfd_coff_final_link): Adjust stab_info test.
(_bfd_coff_link_input_bfd): Ignore SEC_LINKER_CREATED sections.
* elf-bfd.h (struct elf_link_hash_table): Include struct stab_info
in place.
* libcoff-in.h (struct coff_link_hash_table): Likewise.
* elf.c (_bfd_elf_link_hash_table_init): Clear stab_info.
* elflink.c (bfd_elf_final_link): Don't attempt to link linker created
stabstr section. Adjust stab_info test.
* libbfd-in.h (_bfd_link_section_stabs, _bfd_write_section_stabs)
(_bfd_write_stab_strings): Adjust prototypes.
* libbfd.h: Regenerate.
* libcoff.h: Regenerate.
* bfd-in2.h: Regenerate.
+2004-06-28 Alan Modra <amodra@bigpond.net.au>
+
+ * bfd-in.h (struct stab_info): Move from stabs.c.
+ * stabs.c (struct stab_link_includes_table): Delete.
+ (stab_link_includes_lookup): Delete.
+ (_bfd_write_section_stabs, _bfd_write_stab_strings): Remove one
+ level of indirection from sinfo parm.
+ (_bfd_link_section_stabs): Likewise. Set SEC_LINKER_CREATED on
+ stabstr section. Adjust hash table accesses.
+ * coff-ppc.c (ppc_bfd_coff_final_link): Do include rawsize in contents
+ alloc. Adjust stab_info test.
+ * cofflink.c (_bfd_coff_link_hash_table_init): Clear stab_info.
+ (_bfd_coff_final_link): Adjust stab_info test.
+ (_bfd_coff_link_input_bfd): Ignore SEC_LINKER_CREATED sections.
+ * elf-bfd.h (struct elf_link_hash_table): Include struct stab_info
+ in place.
+ * libcoff-in.h (struct coff_link_hash_table): Likewise.
+ * elf.c (_bfd_elf_link_hash_table_init): Clear stab_info.
+ * elflink.c (bfd_elf_final_link): Don't attempt to link linker created
+ stabstr section. Adjust stab_info test.
+ * libbfd-in.h (_bfd_link_section_stabs, _bfd_write_section_stabs)
+ (_bfd_write_stab_strings): Adjust prototypes.
+ * libbfd.h: Regenerate.
+ * libcoff.h: Regenerate.
+ * bfd-in2.h: Regenerate.
+
2004-06-27 Mark Kettenis <kettenis@gnu.org>
From Miod Vallat <miod@online.fr>:
this size. */
extern void bfd_hash_set_default_size (bfd_size_type);
+/* This structure is used to keep track of stabs in sections
+ information while linking. */
+
+struct stab_info
+{
+ /* A hash table used to hold stabs strings. */
+ struct bfd_strtab_hash *strings;
+ /* The header file hash table. */
+ struct bfd_hash_table includes;
+ /* The first .stabstr section. */
+ struct bfd_section *stabstr;
+};
+
#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
/* User program access to BFD facilities. */
this size. */
extern void bfd_hash_set_default_size (bfd_size_type);
+/* This structure is used to keep track of stabs in sections
+ information while linking. */
+
+struct stab_info
+{
+ /* A hash table used to hold stabs strings. */
+ struct bfd_strtab_hash *strings;
+ /* The header file hash table. */
+ struct bfd_hash_table includes;
+ /* The first .stabstr section. */
+ struct bfd_section *stabstr;
+};
+
#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
/* User program access to BFD facilities. */
if (info->relocatable)
o->reloc_count += sec->reloc_count;
+ if (sec->rawsize > max_contents_size)
+ max_contents_size = sec->rawsize;
if (sec->size > max_contents_size)
max_contents_size = sec->size;
if (sec->lineno_count > max_lineno_count)
}
/* If we have optimized stabs strings, output them. */
- if (coff_hash_table (info)->stab_info != NULL)
+ if (coff_hash_table (info)->stab_info.stabstr != NULL)
{
if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
return FALSE;
struct bfd_hash_table *,
const char *))
{
- table->stab_info = NULL;
+ memset (&table->stab_info, 0, sizeof (table->stab_info));
return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
}
}
/* If we have optimized stabs strings, output them. */
- if (coff_hash_table (info)->stab_info != NULL)
+ if (coff_hash_table (info)->stab_info.stabstr != NULL)
{
if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
return FALSE;
/* This section was omitted from the link. */
continue;
+ if ((o->flags & SEC_LINKER_CREATED) != 0)
+ continue;
+
if ((o->flags & SEC_HAS_CONTENTS) == 0
|| (o->size == 0 && (o->flags & SEC_RELOC) == 0))
{
/* The _GLOBAL_OFFSET_TABLE_ symbol. */
struct elf_link_hash_entry *hgot;
- /* A pointer to information used to link stabs in sections. */
- void *stab_info;
-
/* A pointer to information used to merge SEC_MERGE sections. */
void *merge_info;
+ /* Used to link stabs in sections. */
+ struct stab_info stab_info;
+
/* Used by eh_frame code when editing .eh_frame. */
struct eh_frame_hdr_info eh_info;
table->bucketcount = 0;
table->needed = NULL;
table->hgot = NULL;
- table->stab_info = NULL;
table->merge_info = NULL;
+ memset (&table->stab_info, 0, sizeof (table->stab_info));
memset (&table->eh_info, 0, sizeof (table->eh_info));
table->dynlocal = NULL;
table->runpath = NULL;
secdata = elf_section_data (stab);
if (! _bfd_link_section_stabs (abfd,
- & hash_table->stab_info,
+ &hash_table->stab_info,
stab, stabstr,
&secdata->sec_info,
&string_offset))
created by _bfd_elf_link_create_dynamic_sections. */
continue;
}
+ if (elf_hash_table (info)->stab_info.stabstr == o)
+ continue;
if (elf_hash_table (info)->eh_info.hdr_sec == o)
continue;
if ((elf_section_data (o->output_section)->this_hdr.sh_type
}
/* If we have optimized stabs strings, output them. */
- if (elf_hash_table (info)->stab_info != NULL)
+ if (elf_hash_table (info)->stab_info.stabstr != NULL)
{
if (! _bfd_write_stab_strings (abfd, &elf_hash_table (info)->stab_info))
goto error_return;
/* Link stabs in sections in the first pass. */
extern bfd_boolean _bfd_link_section_stabs
- (bfd *, void **, asection *, asection *, void **, bfd_size_type *);
+ (bfd *, struct stab_info *, asection *, asection *, void **,
+ bfd_size_type *);
/* Eliminate stabs for discarded functions and symbols. */
extern bfd_boolean _bfd_discard_section_stabs
/* Write out the .stab section when linking stabs in sections. */
extern bfd_boolean _bfd_write_section_stabs
- (bfd *, void **, asection *, void **, bfd_byte *);
+ (bfd *, struct stab_info *, asection *, void **, bfd_byte *);
/* Write out the .stabstr string table when linking stabs in sections. */
extern bfd_boolean _bfd_write_stab_strings
- (bfd *, void **);
+ (bfd *, struct stab_info *);
/* Find an offset within a .stab section when linking stabs in
sections. */
/* Link stabs in sections in the first pass. */
extern bfd_boolean _bfd_link_section_stabs
- (bfd *, void **, asection *, asection *, void **, bfd_size_type *);
+ (bfd *, struct stab_info *, asection *, asection *, void **,
+ bfd_size_type *);
/* Eliminate stabs for discarded functions and symbols. */
extern bfd_boolean _bfd_discard_section_stabs
/* Write out the .stab section when linking stabs in sections. */
extern bfd_boolean _bfd_write_section_stabs
- (bfd *, void **, asection *, void **, bfd_byte *);
+ (bfd *, struct stab_info *, asection *, void **, bfd_byte *);
/* Write out the .stabstr string table when linking stabs in sections. */
extern bfd_boolean _bfd_write_stab_strings
- (bfd *, void **);
+ (bfd *, struct stab_info *);
/* Find an offset within a .stab section when linking stabs in
sections. */
{
struct bfd_link_hash_table root;
/* A pointer to information used to link stabs in sections. */
- PTR stab_info;
+ struct stab_info stab_info;
};
/* Look up an entry in a COFF linker hash table. */
{
struct bfd_link_hash_table root;
/* A pointer to information used to link stabs in sections. */
- PTR stab_info;
+ struct stab_info stab_info;
};
/* Look up an entry in a COFF linker hash table. */
#define VALOFF (8)
#define STABSIZE (12)
-/* A hash table used for header files with N_BINCL entries. */
-
-struct stab_link_includes_table
-{
- struct bfd_hash_table root;
-};
-
/* A linked list of totals that we have found for a particular header
file. A total is a unique identifier for a particular BINCL...EINCL
sequence of STABs that can be used to identify duplicate sequences.
struct stab_link_includes_totals *totals;
};
-/* Look up an entry in an the header file hash table. */
-
-#define stab_link_includes_lookup(table, string, create, copy) \
- ((struct stab_link_includes_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
/* This structure is used to hold a list of N_BINCL symbols, some of
which might be converted into N_EXCL symbols. */
bfd_size_type stridxs[1];
};
-/* This structure is used to keep track of stabs in sections
- information while linking. */
-
-struct stab_info
-{
- /* A hash table used to hold stabs strings. */
- struct bfd_strtab_hash *strings;
- /* The header file hash table. */
- struct stab_link_includes_table includes;
- /* The first .stabstr section. */
- asection *stabstr;
-};
-
static struct bfd_hash_entry *stab_link_includes_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
\f
pass of the linker. */
bfd_boolean
-_bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo, pstring_offset)
+_bfd_link_section_stabs (abfd, sinfo, stabsec, stabstrsec, psecinfo, pstring_offset)
bfd *abfd;
- PTR *psinfo;
+ struct stab_info *sinfo;
asection *stabsec;
asection *stabstrsec;
PTR *psecinfo;
bfd_size_type *pstring_offset;
{
bfd_boolean first;
- struct stab_info *sinfo;
bfd_size_type count, amt;
struct stab_section_info *secinfo;
bfd_byte *stabbuf = NULL;
first = FALSE;
- if (*psinfo == NULL)
+ if (sinfo->stabstr == NULL)
{
/* Initialize the stabs information we need to keep track of. */
first = TRUE;
- amt = sizeof (struct stab_info);
- *psinfo = (PTR) bfd_alloc (abfd, amt);
- if (*psinfo == NULL)
- goto error_return;
- sinfo = (struct stab_info *) *psinfo;
sinfo->strings = _bfd_stringtab_init ();
if (sinfo->strings == NULL)
goto error_return;
/* Make sure the first byte is zero. */
(void) _bfd_stringtab_add (sinfo->strings, "", TRUE, TRUE);
- if (! bfd_hash_table_init_n (&sinfo->includes.root,
+ if (! bfd_hash_table_init_n (&sinfo->includes,
stab_link_includes_newfunc,
251))
goto error_return;
sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
- sinfo->stabstr->flags |= SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
+ if (sinfo->stabstr == NULL)
+ goto error_return;
+ sinfo->stabstr->flags |= (SEC_HAS_CONTENTS | SEC_READONLY
+ | SEC_DEBUGGING | SEC_LINKER_CREATED);
}
- sinfo = (struct stab_info *) *psinfo;
-
/* Initialize the information we are going to store for this .stab
section. */
/* If we have already included a header file with the same
value, then replaced this one with an N_EXCL symbol. */
- incl_entry = stab_link_includes_lookup (&sinfo->includes, string,
- TRUE, TRUE);
+ incl_entry = (struct stab_link_includes_entry * )
+ bfd_hash_lookup (&sinfo->includes, string, TRUE, TRUE);
if (incl_entry == NULL)
goto error_return;
/* This is the first time we have seen this header file
with this set of stabs strings. */
t = ((struct stab_link_includes_totals *)
- bfd_hash_allocate (&sinfo->includes.root, sizeof *t));
+ bfd_hash_allocate (&sinfo->includes, sizeof *t));
if (t == NULL)
goto error_return;
t->sum_chars = sum_chars;
contents. */
bfd_boolean
-_bfd_write_section_stabs (output_bfd, psinfo, stabsec, psecinfo, contents)
+_bfd_write_section_stabs (output_bfd, sinfo, stabsec, psecinfo, contents)
bfd *output_bfd;
- PTR *psinfo;
+ struct stab_info *sinfo;
asection *stabsec;
PTR *psecinfo;
bfd_byte *contents;
{
- struct stab_info *sinfo;
struct stab_section_info *secinfo;
struct stab_excl_list *e;
bfd_byte *sym, *tosym, *symend;
bfd_size_type *pstridx;
- sinfo = (struct stab_info *) *psinfo;
secinfo = (struct stab_section_info *) *psecinfo;
if (secinfo == NULL)
/* Write out the .stabstr section. */
bfd_boolean
-_bfd_write_stab_strings (output_bfd, psinfo)
+_bfd_write_stab_strings (output_bfd, sinfo)
bfd *output_bfd;
- PTR *psinfo;
+ struct stab_info *sinfo;
{
- struct stab_info *sinfo;
-
- sinfo = (struct stab_info *) *psinfo;
-
- if (sinfo == NULL)
- return TRUE;
-
if (bfd_is_abs_section (sinfo->stabstr->output_section))
{
/* The section was discarded from the link. */
/* We no longer need the stabs information. */
_bfd_stringtab_free (sinfo->strings);
- bfd_hash_table_free (&sinfo->includes.root);
+ bfd_hash_table_free (&sinfo->includes);
return TRUE;
}