Difference between revisions of "User:Sgielen/Patches"
(Update to Clean 2.3 version →RuntimeSystem patch) |
(Update to Clean 2.3 version →CodeGenerator patch) |
||
Line 51: | Line 51: | ||
This patch needs to be cleaned up sometime soon, because it contains a lot of unneeded debugging and obsolete changes. Also, this patch corrects only some cases of the printf format bug - that should be split off into a separate patch that fixes the problem at least everywhere in these files. | This patch needs to be cleaned up sometime soon, because it contains a lot of unneeded debugging and obsolete changes. Also, this patch corrects only some cases of the printf format bug - that should be split off into a separate patch that fixes the problem at least everywhere in these files. | ||
− | MD5 sum: | + | MD5 sum: d257e6736f67c811fa2459c69f176b27 |
− | [http://files.dazjorz.com/clean/clean_mac_codegenerator.patch Download patch] (last updated | + | [http://files.dazjorz.com/clean/clean_mac_codegenerator.patch Download patch] (last updated December 28, 2010, version 4) |
=== Technical details on this patch === | === Technical details on this patch === |
Revision as of 12:44, 28 December 2010
These are some of my patches to Clean. They make it possible (or /more/ possible) to build Clean on a Mac. For more information, check the Clean Wiki page on building Clean on Mac.
These patches are released as close to public domain as possible; do whatever you want with them. Because this Wiki does not allow uploading .patch files, they are placed on my own webserver; an MD5 sum is included on this page.
Warning: I am in the process of moving this page from my own webserver to this Wiki. Stuff won't work yet. :)
RuntimeSystem patch
Apply outside the bootstrap package (you should have a clean/src/RuntimeSystem dir). This patch will create a new Makefile.macosx based on Makefile.linux, and make some source changes.
MD5 sum: 2e857ebe4295b00d6d725fa99c4ac6a9
Download patch (last updated December 28, 2010, version 4)
Technical details on this patch
This patch makes a few changes to assembly and C code. It makes sure that the assembly code is assemble-able and the C code compilable. I should check this patch through once more, because it might contain some changes that aren't needed anymore now that the Clean on Mac OS X page uses newest `gas`.
As for this hunk:
- /* not portable to all compilers: */ -#ifdef LINUX -/* - if (file_p->_gptr < file_p->_egptr) -*/ - if (file_p->_IO_read_ptr < file_p->_IO_read_end) -#else -# ifdef OS2 - if (file_p->rcount>0) -# else -# ifdef _WINDOWS_ - if (file_p->_r>0) -# else - if (file_p->_cnt>0) -# endif -# endif -#endif - return 0; + file_p = f->file; + if(feof(file_p)) + return -1;
This was not portable at all. What I think the hunk does, is see if a read() call will block because there is no data available for reading. The function will return 0 if there is data available for reading, i.e. this method will "read ahead". However, this is an ugly hack, so I've simply removed it for a feof() function; I hope this will work and if it doesn't, I'll have to come up with another solution.
CodeGenerator patch
Apply outside the bootstrap package (you should have a clean/src/CodeGenerator dir). This patch will create a new Makefile.macosx based on Makefile.linux, and will improve debugging output in many cases. It also corrects some string formatting security bugs, and fixes FTBFS for x86-64 on Macs.
This patch needs to be cleaned up sometime soon, because it contains a lot of unneeded debugging and obsolete changes. Also, this patch corrects only some cases of the printf format bug - that should be split off into a separate patch that fixes the problem at least everywhere in these files.
MD5 sum: d257e6736f67c811fa2459c69f176b27
Download patch (last updated December 28, 2010, version 4)
Technical details on this patch
AT&T assembly mode is no longer needed - now that the guide uses the latest incarnation of GNU `gas`, the generated Intel ASM is just fine.
The string formatting security bugs should speak for themselves in this patch. The code contained, in some places,
printf(string)
instead of
printf("%s",string)
This makes injection of format placeholders in the given string possible - an easy way to crash the application would be to send a string containing a few "%s%s%s", for example.
The debugging output changes may be helpful later, when debugging the final build of Clean.
CLM makefiles and debugging improvements
This patch adds a new Makefile.macosx for CLM, improves some debugging messages, and enables AT&T assembly in the code generator. Now that the guide is using GNU `gas`, I don't think AT&T ASM is needed anymore, Intel ASM will do better. This patch should be updated to reflect that. Other than that, the patch is clean.
MD5 sum: 7905de9c52f77ba3d68f424ab75871fe
Download patch (last updated October 28, 2010, version 2)
Stdenv inclusion in the main Makefile
For me, stdenv inclusion while building the elf linker was necessary to build.
Download patch (last updated September 6, 2010)