Paul Benedict
2018-07-25 22:25:27 UTC
Good day,
I am researching and trying to learn how an EXE/DLL produced by Cygwin's toolchain gets special treatment. This email I write only after doing several days of diligent research. Some things I have done so far... Read the FAQ [1], searched through Stack Overflow and Cygwin mailing lists, built a simple EXE+DLL combo project, inspected the binaries with MS Dependency Walker, dumped symbols using the "nm" command, and read several relevant source files [2]... At this point, I hit a wall; that's why I am turning to the development community. I hope you find this email well.
So it appears to me Cygwin is customizing the GNU toolchain. Am I on the right track? Please correct anything I have misunderstood and gotten wrong. The customization is most apparent as such:
*) Cygwin GCC is automatically stubbing in initialization code before any of my code
*) Cygwin LD is automatically linking to cygwin1.dll
If what I am seeing is correct, can I be pointed to the Cygwin Git project and/or files where those customizations of GCC and LD have taken place? I am really interested in learning the "boot" sequences of Cygwin EXE/DLL and how they get written into the binaries. Documentation in this area seems very scarce.
Thank you!
References:
[1] https://cygwin.com/faq.html#faq.programming.msvs-mingw
[2] From Git HEAD:
winsup/cygwin/crt0.c
winsup/cygwin/cygthread.cc
winsup/cygwin/cygtls.cc
winsup/cygwin/cygtls.h
winsup/cygwin/cygtls_padsize.h
winsup/cygwin/dll_init.cc
winsup/cygwin/dll_init.h
winsup/cygwin/external.cc
winsup/cygwin/how-cygtls-works.txt
winsup/cygwin/how-startup-shutdown-works.txt
winsup/cygwin/include/cygwin/cygwin_dll.h
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/lib/cygwin_attach_dll.c
winsup/cygwin/lib/libcmain.c
winsup/cygwin/lib/premain[0/1/2/3].c
winsup/cygwin/winsup.h
winsup/testsuite/winsup.api/cygload.cc
winsup/testsuite/winsup.api/cygload.h
Cheers and God bless,
Paul
I am researching and trying to learn how an EXE/DLL produced by Cygwin's toolchain gets special treatment. This email I write only after doing several days of diligent research. Some things I have done so far... Read the FAQ [1], searched through Stack Overflow and Cygwin mailing lists, built a simple EXE+DLL combo project, inspected the binaries with MS Dependency Walker, dumped symbols using the "nm" command, and read several relevant source files [2]... At this point, I hit a wall; that's why I am turning to the development community. I hope you find this email well.
So it appears to me Cygwin is customizing the GNU toolchain. Am I on the right track? Please correct anything I have misunderstood and gotten wrong. The customization is most apparent as such:
*) Cygwin GCC is automatically stubbing in initialization code before any of my code
*) Cygwin LD is automatically linking to cygwin1.dll
If what I am seeing is correct, can I be pointed to the Cygwin Git project and/or files where those customizations of GCC and LD have taken place? I am really interested in learning the "boot" sequences of Cygwin EXE/DLL and how they get written into the binaries. Documentation in this area seems very scarce.
Thank you!
References:
[1] https://cygwin.com/faq.html#faq.programming.msvs-mingw
[2] From Git HEAD:
winsup/cygwin/crt0.c
winsup/cygwin/cygthread.cc
winsup/cygwin/cygtls.cc
winsup/cygwin/cygtls.h
winsup/cygwin/cygtls_padsize.h
winsup/cygwin/dll_init.cc
winsup/cygwin/dll_init.h
winsup/cygwin/external.cc
winsup/cygwin/how-cygtls-works.txt
winsup/cygwin/how-startup-shutdown-works.txt
winsup/cygwin/include/cygwin/cygwin_dll.h
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/lib/cygwin_attach_dll.c
winsup/cygwin/lib/libcmain.c
winsup/cygwin/lib/premain[0/1/2/3].c
winsup/cygwin/winsup.h
winsup/testsuite/winsup.api/cygload.cc
winsup/testsuite/winsup.api/cygload.h
Cheers and God bless,
Paul