This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Fix for short import libs
- From: rridge at csclub dot uwaterloo dot ca (Ross Ridge)
- To: binutils at sources dot redhat dot com
- Date: Wed, 23 Feb 2005 19:18:05 -0500 (EST)
- Subject: [PATCH] Fix for short import libs
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 //