@@ -800,13 +800,11 @@ impl<'a> Linker for GccLinker<'a> {
800
800
return ;
801
801
}
802
802
803
- let is_windows = self . sess . target . is_like_windows ;
804
- let path = tmpdir. join ( if is_windows { "list.def" } else { "list" } ) ;
805
-
806
803
debug ! ( "EXPORTED SYMBOLS:" ) ;
807
804
808
805
if self . sess . target . is_like_darwin {
809
806
// Write a plain, newline-separated list of symbols
807
+ let path = tmpdir. join ( "list" ) ;
810
808
let res: io:: Result < ( ) > = try {
811
809
let mut f = File :: create_buffered ( & path) ?;
812
810
for ( sym, _) in symbols {
@@ -817,7 +815,9 @@ impl<'a> Linker for GccLinker<'a> {
817
815
if let Err ( error) = res {
818
816
self . sess . dcx ( ) . emit_fatal ( errors:: LibDefWriteFailure { error } ) ;
819
817
}
820
- } else if is_windows {
818
+ self . link_arg ( "-exported_symbols_list" ) . link_arg ( path) ;
819
+ } else if self . sess . target . is_like_windows {
820
+ let path = tmpdir. join ( "list.def" ) ;
821
821
let res: io:: Result < ( ) > = try {
822
822
let mut f = File :: create_buffered ( & path) ?;
823
823
@@ -835,7 +835,24 @@ impl<'a> Linker for GccLinker<'a> {
835
835
if let Err ( error) = res {
836
836
self . sess . dcx ( ) . emit_fatal ( errors:: LibDefWriteFailure { error } ) ;
837
837
}
838
+ self . link_arg ( path) ;
839
+ } else if crate_type == CrateType :: Executable && !self . sess . target . is_like_solaris {
840
+ let path = tmpdir. join ( "list" ) ;
841
+ let res: io:: Result < ( ) > = try {
842
+ let mut f = File :: create_buffered ( & path) ?;
843
+ writeln ! ( f, "{{" ) ?;
844
+ for ( sym, _) in symbols {
845
+ debug ! ( sym) ;
846
+ writeln ! ( f, " {sym};" ) ?;
847
+ }
848
+ writeln ! ( f, "}};" ) ?;
849
+ } ;
850
+ if let Err ( error) = res {
851
+ self . sess . dcx ( ) . emit_fatal ( errors:: VersionScriptWriteFailure { error } ) ;
852
+ }
853
+ self . link_arg ( "--dynamic-list" ) . link_arg ( path) ;
838
854
} else {
855
+ let path = tmpdir. join ( "list" ) ;
839
856
// Write an LD version script
840
857
let res: io:: Result < ( ) > = try {
841
858
let mut f = File :: create_buffered ( & path) ?;
@@ -852,18 +869,13 @@ impl<'a> Linker for GccLinker<'a> {
852
869
if let Err ( error) = res {
853
870
self . sess . dcx ( ) . emit_fatal ( errors:: VersionScriptWriteFailure { error } ) ;
854
871
}
855
- }
856
-
857
- if self . sess . target . is_like_darwin {
858
- self . link_arg ( "-exported_symbols_list" ) . link_arg ( path) ;
859
- } else if self . sess . target . is_like_solaris {
860
- self . link_arg ( "-M" ) . link_arg ( path) ;
861
- } else if is_windows {
862
- self . link_arg ( path) ;
863
- } else {
864
- let mut arg = OsString :: from ( "--version-script=" ) ;
865
- arg. push ( path) ;
866
- self . link_arg ( arg) . link_arg ( "--no-undefined-version" ) ;
872
+ if self . sess . target . is_like_solaris {
873
+ self . link_arg ( "-M" ) . link_arg ( path) ;
874
+ } else {
875
+ let mut arg = OsString :: from ( "--version-script=" ) ;
876
+ arg. push ( path) ;
877
+ self . link_arg ( arg) . link_arg ( "--no-undefined-version" ) ;
878
+ }
867
879
}
868
880
}
869
881
0 commit comments