Re: trying to build gdb with renamed cygwin1.dll

Brian Dessent
2007-04-30T15:32:24Z

Fahd Abidi wrote:

> I was trying to build a gdb version that would use a renamed version of
> cygwin1.dll and some of the other dll's that gdb seem to depend on. I
>
> [...]
>
> Is this going to be possible to do?

Short answer, it's not going to be possible without a lot more work than
what you've done. Unfortunately, Cygwin is complicated, and it jumps
through a ton of hoops to get that magical POSIX emulation under Win32.

Since this is the gdb list it's not particularly topical, so I will try
to be brief. I'm sure gdb developers don't really care about this much
so please take any replies to the Cygwin list.

For one thing, as Bob already mentioned, Cygwin uses a shared memory
region for interprocess communication between other Cygwin processes to
coordinate signals and child/parent communications and so forth. The
name of this shared memory region must be changed in order to actually
isolate two Cygwin DLLs. While you're at it you'd also have to change
the registry key used for the mount table, otherwise both Cygwins will
share the same notions of posix-win32 path mappings. And there is also
a "magic prefix" used to differentiate Cygwin strace messages from other
OutputDebugString() output that you would have to also change so that
two Cygwins would not collide when using strace or gdb.

Further, linking against the Cygwin DLL requires use of an import
library (due to symbol name aliases), and when using an import library
to link the name of the DLL is embedded into the import library. This
is convenient because it allows for easy library versioning, i.e. you
have an import library libfoo.dll.a that internally references
cygfoo-<some version number>.dll. Thus you can still link with just
-lfoo but this will pick up the most recent version of the library where
multiple ones exist. It's directly analogous to making the symlink
libfoo.so -> libfoo-<version>.so on ELF systems.

And the Cygwin DLL is just one; all of the other libs you are using all
have their own import libraries, so they would all need to be rebuilt
with a different DLL name too. (Hardly anything in the Cygwin distro
makes use of the "direct to DLL linking without import library" feature
of ld, you will find.) You will end up doing a "make world", patching
and recompiling just about every single library. Don't forget that gcc
has a -lcygwin in its specs file, so you will need to patch that too.

Finally, there are places in the Cygwin source and build machinery that
assume the DLL is named "cygwin<n>.dll", so if you change this (and
especially if you change it to something of a different length) you will
likely have to patch these places too.

Brian