-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
symbols versions are not mangled correctly #2166
Comments
Patch pasted below works on FreeBSD, Windows bots and my Linux machine (x64) with gcc-4.6.3, ld-2.22, but failed on the Linux bots with error:
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs
index 114f02f..1a20084 100644
--- a/src/rustc/back/link.rs
+++ b/src/rustc/back/link.rs
@@ -13,6 +13,7 @@ import syntax::print::pprust;
import lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False};
import util::filesearch;
import middle::ast_map::{path, path_mod, path_name};
+import io::writer_util;
enum output_type {
output_type_none,
@@ -448,7 +449,6 @@ fn sanitize(s: str) -> str {
let mut result = "";
str::chars_iter(s) {|c|
alt c {
- '@' { result += "_sbox_"; }
'~' { result += "_ubox_"; }
'*' { result += "_ptr_"; }
'&' { result += "_ref_"; }
@@ -458,7 +458,7 @@ fn sanitize(s: str) -> str {
'a' to 'z'
| 'A' to 'Z'
| '0' to '9'
- | '_' { str::push_char(result,c); }
+ | '_' | '@' | '.' { str::push_char(result,c); }
_ {
if c > 'z' && char::is_XID_continue(c) {
str::push_char(result,c);
@@ -485,12 +485,13 @@ fn mangle(ss: path) -> str {
}
fn exported_name(path: path, hash: str, vers: str) -> str {
- ret mangle(path + [path_name(hash)] + [path_name(vers)]);
+ ret mangle(path + [path_name(hash)]) + "@VERS_" + sanitize(vers);
}
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str {
let hash = get_symbol_hash(ccx, t);
- ret exported_name(path, hash, ccx.link_meta.vers);
+ let exp = exported_name(path, hash, ccx.link_meta.vers);
+ ret exp;
}
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: str) ->
@@ -602,6 +603,18 @@ fn link_binary(sess: session,
if sess.building_library {
cc_args += [lib_cmd];
+ if sess.targ_cfg.os != session::os_macos {
+ let version_script = out_filename + ".verscript";
+ #debug["version_script: %s", version_script];
+ alt io::file_writer(version_script, [io::create]) {
+ result::ok(w) {
+ w.write_line("VERS_" + lm.vers + " { global: *; };");
+ }
+ _ { fail }
+ };
+ cc_args += ["-Wl,--version-script=" + version_script];
+ }
+
// On mac we need to tell the linker to let this library
// be rpathed
if sess.targ_cfg.os == session::os_macos {
|
This is great work. Thanks for digging into it. |
Removing this from 0.3 since it's just a completeness issue. |
Version strings (as of 1c1af99) are now appended with a trailing Now that I consider it, I think maybe it'll work best if we don't mangle the version into the filename, but do suffix the symbols. Then we can simulate what the gnu linker does, but on all platforms: tell the loader which library to request by name+hash, and then support multiple versions of each symbol in a crate, say via a Thoughts? |
By the way, I tried running some mangled Rust symbols through |
The c++filt thing has to do with us making duplicate symbols (by accident) and LLVM disambiguating them by appending numbers, breaking our (otherwise c++filt-compatible) mangling. This keeps happening. it's very uncool. I put in some hacks to try to notice when it's happening already but apparently some slipped by. I'll try to track down the current culprits. |
Longer-term issue, de-milestoning |
@graydon, perhaps bring this up on the mailing list if you have questions as to the design here? Nominating for Maturity 2. |
accepted for production-ready milestone |
Low, not 1.0 |
Is this issue still relevant today? |
This was fixed when we started hashing crate contents. |
ui_test tweaks - support multiple filters - make `./miri check` also cover ui_test - Run opt-level=4 tests again, but only the "run" tests r? `@oli-obk`
This will allow us to retrieve crash information from Kani driver once we merge rust-lang#2166.
We now store Kani's version and the failure reason (if there's one) into the assess metadata. For now, we still need to manually parse this information, but this moves us closer to rust-lang#2058 and rust-lang#2165. In order to collect more details about the compilation errors, we now inspect the cargo diagnostic messages.
As part of #2137 and #456 we have added the crate version to every exported symbol, but not quite in the correct way.
Right now the final part of the path used for the symbol ends with
"V" + vers
, which gets passed through the mangler. The original design called for@vers
but the@
isn't a valid symbol on all platforms (I think?) so gets mangled to_sbox_
, which is a bizarre way to indicate the version.Mangling also makes any dots in the version go away so a version "0.2" symbol will end with "V02".
There is some additional discussion here about how this is supposed to work that I haven't read.
The text was updated successfully, but these errors were encountered: