[llvm-bugs] [Bug 36646] New: LLD COFF produces broken executables when locally defined symbols are imported

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 8 02:33:07 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36646

            Bug ID: 36646
           Summary: LLD COFF produces broken executables when locally
                    defined symbols are imported
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: kyrab at mail.ru
                CC: llvm-bugs at lists.llvm.org

Let we have foo.c:

void foo(){}

and client.c:

__declspec(dllimport) void foo();
void start(void){ foo(); }

Let's compile and link them:
cl -O2 -Zl -c foo.c
cl -O2 -Zl -c client.c

lld-link -subsystem:console -entry:start -out:ll.exe client.obj foo.obj

Resulting ll.exe then crashed.

The culprit is that underlying locally defined symbol's section is
garbage-collected. Adding '-debug' option to lld (which blocks garbage
collection) make the executable work.

I have several solutions which all work for me, but none of them looks
particularly clean and fit LLVM conventions.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180308/881ecfed/attachment-0001.html>


More information about the llvm-bugs mailing list