[llvm-dev] LLD: patch to fix libCOFF calling exit() on success in a library function
Rui Ueyama via llvm-dev
llvm-dev at lists.llvm.org
Thu Aug 31 14:47:54 PDT 2017
COFF lld uses exit() unlike ELF lld due to lack of user needs, but are you
trying to use it as a library? If so, I believe you need to fix other
places where exit() is called on success or for a trivial error (such as
invalid command line argument) as well.
On Thu, Aug 31, 2017 at 10:45 AM, Andrew Kelley via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> I believe that LLD is not supposed to call exit on success when you
> call lld::coff::link.
>
> From downstream fork of LLD: https://github.com/zig-lang/zig/commit/
> 41da9fdb69065082f57c604b12eb02ca166cb18d
>
>
> diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
> index 854c3e69098..8b17f039870 100644
> --- a/lld/COFF/Driver.cpp
> +++ b/lld/COFF/Driver.cpp
> @@ -1030,7 +1030,7 @@ void LinkerDriver::link(ArrayRef<const char *>
> ArgsArr) {
> if (!Args.hasArgNoClaim(OPT_INPUT)) {
> fixupExports();
> createImportLibrary(/*AsLib=*/true);
> - exit(0);
> + return;
> }
>
> // Handle /delayload
> @@ -1122,7 +1122,7 @@ void LinkerDriver::link(ArrayRef<const char *>
> ArgsArr) {
> // This is useful because MSVC link.exe can generate complete PDBs.
> if (Args.hasArg(OPT_msvclto)) {
> invokeMSVC(Args);
> - exit(0);
> + return;
> }
>
> // Do LTO by compiling bitcode input files to a set of native COFF
> files then
> @@ -1173,8 +1173,7 @@ void LinkerDriver::link(ArrayRef<const char *>
> ArgsArr) {
> // Write the result.
> writeResult(&Symtab);
>
> - // Call exit to avoid calling destructors.
> - exit(0);
> + return;
> }
>
> } // namespace coff
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170831/7f26e1d5/attachment.html>
More information about the llvm-dev
mailing list