From fef292bcaca8b4aed6b30be7b7411e7384c421c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Wed, 19 Jan 2022 18:24:26 +0100 Subject: [PATCH] Add vendor-specific suffixes to mangling RFC 2603 --- text/2603-rust-symbol-name-mangling-v0.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/text/2603-rust-symbol-name-mangling-v0.md b/text/2603-rust-symbol-name-mangling-v0.md index abed85138e1..5e23add43aa 100644 --- a/text/2603-rust-symbol-name-mangling-v0.md +++ b/text/2603-rust-symbol-name-mangling-v0.md @@ -623,7 +623,8 @@ Mangled names conform to the following grammar: ``` // The specifies the encoding version. - = "_R" [] [] + = + "_R" [] [] [] = "C" // crate root | "M" // (inherent impl) @@ -746,6 +747,10 @@ Mangled names conform to the following grammar: // We use here, so that we don't have to add a special rule for // compression. In practice, only a crate root is expected. = + +// There are no restrictions on the characters that may be used +// in the suffix following the `.` or `$`. + = ("." | "$") ``` ### Namespace Tags @@ -801,6 +806,21 @@ With this post-processing in place the Punycode strings can be treated like regular identifiers and need no further special handling. +### Vendor-specific suffix + +Similarly to the [Itanium C++ ABI mangling scheme][itanium-mangling-structure], +a symbol name containing a period (`.`) or a dollar sign (`$`) represents a +vendor-specific version of the symbol. There are no restrictions on the +characters following the period or dollar sign. + +This can happen in practice when locally unique names needed to become globally +unique. For example, LLVM can append a `.llvm.` suffix during LTO to +ensure a unique name, and `$` can be used for thread-local data on Mach-O. In +these situations it's generally fine to ignore the suffix: the suffixed name has +the same semantics as the original. + +[itanium-mangling-structure]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-structure + ## Compression Symbol name compression works by substituting parts of the mangled @@ -1156,3 +1176,4 @@ pub static QUUX: u32 = { - Make `` optional in `` and `` productions. - Extend `` to include `bool` values, `char` values, and negative integer values. - Remove type from constant placeholders. +- Allow vendor-specific suffixes.