summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-10-07 08:53:42 +0000
committerNathan Sidwell <nathan@codesourcery.com>2003-10-07 08:53:42 +0000
commitafcc52fc8495e679fc81a84742293766923ec731 (patch)
treeb0a8022beebbab966af0a853db1654acd03c6288 /bfd
parent663de987e6b34497f8aa33aa67f0ddf6da983ebc (diff)
downloadbinutils-redhat-afcc52fc8495e679fc81a84742293766923ec731.tar.gz
bfd/Changelog:
* libbfd-in.h (_bfd_link_section_stabs): Add string offset parameter. * cofflink.c (coff_link_add_symbols): Deal with split stab sections. * elflink.h (elf_link_add_object_symbols): Deal with split stab sections. * stabs.c (_bfd_link_section_stabs): Add string offset parameter. * libbfd.h: Regenerated. ld/ChangeLog: * ldwrite.c (unsplittable_name): New. (clone_section): Strip existing numeric suffix. Only truncate names for coff targets. (split_sections): Use unsplittable_name. binutils/ChangeLog: * objdump.c (read_section_stabs): Just read one section, return pointer to it. Add size parameter. (print_section_stabs): Add string offset parameter. Adjust. (struct stab_section_names): Add string offset member. (find_stabs_sections): Correct check for split section suffix, adjust read_section_stabs and print_section_stabs calls. (dump_stabs_section): Clear string_offset, free string table.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/cofflink.c26
-rw-r--r--bfd/elflink.h47
-rw-r--r--bfd/libbfd-in.h2
-rw-r--r--bfd/libbfd.h2
-rw-r--r--bfd/stabs.c11
6 files changed, 63 insertions, 34 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 177f6ab8c3..3c471df150 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
2003-10-07 Nathan Sidwell <nathan@codesourcery.com>
+ * libbfd-in.h (_bfd_link_section_stabs): Add string offset
+ parameter.
+ * cofflink.c (coff_link_add_symbols): Deal with split stab
+ sections.
+ * elflink.h (elf_link_add_object_symbols): Deal with split stab
+ sections.
+ * stabs.c (_bfd_link_section_stabs): Add string offset parameter.
+ * libbfd.h: Regenerated.
+
* coffcode.h (coff_set_alignment_hook): With PE_COFF reloc
overflow, set reloc start position to after the count
reloc. Subtract one from num relocs. Give error on 0xffff relocs
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 1b059f6bf5..dbe7fbf100 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -570,19 +570,24 @@ coff_link_add_symbols (bfd *abfd,
&& info->hash->creator->flavour == bfd_get_flavour (abfd)
&& (info->strip != strip_all && info->strip != strip_debugger))
{
- asection *stab, *stabstr;
+ asection *stabstr;
- stab = bfd_get_section_by_name (abfd, ".stab");
- if (stab != NULL)
- {
- stabstr = bfd_get_section_by_name (abfd, ".stabstr");
+ stabstr = bfd_get_section_by_name (abfd, ".stabstr");
- if (stabstr != NULL)
+ if (stabstr != NULL)
+ {
+ bfd_size_type string_offset = 0;
+ asection *stab;
+
+ for (stab = abfd->sections; stab; stab = stab->next)
+ if (strncmp (".stab", stab->name, 5) == 0
+ && (!stab->name[5]
+ || (stab->name[5] == '.' && isdigit (stab->name[6]))))
{
struct coff_link_hash_table *table;
- struct coff_section_tdata *secdata;
-
- secdata = coff_section_data (abfd, stab);
+ struct coff_section_tdata *secdata
+ = coff_section_data (abfd, stab);
+
if (secdata == NULL)
{
amt = sizeof (struct coff_section_tdata);
@@ -596,7 +601,8 @@ coff_link_add_symbols (bfd *abfd,
if (! _bfd_link_section_stabs (abfd, &table->stab_info,
stab, stabstr,
- &secdata->stab_info))
+ &secdata->stab_info,
+ &string_offset))
goto error_return;
}
}
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 48b86cf36f..bd94cbf4fc 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -20,6 +20,8 @@
/* ELF linker code. */
+#include "safe-ctype.h"
+
static bfd_boolean elf_link_add_object_symbols (bfd *, struct bfd_link_info *);
static bfd_boolean elf_link_add_archive_symbols (bfd *,
struct bfd_link_info *);
@@ -1607,27 +1609,32 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
&& is_elf_hash_table (info)
&& (info->strip != strip_all && info->strip != strip_debugger))
{
- asection *stab, *stabstr;
-
- stab = bfd_get_section_by_name (abfd, ".stab");
- if (stab != NULL
- && (stab->flags & SEC_MERGE) == 0
- && !bfd_is_abs_section (stab->output_section))
+ asection *stabstr;
+
+ stabstr = bfd_get_section_by_name (abfd, ".stabstr");
+ if (stabstr != NULL)
{
- stabstr = bfd_get_section_by_name (abfd, ".stabstr");
-
- if (stabstr != NULL)
- {
- struct bfd_elf_section_data *secdata;
-
- secdata = elf_section_data (stab);
- if (! _bfd_link_section_stabs (abfd,
- & hash_table->stab_info,
- stab, stabstr,
- &secdata->sec_info))
- goto error_return;
- if (secdata->sec_info)
- stab->sec_info_type = ELF_INFO_TYPE_STABS;
+ bfd_size_type string_offset = 0;
+ asection *stab;
+
+ for (stab = abfd->sections; stab; stab = stab->next)
+ if (strncmp (".stab", stab->name, 5) == 0
+ && (!stab->name[5] ||
+ (stab->name[5] == '.' && ISDIGIT (stab->name[6])))
+ && (stab->flags & SEC_MERGE) == 0
+ && !bfd_is_abs_section (stab->output_section))
+ {
+ struct bfd_elf_section_data *secdata;
+
+ secdata = elf_section_data (stab);
+ if (! _bfd_link_section_stabs (abfd,
+ & hash_table->stab_info,
+ stab, stabstr,
+ &secdata->sec_info,
+ &string_offset))
+ goto error_return;
+ if (secdata->sec_info)
+ stab->sec_info_type = ELF_INFO_TYPE_STABS;
}
}
}
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 2c9c23cd44..d437f414aa 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -490,7 +490,7 @@ extern bfd_reloc_status_type _bfd_relocate_contents
/* Link stabs in sections in the first pass. */
extern bfd_boolean _bfd_link_section_stabs
- (bfd *, void **, asection *, asection *, void **);
+ (bfd *, void **, asection *, asection *, void **, bfd_size_type *);
/* Eliminate stabs for discarded functions and symbols. */
extern bfd_boolean _bfd_discard_section_stabs
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index a428c660c8..f8f820ee2e 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -495,7 +495,7 @@ extern bfd_reloc_status_type _bfd_relocate_contents
/* Link stabs in sections in the first pass. */
extern bfd_boolean _bfd_link_section_stabs
- (bfd *, void **, asection *, asection *, void **);
+ (bfd *, void **, asection *, asection *, void **, bfd_size_type *);
/* Eliminate stabs for discarded functions and symbols. */
extern bfd_boolean _bfd_discard_section_stabs
diff --git a/bfd/stabs.c b/bfd/stabs.c
index 6e6d290d46..13c60497ea 100644
--- a/bfd/stabs.c
+++ b/bfd/stabs.c
@@ -169,12 +169,13 @@ stab_link_includes_newfunc (entry, table, string)
pass of the linker. */
bfd_boolean
-_bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo)
+_bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo, pstring_offset)
bfd *abfd;
PTR *psinfo;
asection *stabsec;
asection *stabstrsec;
PTR *psecinfo;
+ bfd_size_type *pstring_offset;
{
bfd_boolean first;
struct stab_info *sinfo;
@@ -276,7 +277,11 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo)
and identify N_BINCL symbols which can be eliminated. */
stroff = 0;
- next_stroff = 0;
+ /* The stabs sections can be split when
+ -split-by-reloc/-split-by-file is used. We must keep track of
+ each stab section's place in the single concatenated string
+ table. */
+ next_stroff = pstring_offset ? *pstring_offset : 0;
skip = 0;
symend = stabbuf + stabsec->_raw_size;
@@ -302,6 +307,8 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo)
string table. We only copy the very first one. */
stroff = next_stroff;
next_stroff += bfd_get_32 (abfd, sym + 8);
+ if (pstring_offset)
+ *pstring_offset = next_stroff;
if (! first)
{
*pstridx = (bfd_size_type) -1;