This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH-bfd] i386-mingw32-ld crash on x86_64 linux


Dave Korn wrote:
> Alan Modra wrote:
>> So, something like the following.  I won't commit this as it's
>> untested, and I'm not sure whether the ext->e.e_name[0] == 0 case
>> ought to be handled.
> 
>   Hmm.  That case will arise if the symbol name is long, and I guess it could
> be since we do allow long section names.  I'll whip up something based on your
> patch and run my standard set of testsuites on it.

  I remembered that we had a function to handle all the name-related
complications for us already, so I just used it.  It should be OK to call from
within _bfd_XXi_swap_sym_in, since it is often called immediately afterward in
callers of _bfd_XXi_swap_sym_in anyway.

  I'm running this through a test cycle.  Peter, would you care to test if it
fixes your specific problem?

bfd/ChangeLog

	* peXXigen.c (_bfd_XXi_swap_sym_in):  Fix name handling w.r.t
	long names and non-NUL-terminated strings.

    cheers,
      DaveK
--- bfd/peXXigen.c.orig	2009-04-18 15:03:32.437500000 +0100
+++ bfd/peXXigen.c	2009-04-18 15:20:45.796875000 +0100
@@ -129,6 +129,9 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void *
      they will be handled somewhat correctly in the bfd code.  */
   if (in->n_sclass == C_SECTION)
     {
+      char namebuf[SYMNMLEN + 1];
+      const char *name = namebuf;
+
       in->n_value = 0x0;
 
       /* Create synthetic empty sections as needed.  DJ */
@@ -136,31 +139,22 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void *
 	{
 	  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);
+	  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);
 	  flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
 	  sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]