This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Undefined references due to varasm.c (globalize_decl) changes
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: jason at redhat dot com
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 19 Mar 2002 08:35:25 +1100 (EST)
- Subject: Undefined references due to varasm.c (globalize_decl) changes
This change;
2002-03-15 Jason Merrill <jason@redhat.com>
* varasm.c (globalize_decl): New fn.
(assemble_start_function): Use it.
(asm_emit_uninitialized): Use it.
(assemble_alias): Use it.
(assemble_variable): Use it.
cause problems with encoded stdcall function names on windows targets.
Before the patch, a stdcall function like:
void __attribute__((stdcall)) foo (int i)
{ (void)i; return ;}
emitted this assembler output:
.file "foo.c"
.text
.align 2
.globl _foo@4
.def _foo@4; .scl 2; .type 32; .endef
_foo@4:
ret $4
After the patch:
.globl _foo
.def _foo@4; .scl 2; .type 32; .endef
_foo@4:
ret $4
globalize_decl uses IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))
to get the label name, not the encoded name. The @4 decoration is
generated by ENCODE_SECTION_INFO, calling gen_stdcall_suffix.
This caused undefined symbol _foo in object.
When building dlls (which disallow undefined symbols) ld cleverly
fixes up the reference to _foo by resolving to _foo@4, but issues a
warning, which normally should be taken seriously.
I have only tested the following fix, which passes the name as input
argument to globalize_decl, with mingw32, I am not able to
test on other targets. If this is not right, could someone please
point me to other ways to fix on windows targets.
ChangeLog
2002-13-18 Danny Smith <dannysmith@users.sourceforge.net>
* varasm.c (globalize_decl): Get name as input parameter.
(assemble_start_function): Update call to globalize_decl.
(asm_emit_uninitialised): Likewise.
(assemble_alias): Likewise,.
(assemble_variable): Likewise.
--- varasm.c.ori Mon Mar 18 21:10:29 2002
+++ varasm.c Tue Mar 19 08:26:31 2002
@@ -166,7 +166,7 @@ static unsigned HOST_WIDE_INT array_size
static unsigned min_align PARAMS ((unsigned, unsigned));
static void output_constructor PARAMS ((tree, HOST_WIDE_INT,
unsigned int));
-static void globalize_decl PARAMS ((tree));
+static void globalize_decl PARAMS ((tree, const char *));
static int in_named_entry_eq PARAMS ((const PTR, const PTR));
static hashval_t in_named_entry_hash PARAMS ((const PTR));
#ifdef ASM_OUTPUT_BSS
@@ -1235,7 +1235,7 @@ assemble_start_function (decl, fnname)
weak_global_object_name = name;
}
- globalize_decl (decl);
+ globalize_decl (decl, fnname);
}
/* Do any machine/system dependent processing of the function name */
@@ -1400,7 +1400,7 @@ asm_emit_uninitialised (decl, name, size
if (! DECL_WEAK (decl))
break;
case asm_dest_bss:
- globalize_decl (decl);
+ globalize_decl (decl, name);
default:
break;
}
@@ -1641,7 +1641,7 @@ assemble_variable (decl, top_level, at_e
/* First make the assembler name(s) global if appropriate. */
if (TREE_PUBLIC (decl) && DECL_NAME (decl))
- globalize_decl (decl);
+ globalize_decl (decl, name);
/* Output any data that we will need to use the address of. */
if (DECL_INITIAL (decl) == error_mark_node)
@@ -5049,11 +5049,10 @@ weak_finish ()
/* Emit the assembly bits to indicate that DECL is globally visible. */
static void
-globalize_decl (decl)
+globalize_decl (decl, name)
tree decl;
+ const char * name;
{
- const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-
#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
if (DECL_WEAK (decl))
{
@@ -5098,7 +5097,7 @@ assemble_alias (decl, target)
#ifdef ASM_OUTPUT_DEF
/* Make name accessible from other files, if appropriate. */
if (TREE_PUBLIC (decl))
- globalize_decl (decl);
+ globalize_decl (decl, name);
#ifdef ASM_OUTPUT_DEF_FROM_DECLS
ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target);
http://movies.yahoo.com.au - Yahoo! Movies
- Vote for your nominees in our online Oscars pool.