This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] Fix PR 31144: strengthen name mangling
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Apr 2007 15:59:04 +0200
- Subject: Re: [gfortran] Fix PR 31144: strengthen name mangling
- References: <462380D4.6000705@physik.uni-muenchen.de>
Tobias Schlüter wrote:
this one-liner changes our name-mangling to be more robust.
And it's provided as part of this mail.
- Tobi
:ADDPATCH fortran:
PR fortran/31144
fortran/
* decl.c (gfc_sym_mangled_identifier): Use capital letters in name
mangling.
testsuite/
* gfortran.dg/module_naming_1.f90: New.
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (revision 123861)
+++ gcc/fortran/trans-decl.c (working copy)
@@ -299,7 +299,7 @@ gfc_sym_mangled_identifier (gfc_symbol *
return gfc_sym_identifier (sym);
else
{
- snprintf (name, sizeof name, "__%s__%s", sym->module, sym->name);
+ snprintf (name, sizeof name, "__%s_MOD_%s", sym->module, sym->name);
return get_identifier (name);
}
}
Index: gcc/testsuite/gfortran.dg/module_naming_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/module_naming_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/module_naming_1.f90 (revision 0)
@@ -0,0 +1,31 @@
+! { dg-do assemble }
+! PR 31144
+! Makes sure that our name mangling scheme can't be outwitted
+
+! old scheme
+module m1
+contains
+ subroutine m2__m3()
+ end subroutine m2__m3
+end module m1
+
+module m1__m2
+contains
+ subroutine m3()
+ end subroutine m3
+end module m1__m2
+
+! New scheme, relies on capitalization
+module m2
+contains
+ subroutine m2_MOD_m3()
+ ! mangled to __m2_MOD_m2_mod_m3
+ end subroutine m2_MOD_m3
+end module m2
+
+module m2_MOD_m2
+contains
+ subroutine m3()
+ ! mangled to __m2_mod_m2_MOD_m3
+ end subroutine m3
+end module m2_MOD_m2