@@ -828,7 +828,27 @@ impl<'a> Linker for GccLinker<'a> {
828828                self . sess . dcx ( ) . emit_fatal ( errors:: LibDefWriteFailure  {  error } ) ; 
829829            } 
830830            self . link_arg ( path) ; 
831-         }  else  if  crate_type == CrateType :: Executable  && !self . sess . target . is_like_solaris  { 
831+         }  else  if  self . sess . target . is_like_solaris  { 
832+             // Write a Solaris LD mapfile 
833+             // Documented at https://docs.oracle.com/cd/E53394_01/html/E54813/gjpky.html#OSLLGman-scsvd 
834+             let  res:  io:: Result < ( ) >  = try { 
835+                 let  mut  f = File :: create_buffered ( & path) ?; 
836+                 writeln ! ( f,  "$mapfile_version 2" ) ?; 
837+                 writeln ! ( f,  "SYMBOL_SCOPE {{" ) ?; 
838+                 if  !symbols. is_empty ( )  { 
839+                     writeln ! ( f,  "  global:" ) ?; 
840+                     for  ( sym,  _)  in  symbols { 
841+                         debug ! ( "    {sym};" ) ; 
842+                         writeln ! ( f,  "    {sym};" ) ?; 
843+                     } 
844+                 } 
845+                 writeln ! ( f,  "\n   local:\n     *;\n }};" ) ?; 
846+             } ; 
847+             if  let  Err ( error)  = res { 
848+                 self . sess . dcx ( ) . emit_fatal ( errors:: VersionScriptWriteFailure  {  error } ) ; 
849+             } 
850+             self . link_arg ( "-M" ) . link_arg ( path) ; 
851+         }  else  if  crate_type == CrateType :: Executable  { 
832852            let  res:  io:: Result < ( ) >  = try { 
833853                let  mut  f = File :: create_buffered ( & path) ?; 
834854                writeln ! ( f,  "{{" ) ?; 
@@ -859,13 +879,9 @@ impl<'a> Linker for GccLinker<'a> {
859879            if  let  Err ( error)  = res { 
860880                self . sess . dcx ( ) . emit_fatal ( errors:: VersionScriptWriteFailure  {  error } ) ; 
861881            } 
862-             if  self . sess . target . is_like_solaris  { 
863-                 self . link_arg ( "-M" ) . link_arg ( path) ; 
864-             }  else  { 
865-                 let  mut  arg = OsString :: from ( "--version-script=" ) ; 
866-                 arg. push ( path) ; 
867-                 self . link_arg ( arg) . link_arg ( "--no-undefined-version" ) ; 
868-             } 
882+             let  mut  arg = OsString :: from ( "--version-script=" ) ; 
883+             arg. push ( path) ; 
884+             self . link_arg ( arg) . link_arg ( "--no-undefined-version" ) ; 
869885        } 
870886    } 
871887
0 commit comments