This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] Fix PR 31144: strengthen name mangling


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]