summaryrefslogtreecommitdiff
path: root/bfd/peXXigen.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2009-04-20 01:09:43 +0000
committerAlan Modra <amodra@bigpond.net.au>2009-04-20 01:09:43 +0000
commit0001c65e41a5ef24db17a9abdbab0850e3a9d60b (patch)
treed67c378318c5e68e6e75af5fc35cfccfbebe1b1c /bfd/peXXigen.c
parent34f4222df0cd7d22da3ee7988c9680ad5628f789 (diff)
downloadbinutils-redhat-0001c65e41a5ef24db17a9abdbab0850e3a9d60b.tar.gz
2009-04-19 Peter O'Gorman <binutils@mlists.thewrittenword.com>
Alan Modra <amodra@bigpond.net.au> Dave Korn <dave.korn.cygwin@gmail.com> * peXXigen.c (_bfd_XXi_swap_sym_in): Fix name handling w.r.t long names and non-NUL-terminated strings.
Diffstat (limited to 'bfd/peXXigen.c')
-rw-r--r--bfd/peXXigen.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index db6af64ef3..fe712a6f0e 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -129,6 +129,9 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1)
they will be handled somewhat correctly in the bfd code. */
if (in->n_sclass == C_SECTION)
{
+ char namebuf[SYMNMLEN + 1];
+ const char *name;
+
in->n_value = 0x0;
/* Create synthetic empty sections as needed. DJ */
@@ -136,33 +139,38 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1)
{
asection *sec;
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- if (strcmp (sec->name, in->n_name) == 0)
- {
- in->n_scnum = sec->target_index;
- break;
- }
- }
+ name = _bfd_coff_internal_syment_name (abfd, in, namebuf);
+ if (name == NULL)
+ /* FIXME: Return error. */
+ abort ();
+ sec = bfd_get_section_by_name (abfd, name);
+ if (sec != NULL)
+ in->n_scnum = sec->target_index;
}
if (in->n_scnum == 0)
{
int unused_section_number = 0;
asection *sec;
- char *name;
flagword flags;
for (sec = abfd->sections; sec; sec = sec->next)
if (unused_section_number <= sec->target_index)
unused_section_number = sec->target_index + 1;
- name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
- if (name == NULL)
- return;
- strcpy (name, in->n_name);
+ if (name == namebuf)
+ {
+ name = bfd_alloc (abfd, strlen (namebuf) + 1);
+ if (name == NULL)
+ /* FIXME: Return error. */
+ abort ();
+ strcpy ((char *) name, namebuf);
+ }
flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
+ if (sec == NULL)
+ /* FIXME: Return error. */
+ abort ();
sec->vma = 0;
sec->lma = 0;