public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix for short import libs
@ 2005-02-24  8:03 Ross Ridge
  2005-02-28 18:10 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Ross Ridge @ 2005-02-24  8:03 UTC (permalink / raw)
  To: binutils

Here's a trivial patch to fix an obvious bug in how the BFD library
handles PECOFF short library records.  This fix allows Microsoft's import
libraries to be used directly with binutils.

Index: peicode.h
===================================================================
RCS file: /cvs/src/src/bfd/peicode.h,v
retrieving revision 1.44
diff -u -r1.44 peicode.h
--- peicode.h	20 Feb 2005 14:59:07 -0000	1.44
+++ peicode.h	23 Feb 2005 20:14:19 -0000
@@ -865,6 +865,7 @@
   else
     {
       char * symbol;
+      unsigned int len;
 
       /* Create .idata$6 - the Hint Name Table.  */
       id6 = pe_ILF_make_a_section (& vars, ".idata$6", SIZEOF_IDATA6, 0);
@@ -909,19 +910,20 @@
 	  while (check_again);
 	}
       
+      len = strlen (symbol);
       if (import_name_type == IMPORT_NAME_UNDECORATE)
 	{
-	  /* Truncate at the first '@'  */
-	  while (* symbol != 0 && * symbol != '@')
-	    symbol ++;
-
-	  * symbol = 0;
+	  char *at = strchr (symbol, '@');
+	  if (at != NULL) {
+	    len = at - symbol;
+	  }
 	}
 
       id6->contents[0] = ordinal & 0xff;
       id6->contents[1] = ordinal >> 8;
 
-      strcpy ((char *) id6->contents + 2, symbol);
+      memcpy ((char *) id6->contents + 2, symbol, len);
+      id6->contents[2 + len] = '\0';
     }
 
   if (import_name_type != IMPORT_ORDINAL)

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/u/rridge/ 
 db  //	  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix for short import libs
  2005-02-24  8:03 [PATCH] Fix for short import libs Ross Ridge
@ 2005-02-28 18:10 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2005-02-28 18:10 UTC (permalink / raw)
  To: Ross Ridge; +Cc: binutils

Hi Ross,

> Here's a trivial patch to fix an obvious bug in how the BFD library
> handles PECOFF short library records.  This fix allows Microsoft's import
> libraries to be used directly with binutils.

Thanks for supplying us with this patch.  I have applied it along with 
this ChangeLog entry:

bfd/ChangeLog
2005-02-28  Ross Ridge  <rridge@csclub.uwaterloo.ca>

	* peicode.h (pe_ILF_build_a_bfd): Do not assume that an @ will be
	present when IMPORT_NAME_UNDOECRATE is used.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-02-28 16:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24  8:03 [PATCH] Fix for short import libs Ross Ridge
2005-02-28 18:10 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).