Bug#319999: porting asm to gcc
On Mon, 2008-10-27 at 18:24 +0100, Thomas Gaugler wrote: thanks a lot for trying out the patch on your system and updating the entry on Sourceforge. no probs I build the System plugin with your latest uploaded patch on Souceforge (gcc-system-call-2.patch) and it compiled flawlessly with Visual Studio 2005 on Windows XP. I used the attached solution and project files for building. Excellent Unfortunately I could not get scons to coperate with Visual Studio 2005. Hmm, OK. I've posted a request for testing in the upstream forum: http://forums.winamp.com/showthread.php?s=goto=lastpostthreadid=227304 Hopefully one of the devs or someone with a working NSIS scons setup will try the patch out and reply positively. I created test.py mainly to ease my work of rewriting the C with intermixed assembly part of the System plugin. In general, I thought it might be useful for developers creating NSIS plugins. I did not have on my mind to integrate it with the build system of NSIS. On the other hand I have got nothing against including the script into any regression test framework set up for NSIS. Wine might be suitable for running tests on Debian. Anyway I would leave this decision to the core developers of NSIS. OK, I guess I'll leave it out then, since it isn't universally useful for regression testing. Changes to the System.nsi script to make it test more stuff would be better I think. -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
On Sat, 2008-10-25 at 20:14 +0200, Thomas Gaugler wrote: I am amazed of your work enthusiasm. Thanks a lot for the scons work and fixing the raised GCC warnings for System.c. My pleasure, thanks for doing the porting! I also run the System Plugin example (Contrib/System/System.nsi) on my setup (System.dll built with mingw under Windows XP) but have not experienced a crash. However I do not recall that any Splash screen popped up. So it is likely that I should be able to locate the bug with my current setup as well. It is possible that the fix I used for the lvalue required as increment operand error is quite wrong, since it doesn't increment the pointer, and a result of that might be the crash. Here is a random google result about the error: http://groups.google.com.bz/group/comp.lang.c/msg/bde1c31e563e26c3 Could you please let me know your setup just in case the bug should not reveal in my setup. I assume you use the stable mingw32 (3.4.5.20060117.1.dfsg-2), mingw32-binutils (2.16.91-20060119.1-1) and ming32-runtime (3.9-4) packages on Debian Etch. I'm using the mingw packages from Debian lenny: dpkg -l | grep mingw ii mingw32 4.2.1.dfsg-1 Minimalist GNU win32 (cross) compiler ii mingw32-binutils 2.18.50-20080109-1 Minimalist GNU win32 (cross) binutils ii mingw32-runtime 3.13-1 Minimalist GNU win32 (cross) runtime Newer GCC versions are generally stricter with bad C syntax. http://sourceforge.net/tracker/index.php?func=detailaid=2193442group_id=22049atid=373087 Fixing the invalid lvalue FTBFS properly. What does FTBFS mean? Sorry, Debian jargon, means Fails To Build From Source. -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
Hi Pabs, I come back to your offer to figure out the scons side. The attached patch (against nsis-2.40) implements the functions CallProc, RealCallBack and CallBack of the System plugin in pure x86 assembly. The call.asm assembly source file supports both the MASM and GNU assembler in one file. The trick lies in the ; .if 0 line which is ignored by MASM but evaluated by the GNU assembler. The stack probing function _alloca_probe is equivalent to _chkstk. GCC provides an equivalent function in libgcc called _alloca. For details see the discussion in: http://gcc.gnu.org/ml/gcc/2006-11/msg00081.html I refrained from using hardcoded offsets for the structures SystemProc and ProcParameter but rather opted for C helper functions for determining these offsets. As a result it is easier for maintenance because changes to the SystemProc and ProcParameter structures would not affect the assembly source code. As a side effect the hardcoded offset SYSTEM_ZERO_PARAM_VALUE_OFFSET in System.h is no longer needed. I changed the macros SYSTEM_LOG_ADD and SYSTEM_LOG_POST in System.c to avoid an access violation in case call.asm was compiled without the SYSTEM_DEBUG_LOG define. DllMain is used instead of _DllMainCRTStartup to avoid an endless recursion for the debug report macro _RPT0. The system DllMain initializes the C runtime environment. In particular the value for _osplatform is initialized. In the function _get_winmajor called in the execution of the _RPT0 macro an assertion failure is raised if _osplatform is not set. The assertion is reported by the same means as used for the _RPT0 macro. This leads to an endless recursion. By default the define SYSTEM_DEBUG_LOG is not set. So it would be ok to stick with _DllMainCRTStartup. I used the attached test.py python script for unit testing the System plug-in. For building the System plug-in I used the development environment of Microsoft Visual Studio 8 and the following batch script for the GNU toolchain: @echo off setlocal set TOOLCHAIN_PATH=C:\mingw\bin rem SET DEBUG=-DSYSTEM_DEBUG_LOG set DEFINES=-DWIN32 -DNDEBUG -D_WINDOWS -D_USERDLL %DEBUG% set CFLAGS=-g -Os -Wall %DEFINES% set SRCS=Buffers.c Plugin.c stdafx.c System.c set ASM_SRCS=call.asm set OBJS=Buffers.o call.o Plugin.o stdafx.o System.o et AS=%TOOLCHAIN_PATH%\gcc.exe -x assembler-with-cpp -s set GCC=%TOOLCHAIN_PATH%\gcc.exe for %%F in (%SRCS%) do %GCC% %CFLAGS% -c %%F for %%F in (%ASM_SRCS%) do %AS% %DEFINES% -c %%F %GCC% -shared %OBJS% -mwindows -o System.dll -lole32 -Wl,--add-stdcall-alias enlocal So that's where scons respectively you are welcome to take over. Best regards, Thomas diff -urN nsis-2.40-src.orig/Contrib/System/Source/call.asm nsis-2.40-src/Contrib/System/Source/call.asm --- nsis-2.40-src.orig/Contrib/System/Source/call.asm 1970-01-01 01:00:00.0 +0100 +++ nsis-2.40-src/Contrib/System/Source/call.asm 2008-10-24 20:15:22.0 +0200 @@ -0,0 +1,954 @@ +;# Copyright (c) 2008 Thomas Gaugler [EMAIL PROTECTED] +;# +;# Permission is hereby granted, free of charge, to any person +;# obtaining a copy of this software and associated documentation +;# files (the Software), to deal in the Software without +;# restriction, including without limitation the rights to use, +;# copy, modify, merge, publish, distribute, sublicense, and/or sell +;# copies of the Software, and to permit persons to whom the +;# Software is furnished to do so, subject to the following +;# conditions: +;# +;# The above copyright notice and this permission notice shall be +;# included in all copies or substantial portions of the Software. +;# +;# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, +;# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +;# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +;# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +;# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +;# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +;# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +;# OTHER DEALINGS IN THE SOFTWARE. +;# +;# +;# Implementation of the functions CallProc, RealCallBack and +;# CallBack of the System plugin in pure x86 assembly. +;# +;# This is a hybrid assembly source file supporting both the +;# MASM as well as the GNU assembler in one file. +;# +;# +;# MASM: +;# ml.exe /c /nologo /Focall.obj /W3 /Zi /errorReport:prompt /Tacall.asm +;# +;# For enabling debug support use: +;# ml.exe /c /nologo /DSYSTEM_DEBUG_LOG /Focall.obj /W3 /Zi /errorReport:prompt /Tacall.asm +;# +;# GNU toolchain: +;# gcc -x assembler-with-cpp -s call.asm -c +;# +;# For enabling debug support use: +;# gcc -x assembler-with-cpp -DSYSTEM_DEBUG_LOG -s call.asm -c +;# + +; .if 0 +;# MASM specific block +.386 +.model flat +OPTION casemap:none +;# SYSCALL is identical to the C calling convention, +;# but does not add an underscore prefix to symbols. +OPTION language:syscall + +SECTION_DATA equ
Bug#319999: porting asm to gcc
On Fri, 2008-10-24 at 21:33 +0200, Thomas Gaugler wrote: The attached patch (against nsis-2.40) implements the functions CallProc, RealCallBack and CallBack of the System plugin in pure x86 assembly. Awesome, thanks for your work! I'll work on integrating this with the nsis scons build system and propose a patch for inclusion upstream. kichik, the remainder of Thomas' message is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=31#50 -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
On Sat, 2008-10-25 at 10:06 +0800, Paul Wise wrote: I'll work on integrating this with the nsis scons build system and propose a patch for inclusion upstream. I get an error (and several warnings) compiling the resulting System.c: $ i586-mingw32msvc-gcc -o build/debug/System/Source/System.o -c -Wno-write-strings -Wall -g -O0 -g -Wall -fno-strict-aliasing -DSYSTEM_EXPORTS Contrib/System/Source/System.c Contrib/System/Source/System.c: In function 'PrepareProc': Contrib/System/Source/System.c:392: warning: cast to pointer from integer of different size Contrib/System/Source/System.c:673: warning: cast to pointer from integer of different size Contrib/System/Source/System.c:702: warning: cast to pointer from integer of different size Contrib/System/Source/System.c:725: warning: cast to pointer from integer of different size Contrib/System/Source/System.c: In function 'ParamsIn': Contrib/System/Source/System.c:807: warning: cast to pointer from integer of different size Contrib/System/Source/System.c: In function 'CreateCallback': Contrib/System/Source/System.c:918: error: lvalue required as increment operand Contrib/System/Source/System.c: In function 'DllMain': Contrib/System/Source/System.c:1022: warning: passing argument 4 of 'VirtualProtect' from incompatible pointer type Fixed the error with this patch, would that be the correct change? diff --git a/Contrib/System/Source/System.c b/Contrib/System/Source/System.c index 28983b4..970fc6e 100644 --- a/Contrib/System/Source/System.c +++ b/Contrib/System/Source/System.c @@ -915,7 +915,7 @@ HANDLE CreateCallback(SystemProc *cbproc) mem = (char *) (cbproc-Proc = VirtualAlloc(NULL, 10, MEM_COMMIT, PAGE_EXECUTE_READWRITE)); *(mem++) = (char) 0xB8; // Mov eax, const -*(((int *)mem)++) = (int) cbproc; +*(((int *)mem)+1) = (int) cbproc; *(mem++) = (char) 0xe9; // Jmp relative *((int *)mem) = (int) RealCallBack; *((int *)mem) -= ((int) mem) + 4; -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
On Sat, 2008-10-25 at 10:06 +0800, Paul Wise wrote: I'll work on integrating this with the nsis scons build system and propose a patch for inclusion upstream. This is now done, except for integration of test.py. I had to rename the .asm file to .spp because otherwise scons runs 'as' instead of 'gcc' and the compile fails. As a result I was able to remove all but two of the test scripts from ignore_tests :D Didn't test the results under Windows yet though. -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
On Sat, 2008-10-25 at 11:29 +0800, Paul Wise wrote: Didn't test the results under Windows yet though. Most of the tests that used System.dll and were disabled before seem fine with the new System.dll. One exception was that Contrib/System/System.nsi crashed at the systemSplash demo stage, which does not happen when using the System.dll from 2.40. If you could investigate this, that would be good. -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
forwarded 31 http://sf.net/support/tracker.php?aid=2193442 thanks On Sat, 2008-10-25 at 11:29 +0800, Paul Wise wrote: On Sat, 2008-10-25 at 10:06 +0800, Paul Wise wrote: I'll work on integrating this with the nsis scons build system and propose a patch for inclusion upstream. This is now done, except for integration of test.py. I've sent the updated patch upstream: http://sf.net/support/tracker.php?aid=2193442 If you'd like to do the remaining items documented there, please post new versions of patch there. -- bye, pabs http://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part
Bug#319999: porting asm to gcc
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 it's not a big deal to port this code, but some time ago I got problems with naked msvc flag gcc was not really producing the same code and some assumptions cannot be made I just don't understand why doing external calls in this brutal way Regards - -- Gianluigi Tiesi [EMAIL PROTECTED] EDP Project Leader Netfarm S.r.l. - http://www.netfarm.it/ Free Software: http://oss.netfarm.it/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFH04Yb3UE5cRfnO04RAi6QAKC+x0gIy1ILWEsUq4npZkYieFQAagCdHV+y EdmSJR/Dww2prtHNXYyrcAs= =N3uy -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]