Discussion:
How is a Cygwin EXE/DLL customized?
Paul Benedict
2018-07-25 22:25:27 UTC
Permalink
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
Marco Atzeri
2018-07-26 07:26:56 UTC
Permalink
Post by Paul Benedict
Good day,
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.
you should look at the patches for GCC included in the source package
code. You can download it with cygwin setup, just click on the "Src ?"
column for the gcc row. It will be put in "/usr/src"

There are no patches for binutils/ld for what I see on its source
package
Post by Paul Benedict
Cheers and God bless,
Paul
Regards
Marco


---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
cyg Simple
2018-07-26 12:41:56 UTC
Permalink
Post by Marco Atzeri
Post by Paul Benedict
Good day,
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.
you should look at the patches for GCC included in the source package
code. You can download it with cygwin setup, just click on the "Src ?"
column for the gcc row. It will be put in "/usr/src"
You should also move this conversation to ***@cygwin.com as this list
is about developing Cygwin, not a general forum of how things are done.
--
cyg Simple
Loading...