Closed jeremyd2019 closed 9 months ago
OK, check this out:
$ objdump -h /usr/bin/msys-2.0.dll
/usr/bin/msys-2.0.dll: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
...
11 .rsrc 00000408 612e6000 612e6000 002a6a00 2**2
CONTENTS, ALLOC, LOAD, DATA
12 .cygheap 00209000 612e7000 612e7000 00000000 2**2
ALLOC
$ nm -B /usr/bin/msys-2.0.dll | grep cygheap_start
612e6408 D __cygheap_start
$ objdump -h usr/bin/msys-2.0.dll
usr/bin/msys-2.0.dll: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
...
11 .rsrc 00000408 612e5000 612e5000 002a6200 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
12 .cygheap 0020a000 612e6000 612e6000 00000000 2**2
ALLOC
$ nm -B usr/bin/msys-2.0.dll | grep cygheap_start
612e5408 R __cygheap_start
So _cygheap_start
is actually in the .rsrc
section, and that section seems to have changed to be READONLY. That actually makes some sense, due to:
https://github.com/msys2/msys2-runtime/blob/3cba82a63c4f3a8c10565ab531fb64a5d2117474/winsup/cygwin/cygwin.sc.in#L141-L156
Maybe the solution is to figure out how to make the .rsrc
section writable again? I have to imagine there's some good reason why _cygheap_start
was put in the .rsrc
instead of .cygheap
section to begin with...
I saw that, but I don't yet see a way to force the section to be writable. I've been playing with objcopy but I'm not getting --set-section-flags to do what I want.
From https://github.com/msys2/MSYS2-packages/pull/4421, it was discovered that msys2-runtime-3.3-3.3.6-7 does not work, while -6 does, both on x86_64 and i686. On i686 at least, I found that downgrading to binutils-2.40-1 resulted in a working dll while any later version I tried did not.
Again on i686, I found that it crashed early on when the dll was loaded, in a
memset
call. It appears that the memory at_cygheap_start
is not writable anymore.