This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: Avoid collisions between parallel installations of Cygwin
On Oct 21 02:28, Dave Korn wrote:
> Corinna Vinschen wrote:
>
> > Does anybody have an idea what's going on? Am I doing something
> > wrong or are these Windows function really broken?
>
> Cygwin keeps long section names in a string table which is brutally
> concatenated on the end of the PE executable - generally that means
> "immediately after the resources". Long section names are non-standard in the
> PE format so I expect the standard ABIs won't handle it.
>
> I don't know whether using --disable-long-section-names is a practical
> solution;
I just tried this:
$ objcopy --rename-section .autoload_text=.autol \
--rename-section .cygwin_dll_common=.cdc \
--rename-section .gnu_debuglink=.gnudl \
/bin/cygwin1.dll ./cygwin1.dll.temp
$ cygcheck --disable-unique-object-names cygwin1.dll.temp
Unique object names are disabled
$ cygcheck --show-unique-object-names cygwin1.dll.temp
Unique object names are disabled
$ objdump -h cygwin1.dll.temp
cygwin1.dll.temp: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00180f04 61001000 61001000 00000400 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .autol 00001548 61182000 61182000 00181400 2**3
CONTENTS, ALLOC, LOAD, CODE
2 .data 00015f48 61184000 61184000 00182a00 2**5
CONTENTS, ALLOC, LOAD, DATA
3 .rdata 000563e4 6119a000 6119a000 00198a00 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .bss 0002a690 611f1000 611f1000 00000000 2**5
ALLOC
5 .edata 00008c90 6121c000 6121c000 001eee00 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .rsrc 0000047c 61225000 61225000 001f7c00 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .reloc 00015548 61226000 61226000 001f8200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .cdc 0000a260 6123c000 6123c000 0020d800 2**5
CONTENTS, ALLOC, LOAD, DATA, SHARED
9 .gnudl 00000010 61247000 61247000 00217c00 2**2
CONTENTS, READONLY, EXCLUDE
10 .idata 00008000 61248000 61248000 00217e00 2**2
CONTENTS, ALLOC, LOAD, DATA
11 .cygheap 000b0000 61250000 61250000 00000000 2**2
ALLOC
So, everything looks fine, except for the .rsrc section which, again,
is 0x1c bytes longer than before. But then this:
$ objcopy --rename-section .autol=.autoload_text \
--rename-section .cdc=.cygwin_dll_common \
--rename-section .gnudl=.gnu_debuglink \
cygwin1.dll.temp cygwin1.dll
objcopy:cygwin1.dll.temp: File truncated
Uh oh. Since the long section names are not required to *use* the DLL,
let's try this:
$ cp /bin/ls.exe . <== For testing
$ mv cygwin1.dll.temp cygwin1.dll
$ ./ls
$ <== No output
So the Windows functions *did* break the file, independent of the long
section names. I assume the broken section names are just a
side-effect.
I'm inclined to create a script instead, which fetches the file offset
of the Unicode string L"CYGPROCS", skips the right number of bytes to
the actual data, and then just overwrites the data.
$ strings -el -tx /bin/cygwin1.dll | grep CYGPROPS
1f7c82 CYGPROPS
The data starts at 0x1f7cb4, so the offset is 50 bytes. What POSIX
tool allows to stream a file from stdin to stdout while changing
specified binary data? Perl, as usual, I assume, but is there some
simple already existing tool for that?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat