[lld] Support for PECOFF in gnu ld mode

Martell Malone martellmalone at gmail.com
Sun Jun 7 19:12:32 PDT 2015


Hi All,

I have added support for PECOFF in gnu ld mode.
Currently it now works to create x86_64 executable for mingw-w64.

I'm not sure what the review process for lld involves or where i should
send my series of patches so advice going forward would be appreciated as I
plan to work on lld a lot over the next while.

I am having link errors still on armv7 and i686 that I would love some help
with :)
Attached are the patches and buildlogs for simple hello world programs
under both i686 and x86_64 insight into the i686 link errors would be great
:)
I already know that i686 prepends an underscore to all symbol names but I
don't think this is the cause other devs may know more which is why I ask

Kind Regards
Martell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/b5d51664/attachment.html>
-------------- next part --------------
Martell at Desktop MINGW64 ~
$ clang -target x86_64-windows-gnu -mconsole -fuse-ld=lld test.c -v
clang version 3.7.0 (clang 63416623e940566588bbd4f634275580cfb97d34) (n/llvm 9e6dc8ea549e1b16b6867f8bef384d453e8719ce)
Target: x86_64--windows-gnu
Thread model: posix
 "E:\\msys64\\mingw64\\bin\\clang.exe" -cc1 -triple x86_64--windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -momit-leaf-frame-pointer -v -dwarf-column-info -resource-dir "E:\\msys64\\mingw64\\bin\\..\\lib\\clang\\3.7.0" -internal-isystem "E:\\msys64\\mingw64\\bin\\..\\lib\\clang\\3.7.0\\include" -internal-isystem "E:\\msys64\\mingw64\\bin/../x86_64-w64-mingw32/include" -internal-isystem "E:\\msys64\\mingw64\\bin/../include" -fdebug-compilation-dir "E:\\msys64\\home\\Martell" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -o "E:\\msys64\\tmp\\test-db364b.o" -x c test.c
clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target x86_64-w64-windows-gnu
ignoring duplicate directory "E:\msys64\mingw64\bin\..\lib\clang\3.7.0\include"
#include "..." search starts here:
#include <...> search starts here:
 E:\msys64\mingw64\bin\..\lib\clang\3.7.0\include
 E:\msys64\mingw64\bin/../x86_64-w64-mingw32/include
 E:\msys64\mingw64\bin/../include
End of search list.
 "E:\\msys64\\mingw64\\bin\\lld.exe" -m i386pep --subsystem console -Bdynamic -o a.exe "E:\\msys64\\mingw64\\bin/../x86_64-w64-mingw32/lib\\crt2.o" "E:\\msys64\\mingw64\\bin/../x86_64-w64-mingw32/lib\\crtbegin.o" "-LE:\\msys64\\mingw64\\bin/../lib" "-LE:\\msys64\\mingw64\\bin/../x86_64-w64-mingw32/lib" "-LE:\\msys64\\mingw64\\bin/../lib/gcc/x86_64-w64-mingw32/4.9.2" "E:\\msys64\\tmp\\test-db364b.o" -flavor gnu -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt "E:\\msys64\\mingw64\\bin/../x86_64-w64-mingw32/lib\\crtend.o"

Martell at Desktop MINGW64 ~
$ clang -target i686-windows-gnu -mconsole -fuse-ld=lld test.c -v
clang version 3.7.0 (clang 63416623e940566588bbd4f634275580cfb97d34) (llvm 9e6dc8ea549e1b16b6867f8bef384d453e8719ce)
Target: i686--windows-gnu
Thread model: posix
 "E:\\msys64\\mingw64\\bin\\clang.exe" -cc1 -triple i686--windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -v -dwarf-column-info -resource-dir "E:\\msys64\\mingw64\\bin\\..\\lib\\clang\\3.7.0" -internal-isystem "E:\\msys64\\mingw64\\bin\\..\\lib\\clang\\3.7.0\\include" -internal-isystem "E:\\msys64\\mingw64\\bin/../i686-w64-mingw32/include" -internal-isystem "E:\\msys64\\mingw64\\bin/../include" -fdebug-compilation-dir "E:\\msys64\\home\\Martell" -ferror-limit 19 -fmessage-length 0 -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -o "E:\\msys64\\tmp\\test-71ed81.o" -x c test.c
clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target x86_64-w64-windows-gnu
ignoring nonexistent directory "E:\msys64\mingw64\bin/../i686-w64-mingw32/include"
ignoring duplicate directory "E:\msys64\mingw64\bin\..\lib\clang\3.7.0\include"
#include "..." search starts here:
#include <...> search starts here:
 E:\msys64\mingw64\bin\..\lib\clang\3.7.0\include
 E:\msys64\mingw64\bin/../include
End of search list.
 "E:\\msys64\\mingw64\\bin\\lld.exe" -m i386pe --subsystem console -Bdynamic -o a.exe "E:\\msys64\\mingw64\\bin/../i686-w64-mingw32/lib\\crt2.o" "E:\\msys64\\mingw64\\bin/../i686-w64-mingw32/lib\\crtbegin.o" "-LE:\\msys64\\mingw64\\bin/../lib" "-LE:\\msys64\\mingw64\\bin/../i686-w64-mingw32/lib" "-LE:\\msys64\\mingw64\\bin/../lib/gcc/i686-w64-mingw32/4.9.2" "E:\\msys64\\tmp\\test-71ed81.o" -flavor gnu -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt "E:\\msys64\\mingw64\\bin/../i686-w64-mingw32/lib\\crtend.o"
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _mingw_initltsdyn_force
Undefined symbol: <entry>: mainCRTStartup
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __gnu_exception_handler at 4
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __fmode
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __initterm
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __newmode
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _mingw_initltsdrot_force
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __MINGW_INSTALL_DEBUG_MATHERR
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __set_invalid_parameter_handler
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___xc_z
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___getmainargs
Undefined symbol: __imp___acmdln: __acmdln
Undefined symbol: __imp__GetStartupInfoA at 4: _GetStartupInfoA at 4
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___native_startup_state
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___xi_z
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _mingw_initcharmax
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___dyn_tls_init_callback
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __fpreset
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___mingw_setusermatherr
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _malloc
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __amsg_exit
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___security_init_cookie
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _mingw_app_type
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___main
Undefined symbol: __imp____initenv: ___initenv
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __pei386_runtime_relocator
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___onexitend
Undefined symbol: __imp__SetUnhandledExceptionFilter at 4: _SetUnhandledExceptionFilter at 4
Undefined symbol: __imp__Sleep at 4: _Sleep at 4
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __matherr
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _exit
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __image_base__
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___onexitbegin
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __dowildcard
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___chkstk_ms
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___set_app_type
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _mingw_initltssuo_force
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __encode_pointer
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___native_startup_lock
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___mingw_oldexcpt_handler
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _memcpy
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: _strlen
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___xc_a
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __setargv
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: __cexit
Undefined symbol: E:\msys64\mingw64\bin/../i686-w64-mingw32/lib\crt2.o: ___xi_a
symbol(s) not found
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-COFF-add-the-mingw-alias-for-ImageBase.patch
Type: application/octet-stream
Size: 748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/b5d51664/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-PECOFF-add-the-mingw-alias-for-ImageBase.patch
Type: application/octet-stream
Size: 3110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/b5d51664/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-PECOFF-add-searchLibrary-function-with-sysroot-suppo.patch
Type: application/octet-stream
Size: 3562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/b5d51664/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-GNU-add-support-for-linking-PECOFF.patch
Type: application/octet-stream
Size: 28149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/b5d51664/attachment-0003.obj>


More information about the llvm-commits mailing list