@@ -77,6 +77,7 @@ fn check_paths<P: AsRef<Path>>(paths: &[P]) {
7777
7878 verify_no_duplicates ( & archive) ;
7979 verify_core_symbols ( & archive) ;
80+ verify_hidden_visibility ( & archive) ;
8081 }
8182}
8283
@@ -299,6 +300,36 @@ fn verify_core_symbols(archive: &BinFile) {
299300 println ! ( " success: no undefined references to core found" ) ;
300301}
301302
303+ /// Check for symbols with default visibility.
304+ fn verify_hidden_visibility ( archive : & BinFile ) {
305+ let mut visible = Vec :: new ( ) ;
306+ let mut found_any = false ;
307+
308+ archive. for_each_symbol ( |symbol, obj, member| {
309+ // Only check defined globals.
310+ if !symbol. is_global ( ) || symbol. is_undefined ( ) {
311+ return ;
312+ }
313+
314+ let sym = SymInfo :: new ( & symbol, obj, member) ;
315+ if sym. scope == SymbolScope :: Dynamic {
316+ visible. push ( sym) ;
317+ }
318+
319+ found_any = true
320+ } ) ;
321+
322+ assert ! ( found_any, "no symbols found" ) ;
323+
324+ if !visible. is_empty ( ) {
325+ visible. sort_unstable_by ( |a, b| a. name . cmp ( & b. name ) ) ;
326+ let num = visible. len ( ) ;
327+ panic ! ( "found {num:#?} visible symbols: {visible:#?}" ) ;
328+ }
329+
330+ println ! ( " success: no visible symbols found" ) ;
331+ }
332+
302333/// Thin wrapper for owning data used by `object`.
303334struct BinFile {
304335 path : PathBuf ,
0 commit comments