[MLton-commit] r6708

Wesley Terpstra wesley at mlton.org
Tue Aug 19 14:40:55 PDT 2008


A better understanding of how dynamic linking works has led me to realize that 
this code was in error. Just because a symbol is alloc'd by MLton does NOT
make it safe to be accessed as an internal symbol. ELF dynamic linking will
relocate the symbol when it is used by an executable. This is so that the
executable can refer to it by name (not needing to worry about whether it
comes from a dynamic library or not). Therefore, we must refer to the symbol
as an external/exported symbol.


----------------------------------------------------------------------

U   mlton/trunk/mlton/elaborate/elaborate-core.fun

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/elaborate/elaborate-core.fun
===================================================================
--- mlton/trunk/mlton/elaborate/elaborate-core.fun	2008-08-19 18:29:58 UTC (rev 6707)
+++ mlton/trunk/mlton/elaborate/elaborate-core.fun	2008-08-19 21:40:54 UTC (rev 6708)
@@ -1200,14 +1200,13 @@
                          empty)
                         ; SymbolScope.External)
              | SOME x => x
-         val scope =
+         val () =
             if List.exists (attributes, fn attr => 
                                            attr = SymbolAttribute.Alloc)
-               then (Ffi.addSymbol {name = name, 
-                                    ty = ctypeCbTy, 
-                                    symbolScope = scope}
-                     ; SymbolScope.Internal)
-               else scope
+               then Ffi.addSymbol {name = name, 
+                                   ty = ctypeCbTy, 
+                                   symbolScope = scope}
+               else ()
          val addrExp =
             mkAddress {expandedPtrTy = Type.cpointer,
                        name = name,




More information about the MLton-commit mailing list