@@ -800,9 +800,7 @@ 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
-
803
+ let path = tmpdir. join ( if self . sess . target . is_like_windows { "list.def" } else { "list" } ) ;
806
804
debug ! ( "EXPORTED SYMBOLS:" ) ;
807
805
808
806
if self . sess . target . is_like_darwin {
@@ -817,7 +815,8 @@ 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 {
821
820
let res: io:: Result < ( ) > = try {
822
821
let mut f = File :: create_buffered ( & path) ?;
823
822
@@ -835,6 +834,21 @@ impl<'a> Linker for GccLinker<'a> {
835
834
if let Err ( error) = res {
836
835
self . sess . dcx ( ) . emit_fatal ( errors:: LibDefWriteFailure { error } ) ;
837
836
}
837
+ self . link_arg ( path) ;
838
+ } else if crate_type == CrateType :: Executable && !self . sess . target . is_like_solaris {
839
+ let res: io:: Result < ( ) > = try {
840
+ let mut f = File :: create_buffered ( & path) ?;
841
+ writeln ! ( f, "{{" ) ?;
842
+ for ( sym, _) in symbols {
843
+ debug ! ( sym) ;
844
+ writeln ! ( f, " {sym};" ) ?;
845
+ }
846
+ writeln ! ( f, "}};" ) ?;
847
+ } ;
848
+ if let Err ( error) = res {
849
+ self . sess . dcx ( ) . emit_fatal ( errors:: VersionScriptWriteFailure { error } ) ;
850
+ }
851
+ self . link_arg ( "--dynamic-list" ) . link_arg ( path) ;
838
852
} else {
839
853
// Write an LD version script
840
854
let res: io:: Result < ( ) > = try {
@@ -852,18 +866,13 @@ impl<'a> Linker for GccLinker<'a> {
852
866
if let Err ( error) = res {
853
867
self . sess . dcx ( ) . emit_fatal ( errors:: VersionScriptWriteFailure { error } ) ;
854
868
}
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" ) ;
869
+ if self . sess . target . is_like_solaris {
870
+ self . link_arg ( "-M" ) . link_arg ( path) ;
871
+ } else {
872
+ let mut arg = OsString :: from ( "--version-script=" ) ;
873
+ arg. push ( path) ;
874
+ self . link_arg ( arg) . link_arg ( "--no-undefined-version" ) ;
875
+ }
867
876
}
868
877
}
869
878
0 commit comments