* PATCH mingw32 PE dlltool: No ASM underscore for symbols beginning with ?
@ 2004-06-28 0:49 Aaron W. LaFramboise
2004-07-09 16:18 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Aaron W. LaFramboise @ 2004-06-28 0:49 UTC (permalink / raw)
To: binutils
MS LINK and LIB do not generate a leading underscore for symbols that
begin with ? in .def files. The following patch matches this behavior.
These symbols are MSVC C++ mangled names. Without this patch, an
import library from a DLL with MSVC C++ exports will be incorrect,
causing link failures when linking MSVC C++ code.
(FYI, I have not yet been notified by the FSF of acceptance of my
copyright assignment forms. I'm not sure whether or not this patch is
considered trivial. With any luck, they'll get around to processing me
Monday.)
2004-06-27 Aaron W. LaFramboise <aaron98wiridge9@aaronwl.com>
* binutils/dlltool.c (asm_prefix): Add parameter: name.
No underscore for symbols beginning with ?.
(ASM_PREFIX): Add parameter: NAME.
(gen_exp_file): Use new parameter.
(make_label): Same.
(make_imp_label): Same.
(make_one_lib_file): Same.
Index: src/binutils/dlltool.c
===================================================================
RCS file: /cvs/src/src/binutils/dlltool.c,v
retrieving revision 1.49
diff -c -3 -p -r1.49 dlltool.c
*** src/binutils/dlltool.c 15 Jun 2004 01:19:13 -0000 1.49
--- src/binutils/dlltool.c 28 Jun 2004 00:36:54 -0000
*************** static struct string_list *excludes;
*** 664,670 ****
static const char *rvaafter (int);
static const char *rvabefore (int);
! static const char *asm_prefix (int);
static void process_def_file (const char *);
static void new_directive (char *);
static void append_import (const char *, const char *, int);
--- 664,670 ----
static const char *rvaafter (int);
static const char *rvabefore (int);
! static const char *asm_prefix (int, const char *);
static void process_def_file (const char *);
static void new_directive (char *);
static void append_import (const char *, const char *, int);
*************** rvabefore (int machine)
*** 795,801 ****
}
static const char *
! asm_prefix (int machine)
{
switch (machine)
{
--- 795,801 ----
}
static const char *
! asm_prefix (int machine, const char *name)
{
switch (machine)
{
*************** asm_prefix (int machine)
*** 810,816 ****
case MARM_EPOC:
break;
case M386:
! return "_";
default:
/* xgettext:c-format */
fatal (_("Internal error: Unknown machine type: %d"), machine
);
--- 810,820 ----
case MARM_EPOC:
break;
case M386:
! /* Symbol names starting with ? do not have a leading
underscore. */
! if (name && *name == '?')
! break;
! else
! return "_";
default:
/* xgettext:c-format */
fatal (_("Internal error: Unknown machine type: %d"), machine
);
*************** asm_prefix (int machine)
*** 819,844 ****
return "";
}
! #define ASM_BYTE mtable[machine].how_byte
! #define ASM_SHORT mtable[machine].how_short
! #define ASM_LONG mtable[machine].how_long
! #define ASM_TEXT mtable[machine].how_asciz
! #define ASM_C mtable[machine].how_comment
! #define ASM_JUMP mtable[machine].how_jump
! #define ASM_GLOBAL mtable[machine].how_global
! #define ASM_SPACE mtable[machine].how_space
! #define ASM_ALIGN_SHORT mtable[machine].how_align_short
! #define ASM_RVA_BEFORE rvabefore(machine)
! #define ASM_RVA_AFTER rvaafter(machine)
! #define ASM_PREFIX asm_prefix(machine)
! #define ASM_ALIGN_LONG mtable[machine].how_align_long
! #define HOW_BFD_READ_TARGET 0 /* always default*/
! #define HOW_BFD_WRITE_TARGET mtable[machine].how_bfd_target
! #define HOW_BFD_ARCH mtable[machine].how_bfd_arch
! #define HOW_JTAB mtable[machine].how_jtab
! #define HOW_JTAB_SIZE mtable[machine].how_jtab_size
! #define HOW_JTAB_ROFF mtable[machine].how_jtab_roff
! #define ASM_SWITCHES mtable[machine].how_default_as_switches
static char **oav;
--- 823,848 ----
return "";
}
! #define ASM_BYTE mtable[machine].how_byte
! #define ASM_SHORT mtable[machine].how_short
! #define ASM_LONG mtable[machine].how_long
! #define ASM_TEXT mtable[machine].how_asciz
! #define ASM_C mtable[machine].how_comment
! #define ASM_JUMP mtable[machine].how_jump
! #define ASM_GLOBAL mtable[machine].how_global
! #define ASM_SPACE mtable[machine].how_space
! #define ASM_ALIGN_SHORT mtable[machine].
how_align_short
! #define ASM_RVA_BEFORE rvabefore(machine)
! #define ASM_RVA_AFTER rvaafter(machine)
! #define ASM_PREFIX(NAME) asm_prefix(machine, (NAME))
! #define ASM_ALIGN_LONG mtable[machine].how_align_long
! #define HOW_BFD_READ_TARGET 0 /* always default*/
! #define HOW_BFD_WRITE_TARGET mtable[machine].how_bfd_target
! #define HOW_BFD_ARCH mtable[machine].how_bfd_arch
! #define HOW_JTAB mtable[machine].how_jtab
! #define HOW_JTAB_SIZE mtable[machine].how_jtab_size
! #define HOW_JTAB_ROFF mtable[machine].how_jtab_roff
! #define ASM_SWITCHES mtable[machine].
how_default_as_switches
static char **oav;
*************** gen_exp_file (void)
*** 1816,1822 ****
exp->internal_name, ASM_RVA_AFTER, ASM_C,
exp->ordinal);
else
fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
! ASM_PREFIX,
exp->internal_name, ASM_RVA_AFTER, ASM_C,
exp->ordinal);
}
else
--- 1820,1826 ----
exp->internal_name, ASM_RVA_AFTER, ASM_C,
exp->ordinal);
else
fprintf (f, "\t%s%s%s%s\t%s %d\n", ASM_RVA_BEFORE,
! ASM_PREFIX(exp->internal_name),
exp->internal_name, ASM_RVA_AFTER, ASM_C,
exp->ordinal);
}
else
*************** ID2: .short 2
*** 2150,2159 ****
static char *
make_label (const char *prefix, const char *name)
{
! int len = strlen (ASM_PREFIX) + strlen (prefix) + strlen (name);
char *copy = xmalloc (len +1 );
! strcpy (copy, ASM_PREFIX);
strcat (copy, prefix);
strcat (copy, name);
return copy;
--- 2154,2163 ----
static char *
make_label (const char *prefix, const char *name)
{
! int len = strlen (ASM_PREFIX(name)) + strlen (prefix) + strlen (
name);
char *copy = xmalloc (len +1 );
! strcpy (copy, ASM_PREFIX(name));
strcat (copy, prefix);
strcat (copy, name);
return copy;
*************** make_imp_label (const char *prefix, cons
*** 2174,2183 ****
}
else
{
! len = strlen (ASM_PREFIX) + strlen (prefix) + strlen (name);
copy = xmalloc (len + 1);
strcpy (copy, prefix);
! strcat (copy, ASM_PREFIX);
strcat (copy, name);
}
return copy;
--- 2178,2187 ----
}
else
{
! len = strlen (ASM_PREFIX(name)) + strlen (prefix) + strlen (
name);
copy = xmalloc (len + 1);
strcpy (copy, prefix);
! strcat (copy, ASM_PREFIX(name));
strcat (copy, name);
}
return copy;
*************** make_one_lib_file (export_type *exp, int
*** 2197,2208 ****
sprintf (name, "%ss%05d.s", prefix, i);
f = fopen (name, FOPEN_WT);
fprintf (f, "\t.text\n");
! fprintf (f, "\t%s\t%s%s\n", ASM_GLOBAL, ASM_PREFIX, exp->name
);
if (create_compat_implib)
fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name);
fprintf (f, "\t%s\t_imp__%s\n", ASM_GLOBAL, exp->name);
if (create_compat_implib)
! fprintf (f, "%s%s:\n\t%s\t__imp_%s\n", ASM_PREFIX,
exp->name, ASM_JUMP, exp->name);
fprintf (f, "\t.section\t.idata$7\t%s To force loading of
head\n", ASM_C);
--- 2201,2212 ----
sprintf (name, "%ss%05d.s", prefix, i);
f = fopen (name, FOPEN_WT);
fprintf (f, "\t.text\n");
! fprintf (f, "\t%s\t%s%s\n", ASM_GLOBAL, ASM_PREFIX(exp->name),
exp->name);
if (create_compat_implib)
fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name);
fprintf (f, "\t%s\t_imp__%s\n", ASM_GLOBAL, exp->name);
if (create_compat_implib)
! fprintf (f, "%s%s:\n\t%s\t__imp_%s\n", ASM_PREFIX(exp->name),
exp->name, ASM_JUMP, exp->name);
fprintf (f, "\t.section\t.idata$7\t%s To force loading of
head\n", ASM_C);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH mingw32 PE dlltool: No ASM underscore for symbols beginning with ?
2004-06-28 0:49 PATCH mingw32 PE dlltool: No ASM underscore for symbols beginning with ? Aaron W. LaFramboise
@ 2004-07-09 16:18 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2004-07-09 16:18 UTC (permalink / raw)
To: Aaron W. LaFramboise; +Cc: binutils
Hi Aaron,
> 2004-06-27 Aaron W. LaFramboise <aaron98wiridge9@aaronwl.com>
>
> * binutils/dlltool.c (asm_prefix): Add parameter: name.
> No underscore for symbols beginning with ?.
> (ASM_PREFIX): Add parameter: NAME.
> (gen_exp_file): Use new parameter.
> (make_label): Same.
> (make_imp_label): Same.
> (make_one_lib_file): Same.
Approved and applied - thanks very much for submitting this patch.
> (FYI, I have not yet been notified by the FSF of acceptance of my
> copyright assignment forms. I'm not sure whether or not this patch is
> considered trivial. With any luck, they'll get around to processing
> me Monday.)
I think that this particular patch can be considered to be trivial,
although as it happens your assignment has now gone through :-)
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-09 16:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-28 0:49 PATCH mingw32 PE dlltool: No ASM underscore for symbols beginning with ? Aaron W. LaFramboise
2004-07-09 16:18 ` 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).