msys2 / msys2-runtime

Our friendly fork of Cygwin 💖 https://cygwin.org 💖 see the wiki for details
https://github.com/msys2/msys2-runtime/wiki
GNU General Public License v2.0
185 stars 39 forks source link

msys2-runtime-3.3 binaries no longer work #200

Closed jeremyd2019 closed 9 months ago

jeremyd2019 commented 9 months ago

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.

jeremyd2019 commented 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...

lazka commented 9 months ago

https://github.com/bminor/binutils-gdb/commit/c53c6186c8d69586a71a7f8284a9ed7fa8cb207f / https://sourceware.org/bugzilla/show_bug.cgi?id=30142 ?

jeremyd2019 commented 9 months ago

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.