[lld] r289074 - Add support for 'extern "C"'.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 09:39:13 PST 2016
Whoa, `extern "C"` in a linker script? I didn't know they exist.
On Thu, Dec 8, 2016 at 9:26 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: rafael
> Date: Thu Dec 8 11:26:53 2016
> New Revision: 289074
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289074&view=rev
> Log:
> Add support for 'extern "C"'.
>
> It is used by Qt.
>
> Modified:
> lld/trunk/ELF/LinkerScript.cpp
> lld/trunk/test/ELF/version-script-extern.s
>
> Modified: lld/trunk/ELF/LinkerScript.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> LinkerScript.cpp?rev=289074&r1=289073&r2=289074&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/LinkerScript.cpp (original)
> +++ lld/trunk/ELF/LinkerScript.cpp Thu Dec 8 11:26:53 2016
> @@ -1929,14 +1929,17 @@ std::vector<SymbolVersion> ScriptParser:
> // Reads an "extern C++" directive, e.g.,
> // "extern "C++" { ns::*; "f(int, double)"; };"
> std::vector<SymbolVersion> ScriptParser::readVersionExtern() {
> - expect("\"C++\"");
> + StringRef Tok = next();
> + bool IsCXX = Tok == "\"C++\"";
> + if (!IsCXX && Tok != "\"C\"")
> + setError("Unknown Language");
> expect("{");
>
> std::vector<SymbolVersion> Ret;
> while (!Error && peek() != "}") {
> StringRef Tok = next();
> bool HasWildcard = !Tok.startswith("\"") && hasWildcard(Tok);
> - Ret.push_back({unquote(Tok), true, HasWildcard});
> + Ret.push_back({unquote(Tok), IsCXX, HasWildcard});
> expect(";");
> }
>
>
> Modified: lld/trunk/test/ELF/version-script-extern.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> version-script-extern.s?rev=289074&r1=289073&r2=289074&view=diff
> ============================================================
> ==================
> --- lld/trunk/test/ELF/version-script-extern.s (original)
> +++ lld/trunk/test/ELF/version-script-extern.s Thu Dec 8 11:26:53 2016
> @@ -5,7 +5,7 @@
> # RUN: echo ' extern "C++" { "foo(int)"; "zed(int)"; "abc::abc()"; };'
> >> %t.script
> # RUN: echo "};" >> %t.script
> # RUN: echo "LIBSAMPLE_2.0 { global:" >> %t.script
> -# RUN: echo ' extern "C++" { "bar(int)"; };' >> %t.script
> +# RUN: echo ' extern "C" { _Z3bari; };' >> %t.script
> # RUN: echo "};" >> %t.script
> # RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
> # RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck --check-prefix=DSO
> %s
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161208/185e86b6/attachment.html>
More information about the llvm-commits
mailing list