// comments exctracted from `readelf -sW ` // in ALL CASES, it is required to use the symbol to keep it in the resulting binary // FOO, FOO2, and foo3 are fairly expected pub static FOO: u32 = 1; // OBJECT LOCAL DEFAULT mangled name static FOO2: u32 = 2; // OBJECT LOCAL DEFAULT mangled name pub fn foo3() {} // FUNC LOCAL DEFAULT mangled name // declaring `extern "C"` **only** declares an ABI, the symbol is still mangled pub extern "C" fn foo4() {} // FUNC LOCAL DEFAULT mangled name // #[no_mangle] causes symbols to be GLOBAL regardless of visibility or `extern` (unexpected) and not mangled (expected) #[no_mangle] fn foo5() {} // FUNC GLOBAL DEFAULT foo5 #[no_mangle] pub fn foo6() {} // FUNC GLOBAL DEFAULT foo6 #[no_mangle] extern "C" fn foo7() {} // FUNC GLOBAL DEFAULT foo7 #[no_mangle] pub extern "C" fn foo8() {} // FUNC GLOBAL DEFAULT foo8 fn main() { println!("Foo: {}", FOO); // required to keep FOO's symbol println!("Foo2: {}", FOO2); // required to keep FOO2's symbol foo3(); // required to keep foo3's symbol foo4(); // required to keep foo4's symbol foo5(); // required to keep foo5's symbol foo6(); // required to keep foo6's symbol foo7(); // required to keep foo7's symbol foo8(); // required to keep foo8's symbol }