diff --git a/programs/develop/libraries/Mesa/configs/current b/programs/develop/libraries/Mesa/configs/current index 93f504ede5..cf401ce8ed 100644 --- a/programs/develop/libraries/Mesa/configs/current +++ b/programs/develop/libraries/Mesa/configs/current @@ -1,12 +1,11 @@ -# Autoconf configuration - -# Pull in the defaults +#Pull in the defaults include $(TOP)/configs/default # This is generated by configure CONFIG_NAME = autoconf # Compiler and flags + AR = ar rc CC = gcc CXX = g++ diff --git a/programs/develop/libraries/Mesa/src/mesa/main/context.c b/programs/develop/libraries/Mesa/src/mesa/main/context.c index 5fe71db422..894025e74a 100644 --- a/programs/develop/libraries/Mesa/src/mesa/main/context.c +++ b/programs/develop/libraries/Mesa/src/mesa/main/context.c @@ -438,7 +438,7 @@ one_time_init( struct gl_context *ctx ) /* Hopefully atexit() is widely available. If not, we may need some * #ifdef tests here. */ -// atexit(_mesa_destroy_shader_compiler); + atexit(_mesa_destroy_shader_compiler); dummy_enum_func(); } diff --git a/programs/develop/libraries/cairo/Makefile b/programs/develop/libraries/cairo/Makefile index 2f43c2891a..94ac9bb218 100644 --- a/programs/develop/libraries/cairo/Makefile +++ b/programs/develop/libraries/cairo/Makefile @@ -7,7 +7,7 @@ CFLAGS = -c -O2 -fomit-frame-pointer -ffast-math LDIMPORT:= -nostdlib --out-implib libcairoimp.a --exclude-libs libamz.a -LDFLAGS:= -shared -s -T ../newlib/dll.lds -Map map --image-base 0 +LDFLAGS:= -shared -s -T ../newlib/dll.lds --image-base 0 DEFINES = -DHAVE_CONFIG_H -DCAIRO_NO_MUTEX -U_WIN32 -U_MSC_VER -U__WIN32__ @@ -125,6 +125,8 @@ $(LIBRARY).dll: $(OBJECTS) Makefile %.o : %.c Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< +clean: + -rm -f */*.o diff --git a/programs/develop/libraries/libmpg123/Makefile b/programs/develop/libraries/libmpg123/Makefile index b2bed8e68b..6fe6f76102 100644 --- a/programs/develop/libraries/libmpg123/Makefile +++ b/programs/develop/libraries/libmpg123/Makefile @@ -4,9 +4,9 @@ CPP=gcc -E CFLAGS= -c -combine -O2 -fomit-frame-pointer -ffast-math -mmmx -finline-functions -LDIMPORT:= -nostdlib --out-implib libmpg123imp.a +LDIMPORT:= -nostdlib --out-implib libmpg123imp.a --exclude-libs libamz.a -LDFLAGS:= -shared -s -T../newlib/dll.lds -Map map --image-base 0 +LDFLAGS:= -shared -s -T../newlib/dll.lds --image-base 0 INCLUDES= -I../newlib/include @@ -61,4 +61,8 @@ $(NAME).dll: $(SRCS_OBJ) $(ASM_OBJS) Makefile %.o: %.c Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< + +clean: + -rm -f *.o + \ No newline at end of file diff --git a/programs/develop/libraries/libpng/Makefile b/programs/develop/libraries/libpng/Makefile index 96d277058f..c26d439b40 100644 --- a/programs/develop/libraries/libpng/Makefile +++ b/programs/develop/libraries/libpng/Makefile @@ -7,11 +7,11 @@ AR= ar rc CFLAGS = -c -O2 -fomit-frame-pointer -LDIMPORT:= -nostdlib --out-implib libpngimp.a --exclude-libs libamz.a +LDIMPORT:= -nostdlib --out-implib libpngimp.a -LDFLAGS:= -shared -s -T../newlib/dll.lds -Map map --image-base 0 +LDFLAGS:= -shared -s -T../newlib/dll.lds --image-base 0 -DEFS = -DHAVE_CONFIG_H -D__DYNAMIC_REENT__ +DEFS = -DHAVE_CONFIG_H LIBPNG_DEFINES = -DPNG_CONFIGURE_LIBPNG @@ -29,7 +29,6 @@ SOURCES = png.c pngerror.c pngget.c pngmem.c pngpread.c \ pngwtran.c pngwutil.c - OBJECTS = $(patsubst %.c, %.o, $(SOURCES)) @@ -43,10 +42,14 @@ $(LIBRARY).a: $(OBJECTS) Makefile ar cvrs $(LIBRARY).a $(OBJECTS) $(LIBRARY).dll: $(OBJECTS) Makefile - ld $(LDFLAGS) $(LDIMPORT) $(LIBPATH) -o $@ $(OBJECTS) $(LIBS) + ld $(LDFLAGS) $(LDIMPORT) $(LIBPATH) -o $@ $(OBJECTS) $(LIBS) symbols.def %.o : %.c Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< +clean: + -rm -f *.o + + diff --git a/programs/develop/libraries/libpng/README b/programs/develop/libraries/libpng/README new file mode 100644 index 0000000000..9dd6745f0a --- /dev/null +++ b/programs/develop/libraries/libpng/README @@ -0,0 +1,205 @@ +README for libpng version 1.5.1 - February 3, 2011 (shared library 15.0) +See the note about version numbers near the top of png.h + +See INSTALL for instructions on how to install libpng. + +Libpng comes in several distribution formats. Get libpng-*.tar.gz, +libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings +in the text files, or lpng*.zip if you want DOS-style line endings. + +Version 0.89 was the first official release of libpng. Don't let the +fact that it's the first release fool you. The libpng library has been in +extensive use and testing since mid-1995. By late 1997 it had +finally gotten to the stage where there hadn't been significant +changes to the API in some time, and people have a bad feeling about +libraries with versions < 1.0. Version 1.0.0 was released in +March 1998. + +**** +Note that some of the changes to the png_info structure render this +version of the library binary incompatible with libpng-0.89 or +earlier versions if you are using a shared library. The type of the +"filler" parameter for png_set_filler() has changed from png_byte to +png_uint_32, which will affect shared-library applications that use +this function. + +To avoid problems with changes to the internals of png_info_struct, +new APIs have been made available in 0.95 to avoid direct application +access to info_ptr. These functions are the png_set_ and +png_get_ functions. These functions should be used when +accessing/storing the info_struct data, rather than manipulating it +directly, to avoid such problems in the future. + +It is important to note that the APIs do not make current programs +that access the info struct directly incompatible with the new +library. However, it is strongly suggested that new programs use +the new APIs (as shown in example.c and pngtest.c), and older programs +be converted to the new format, to facilitate upgrades in the future. +**** + +Additions since 0.90 include the ability to compile libpng as a +Windows DLL, and new APIs for accessing data in the info struct. +Experimental functions include the ability to set weighting and cost +factors for row filter selection, direct reads of integers from buffers +on big-endian processors that support misaligned data access, faster +methods of doing alpha composition, and more accurate 16->8 bit color +conversion. + +The additions since 0.89 include the ability to read from a PNG stream +which has had some (or all) of the signature bytes read by the calling +application. This also allows the reading of embedded PNG streams that +do not have the PNG file signature. As well, it is now possible to set +the library action on the detection of chunk CRC errors. It is possible +to set different actions based on whether the CRC error occurred in a +critical or an ancillary chunk. + +The changes made to the library, and bugs fixed are based on discussions +on the PNG-implement mailing list and not on material submitted +privately to Guy, Andreas, or Glenn. They will forward any good +suggestions to the list. + +For a detailed description on using libpng, read libpng-manual.txt. For +examples of libpng in a program, see example.c and pngtest.c. For usage +information and restrictions (what little they are) on libpng, see +png.h. For a description on using zlib (the compression library used by +libpng) and zlib's restrictions, see zlib.h + +I have included a general makefile, as well as several machine and +compiler specific ones, but you may have to modify one for your own needs. + +You should use zlib 1.0.4 or later to run this, but it MAY work with +versions as old as zlib 0.95. Even so, there are bugs in older zlib +versions which can cause the output of invalid compression streams for +some images. You will definitely need zlib 1.0.4 or later if you are +taking advantage of the MS-DOS "far" structure allocation for the small +and medium memory models. You should also note that zlib is a +compression library that is useful for more things than just PNG files. +You can use zlib as a drop-in replacement for fread() and fwrite() if +you are so inclined. + +zlib should be available at the same place that libpng is, or at. +ftp://ftp.info-zip.org/pub/infozip/zlib + +You may also want a copy of the PNG specification. It is available +as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find +these at http://www.libpng.org/pub/png/documents/ + +This code is currently being archived at libpng.sf.net in the +[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT) +at GO GRAPHSUP. If you can't find it in any of those places, +e-mail me, and I'll help you find it. + +If you have any code changes, requests, problems, etc., please e-mail +them to me. Also, I'd appreciate any make files or project files, +and any modifications you needed to make to get libpng to compile, +along with a #define variable to tell what compiler/system you are on. +If you needed to add transformations to libpng, or wish libpng would +provide the image in a different way, drop me a note (and code, if +possible), so I can consider supporting the transformation. +Finally, if you get any warning messages when compiling libpng +(note: not zlib), and they are easy to fix, I'd appreciate the +fix. Please mention "libpng" somewhere in the subject line. Thanks. + +This release was created and will be supported by myself (of course +based in a large way on Guy's and Andreas' earlier work), and the PNG +development group. + +Send comments/corrections/commendations to png-mng-implement at +lists.sourceforge.net (subscription required; visit +https://lists.sourceforge.net/lists/listinfo/png-mng-implement +to subscribe) or to glennrp at users.sourceforge.net + +You can't reach Guy, the original libpng author, at the addresses +given in previous versions of this document. He and Andreas will +read mail addressed to the png-implement list, however. + +Please do not send general questions about PNG. Send them to +the (png-list at ccrc.wustl.edu, subscription required, write to +majordomo at ccrc.wustl.edu with "subscribe png-list" in your message). +On the other hand, +please do not send libpng questions to that address, send them to me +or to the png-implement list. I'll +get them in the end anyway. If you have a question about something +in the PNG specification that is related to using libpng, send it +to me. Send me any questions that start with "I was using libpng, +and ...". If in doubt, send questions to me. I'll bounce them +to others, if necessary. + +Please do not send suggestions on how to change PNG. We have +been discussing PNG for nine years now, and it is official and +finished. If you have suggestions for libpng, however, I'll +gladly listen. Even if your suggestion is not used immediately, +it may be used later. + +Files in this distribution: + + ANNOUNCE => Announcement of this version, with recent changes + CHANGES => Description of changes between libpng versions + KNOWNBUG => List of known bugs and deficiencies + LICENSE => License to use and redistribute libpng + README => This file + TODO => Things not implemented in the current library + Y2KINFO => Statement of Y2K compliance + example.c => Example code for using libpng functions + libpng.3 => manual page for libpng (includes libpng-manual.txt) + libpng-manual.txt => Description of libpng and its functions + libpngpf.3 => manual page for libpng's private functions + png.5 => manual page for the PNG format + png.c => Basic interface functions common to library + png.h => Library function and interface declarations (public) + pngpriv.h => Library function and interface declarations (private) + pngconf.h => System specific library configuration (public) + pngstruct.h => png_struct declaration (private) + pnginfo.h => png_info struct declaration (private) + pngdebug.h => debugging macros (private) + pngerror.c => Error/warning message I/O functions + pngget.c => Functions for retrieving info from struct + pngmem.c => Memory handling functions + pngbar.png => PNG logo, 88x31 + pngnow.png => PNG logo, 98x31 + pngpread.c => Progressive reading functions + pngread.c => Read data/helper high-level functions + pngrio.c => Lowest-level data read I/O functions + pngrtran.c => Read data transformation functions + pngrutil.c => Read data utility functions + pngset.c => Functions for storing data into the info_struct + pngtest.c => Library test program + pngtest.png => Library test sample image + pngtrans.c => Common data transformation functions + pngwio.c => Lowest-level write I/O functions + pngwrite.c => High-level write functions + pngwtran.c => Write data transformations + pngwutil.c => Write utility functions + contrib => Contributions + gregbook => source code for PNG reading and writing, from + Greg Roelofs' "PNG: The Definitive Guide", + O'Reilly, 1999 + msvctest => Builds and runs pngtest using a MSVC workspace + pngminus => Simple pnm2png and png2pnm programs + pngsuite => Test images + visupng => Contains a MSVC workspace for VisualPng + projects => Contains project files and workspaces for + building a DLL + cbuilder5 => Contains a Borland workspace for building + libpng and zlib + visualc6 => Contains a Microsoft Visual C++ (MSVC) + workspace for building libpng and zlib + visualc71 => Contains a Microsoft Visual C++ (MSVC) + workspace for building libpng and zlib + xcode => Contains an Apple xcode + workspace for building libpng and zlib + scripts => Directory containing scripts for building libpng: + (see scripts/README.txt for the list of scripts) + +Good luck, and happy coding. + +-Glenn Randers-Pehrson (current maintainer, since 1998) + Internet: glennrp at users.sourceforge.net + +-Andreas Eric Dilger (former maintainer, 1996-1997) + Internet: adilger at enel.ucalgary.ca + Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ + +-Guy Eric Schalnat (original author and former maintainer, 1995-1996) + (formerly of Group 42, Inc) + Internet: gschal at infinet.com diff --git a/programs/develop/libraries/libpng/pnglibconf.h b/programs/develop/libraries/libpng/pnglibconf.h index 52a158bf35..8fbe0038dd 100644 --- a/programs/develop/libraries/libpng/pnglibconf.h +++ b/programs/develop/libraries/libpng/pnglibconf.h @@ -46,7 +46,7 @@ #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_USER_LIMITS_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ +#define PNG_ERROR_NUMBERS_SUPPORTED #define PNG_ERROR_TEXT_SUPPORTED #define PNG_READ_SUPPORTED /*#undef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED*/ diff --git a/programs/develop/libraries/libpng/symbols.def b/programs/develop/libraries/libpng/symbols.def new file mode 100644 index 0000000000..239bbe3c77 --- /dev/null +++ b/programs/develop/libraries/libpng/symbols.def @@ -0,0 +1,227 @@ +;-------------------------------------------------------------- +; LIBPNG symbol list as a Win32 DEF file +; Contains all the symbols that can be exported from libpng +;-------------------------------------------------------------- +LIBRARY + +EXPORTS +;Version 1.5.1 + png_access_version_number @1 + png_set_sig_bytes @2 + png_sig_cmp @3 + png_create_read_struct @4 + png_create_write_struct @5 + png_get_compression_buffer_size @6 + png_set_compression_buffer_size @7 + png_set_longjmp_fn @8 + png_longjmp @9 + png_reset_zstream @10 + png_create_read_struct_2 @11 + png_create_write_struct_2 @12 + png_write_sig @13 + png_write_chunk @14 + png_write_chunk_start @15 + png_write_chunk_data @16 + png_write_chunk_end @17 + png_create_info_struct @18 + png_info_init_3 @19 + png_write_info_before_PLTE @20 + png_write_info @21 + png_read_info @22 + png_convert_to_rfc1123 @23 + png_convert_from_struct_tm @24 + png_convert_from_time_t @25 + png_set_expand @26 + png_set_expand_gray_1_2_4_to_8 @27 + png_set_palette_to_rgb @28 + png_set_tRNS_to_alpha @29 + png_set_bgr @30 + png_set_gray_to_rgb @31 + png_set_rgb_to_gray @32 + png_set_rgb_to_gray_fixed @33 + png_get_rgb_to_gray_status @34 + png_build_grayscale_palette @35 + png_set_strip_alpha @36 + png_set_swap_alpha @37 + png_set_invert_alpha @38 + png_set_filler @39 + png_set_add_alpha @40 + png_set_swap @41 + png_set_packing @42 + png_set_packswap @43 + png_set_shift @44 + png_set_interlace_handling @45 + png_set_invert_mono @46 + png_set_background @47 + png_set_strip_16 @48 + png_set_quantize @49 + png_set_gamma @50 + png_set_flush @51 + png_write_flush @52 + png_start_read_image @53 + png_read_update_info @54 + png_read_rows @55 + png_read_row @56 + png_read_image @57 + png_write_row @58 + png_write_rows @59 + png_write_image @60 + png_write_end @61 + png_read_end @62 + png_destroy_info_struct @63 + png_destroy_read_struct @64 + png_destroy_write_struct @65 + png_set_crc_action @66 + png_set_filter @67 + png_set_filter_heuristics @68 + png_set_compression_level @69 + png_set_compression_mem_level @70 + png_set_compression_strategy @71 + png_set_compression_window_bits @72 + png_set_compression_method @73 + png_init_io @74 + png_set_error_fn @75 + png_get_error_ptr @76 + png_set_write_fn @77 + png_set_read_fn @78 + png_get_io_ptr @79 + png_set_read_status_fn @80 + png_set_write_status_fn @81 + png_set_mem_fn @82 + png_get_mem_ptr @83 + png_set_read_user_transform_fn @84 + png_set_write_user_transform_fn @85 + png_set_user_transform_info @86 + png_get_user_transform_ptr @87 + png_set_read_user_chunk_fn @88 + png_get_user_chunk_ptr @89 + png_set_progressive_read_fn @90 + png_get_progressive_ptr @91 + png_process_data @92 + png_progressive_combine_row @93 + png_malloc @94 + png_calloc @95 + png_malloc_warn @96 + png_free @97 + png_free_data @98 + png_data_freer @99 + png_malloc_default @100 + png_free_default @101 + png_error @102 + png_chunk_error @103 + png_warning @105 + png_chunk_warning @106 + png_benign_error @107 + png_chunk_benign_error @108 + png_set_benign_errors @109 + png_get_valid @110 + png_get_rowbytes @111 + png_get_rows @112 + png_set_rows @113 + png_get_channels @114 + png_get_image_width @115 + png_get_image_height @116 + png_get_bit_depth @117 + png_get_color_type @118 + png_get_filter_type @119 + png_get_interlace_type @120 + png_get_compression_type @121 + png_get_pixels_per_meter @122 + png_get_x_pixels_per_meter @123 + png_get_y_pixels_per_meter @124 + png_get_pixel_aspect_ratio @125 + png_get_x_offset_pixels @126 + png_get_y_offset_pixels @127 + png_get_x_offset_microns @128 + png_get_y_offset_microns @129 + png_get_signature @130 + png_get_bKGD @131 + png_set_bKGD @132 + png_get_cHRM @133 + png_get_cHRM_fixed @134 + png_set_cHRM @135 + png_set_cHRM_fixed @136 + png_get_gAMA @137 + png_get_gAMA_fixed @138 + png_set_gAMA @139 + png_set_gAMA_fixed @140 + png_get_hIST @141 + png_set_hIST @142 + png_get_IHDR @143 + png_set_IHDR @144 + png_get_oFFs @145 + png_set_oFFs @146 + png_get_pCAL @147 + png_set_pCAL @148 + png_get_pHYs @149 + png_set_pHYs @150 + png_get_PLTE @151 + png_set_PLTE @152 + png_get_sBIT @153 + png_set_sBIT @154 + png_get_sRGB @155 + png_set_sRGB @156 + png_set_sRGB_gAMA_and_cHRM @157 + png_get_iCCP @158 + png_set_iCCP @159 + png_get_sPLT @160 + png_set_sPLT @161 + png_get_text @162 + png_set_text @163 + png_get_tIME @164 + png_set_tIME @165 + png_get_tRNS @166 + png_set_tRNS @167 + png_get_sCAL @168 + png_get_sCAL_s @169 + png_set_sCAL @170 + png_set_sCAL_s @171 + png_set_keep_unknown_chunks @172 + png_handle_as_unknown @173 + png_set_unknown_chunks @174 + png_set_unknown_chunk_location @175 + png_get_unknown_chunks @176 + png_set_invalid @177 + png_read_png @178 + png_write_png @179 + png_get_copyright @180 + png_get_header_ver @181 + png_get_header_version @182 + png_get_libpng_ver @183 + png_permit_mng_features @184 + png_set_strip_error_numbers @185 + png_set_user_limits @186 + png_get_user_width_max @187 + png_get_user_height_max @188 + png_set_chunk_cache_max @189 + png_get_chunk_cache_max @190 + png_set_chunk_malloc_max @191 + png_get_chunk_malloc_max @192 + png_get_pixels_per_inch @193 + png_get_x_pixels_per_inch @194 + png_get_y_pixels_per_inch @195 + png_get_x_offset_inches @196 + png_get_y_offset_inches @197 + png_get_pHYs_dpi @198 + png_get_io_state @199 + png_get_io_chunk_name @200 + png_get_uint_32 @201 + png_get_uint_16 @202 + png_get_int_32 @203 + png_get_uint_31 @204 + png_save_uint_32 @205 + png_save_int_32 @206 + png_save_uint_16 @207 + png_set_gamma_fixed @208 + png_set_filter_heuristics_fixed @209 + png_get_pixel_aspect_ratio_fixed @210 + png_get_x_offset_inches_fixed @211 + png_get_y_offset_inches_fixed @212 + png_set_sCAL_fixed @213 + png_get_sCAL_fixed @214 + png_set_background_fixed @215 + png_get_io_chunk_type @216 + png_get_current_row_number @217 + png_get_current_pass_number @218 + png_process_data_pause @219 + png_process_data_skip @220 diff --git a/programs/develop/libraries/newlib/Makefile b/programs/develop/libraries/newlib/Makefile index 7bcdfb1a2c..4b998c2f9b 100644 --- a/programs/develop/libraries/newlib/Makefile +++ b/programs/develop/libraries/newlib/Makefile @@ -327,7 +327,7 @@ LIB_OBJS+= \ -shared: $(NAME).dll libamz.a +shared: $(NAME).dll libamz.a libc.obj $(NAME).dll: $(LIB_OBJS) $(SRC_DEP) Makefile @@ -337,6 +337,9 @@ $(NAME).dll: $(LIB_OBJS) $(SRC_DEP) Makefile libamz.a: $(AMZ_OBJS) Makefile ar rc libamz.a $(AMZ_OBJS) +libc.obj: $(NAME).dll + fasm pe/libc.asm ./libc.obj + static: $(NAME).a diff --git a/programs/develop/libraries/newlib/pe/libc.asm b/programs/develop/libraries/newlib/pe/libc.asm new file mode 100644 index 0000000000..2203eec361 --- /dev/null +++ b/programs/develop/libraries/newlib/pe/libc.asm @@ -0,0 +1,284 @@ + +struc APP_HEADER_02 +{ .banner dq ? + .version dd ? ;+8 + .start dd ? ;+12 + .i_end dd ? ;+16 + .mem_size dd ? ;+20 + .stack_top dd ? ;+24 + .cmdline dd ? ;+28 + .path dd ? ;+32 +} + +virtual at 0 + app_hdr APP_HEADER_02 +end virtual + +format MS COFF + +public EXPORTS + +section '.flat' code readable align 16 + +EXPORTS: + dd szStart, START + dd szVersion, 0x00010001 + dd szExec, exec + dd 0 + +check dd 0 + +szStart db 'START',0 +szVersion db 'version',0 +szExec db 'exec',0 + +START: + xor eax, eax + cmp [app_hdr.path], 0 + je .ret + not eax +.ret: + mov [check], eax + ret 4 + +align 4 +exec: + cmp [check], 0 + lea ebp, [esp+4] + je .fail + + mov eax, [ebp+8] + test eax, eax + jz .fail + + mov ecx, [ebp] + mov edx, [ebp+4] + call validate_pe + test eax, eax + jz .fail + + mov eax, 68 + mov ebx, [ebp] + mov ecx, [ebx+60] + mov ecx, [ecx+96+ebx] ; app stack size + add ecx, 4095 + and ecx, -4096 + mov ebx, 12 + + int 0x40 + test eax, eax + jz .fail + + add ecx, eax + mov [fs:4], eax ;stack base + mov [fs:8], ecx ;stack top + + mov esp, ecx + + sub esp, 1024 + mov eax, 9 + mov ebx, esp + mov ecx, -1 + int 0x40 + mov eax, [ebx+30] + mov [fs:0], eax ; save pid + add esp, 1024 + + mov ecx, my_libc + call create_image + test eax, eax + jz .fail + + mov ebx, [eax+60] + mov ebx, [ebx+40+eax] + add ebx, eax + push ebp + push EXPORTS + push eax + call ebx + + ret + +.fail: + ret 4 + +align 4 + +validate_pe: + test ecx, ecx + je .L2 + cmp edx, 63 + jbe .L2 + cmp [ecx], word 23117 + je .L10 +.L2: + xor eax, eax + ret + +align 4 +.L10: + mov eax, [ecx+60] + test eax, eax + je .L2 + add ecx, eax + jb .L2 + cmp [ecx], dword 17744 + jne .L2 + cmp [ecx+4], word 332 + jne .L2 + test [ecx+23], byte 32 + jne .L2 + cmp [ecx+24], word 267 + jne .L2 + mov eax, [ecx+56] + cmp eax, 4095 + ja .L3 + cmp eax, [ecx+60] + jne .L2 + test eax, eax + je .L2 +.L5: + lea edx, [eax-1] + test edx, eax + jne .L2 + mov eax, [ecx+60] + test eax, eax + je .L2 + lea edx, [eax-1] + test edx, eax + jne .L2 + xor eax, eax + cmp [ecx+6], word 96 + setbe al + ret +.L3: + cmp eax, [ecx+60] + jae .L5 + jmp .L2 + +align 4 +create_image: + push ebp + push edi + push esi + push ebx + sub esp, 20 + mov [esp+16], ecx + mov eax, [ecx+60] + add eax, ecx + mov [esp], eax + mov ecx, [eax+80] + mov ebx, 12 + mov eax, 68 + int 0x40 + test eax, eax + je .L16 + + mov edx, [esp] + mov ecx, [edx+84] + mov esi, [esp+16] + mov edi, eax + shr ecx, 2 + rep movsd + mov cx, [edx+6] + test cx, cx + je .L17 + add edx, 248 + movzx ecx, cx + lea ebp, [ecx-1] + xor bl, bl + jmp .L19 + +align 4 +.L31: + add edx, 40 + inc ebx +.L19: + mov ecx, [edx+16] + test ecx, ecx + je .L18 + mov esi, [edx+20] + test esi, esi + je .L18 + add esi, [esp+16] + mov edi, [edx+12] + add edi, eax + + shr ecx, 2 + rep movsd + +.L18: + cmp ebx, ebp + jne .L31 +.L17: + mov edx, [esp] + mov ecx, [edx+164] + test ecx, ecx + je .L16 + + mov ebp, eax + sub ebp, [edx+52] + mov ebx, [edx+160] + add ebx, eax + mov esi, [ebx+4] + test esi, esi + je .L16 + + mov edi, ebp + shr edi, 16 + mov [esp], di + +align 4 +.L26: + lea edi, [esi-8] + shr edi, 1 + je .L20 + xor ecx, ecx + jmp .L25 + +align 4 +.L32: + cmp si, 3 + je .L24 + dec si + jne .L21 + mov esi, [esp] + add [eax+edx], si +.L21: + inc ecx + cmp ecx, edi + je .L20 +.L25: + mov si, [ebx+8+ecx*2] + mov edx, esi + and edx, 4095 + add edx, [ebx] + shr si, 12 + cmp si, 2 + jne .L32 + add [eax+edx], bp + inc ecx + cmp ecx, edi + jne .L25 +.L20: + add ebx, [ebx+4] + mov esi, [ebx+4] + test esi, esi + jne .L26 +.L16: + add esp, 20 + pop ebx + pop esi + pop edi + pop ebp + ret + +align 4 +.L24: + add [eax+edx], ebp + jmp .L21 + + +align 16 +my_libc: + file '../libc.dll' diff --git a/programs/develop/libraries/newlib/pe/loader.c b/programs/develop/libraries/newlib/pe/loader.c index 864464054e..cd30cd4484 100644 --- a/programs/develop/libraries/newlib/pe/loader.c +++ b/programs/develop/libraries/newlib/pe/loader.c @@ -523,7 +523,7 @@ int __fastcall link_image(void *img_base) } else if (minn == maxn) { - printf(" unresolved\n",imp_name->Name); + printf(" unresolved %s\n",imp_name->Name); warn=1; break; } diff --git a/programs/develop/libraries/newlib/tests/pe_demo.asm b/programs/develop/libraries/newlib/tests/pe_demo.asm new file mode 100644 index 0000000000..e5e42cd4ac --- /dev/null +++ b/programs/develop/libraries/newlib/tests/pe_demo.asm @@ -0,0 +1,133 @@ + +use32 + +LIBC_VERSION = 1 +DLL_ENTRY = 1 + +db 'MENUET02' +dd 1 +dd start +dd i_end +dd mem +dd mem +dd cmdline +dd path +dd 0 + +align 4 +start: + mov eax, LIBC_VERSION + mov ecx, sz_libc + mov edx, libc + call load_library + test eax, eax + jz .fail + + push dword 0 ; no environment + push cmdline + push path + push (my_app_end - my_app) + push my_app + call [libc.imp_exec] + + ret +.fail: + or eax, -1 + int 0x40 + +align 4 +load_library: ;eax=VERSION ecx=library path edx=import section + + sub esp, 16 + mov [esp+8], edx + mov [esp+12], eax + + mov eax, 68 + mov ebx, 19 + int 0x40 + test eax, eax + jz .fail + + mov [esp+4], eax + mov esi, edx ;import section + mov edx, eax ;export section +.import_loop: + lodsd + test eax, eax + jz .import_done +.import_find: + mov ebx, [edx] + test ebx, ebx + jz .fail ;import_not_found + + mov [esp], eax ;import name +@@: + mov cl, [eax] + cmp cl, [ebx] + jnz .import_find_next + + test cl, cl + jz .import_found + + inc eax + inc ebx + jmp @b + +.import_find_next: + mov eax, [esp] + add edx, 8 + jmp .import_find + +.import_found: + mov eax, [edx+4] + mov [esi-4], eax + mov edx, [esp+4] + jmp .import_loop +.import_done: + + mov edx, [esp+8] + mov eax, [esp+12] + + cmp word [edx+4], ax + jb .fail + cmp word [edx+6], ax + ja .fail + + push DLL_ENTRY + call dword [edx] +.fail: + add esp, 16 + ret + + +sz_libc db '/sys/lib/libc.obj',0 + +szStart db 'START',0 +szVersion db 'version',0 +szExec db 'exec',0 + +libc: + +.imp_start dd szStart +.imp_ver dd szVersion +.imp_exec dd szExec + dd 0 + +; keep this aligned +align 16 +my_app: + file 'myapp.exe' +my_app_end: + + +; keep this aligned +align 4 +i_end: + +path rb 1024 +cmdline rb 256 + rb 128 ;required stack +; keep this aligned +align 4096 +mem: + diff --git a/programs/develop/libraries/pixman/Makefile b/programs/develop/libraries/pixman/Makefile index c940e775c6..36501a32f0 100644 --- a/programs/develop/libraries/pixman/Makefile +++ b/programs/develop/libraries/pixman/Makefile @@ -6,9 +6,9 @@ CC = gcc CFLAGS = -c -O2 -mmmx -Winline -fomit-frame-pointer LDIMPORT:= -nostdlib --out-implib libpiximp.a --exclude-libs libamz.a -LDFLAGS:= -shared -s -T ../newlib/dll.lds -Map map --image-base 0 +LDFLAGS:= -shared -s -T ../newlib/dll.lds --image-base 0 -DEFINES = -DHAVE_CONFIG_H -DPIXMAN_NO_TLS -D__DYNAMIC_REENT__ -DUSE_MMX +DEFINES = -DHAVE_CONFIG_H -DPIXMAN_NO_TLS -DUSE_MMX INCLUDES = -I../pixman -I../newlib/include @@ -61,5 +61,6 @@ $(LIBRARY).dll: $(OBJECTS) Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< - +clean: + -rm -f *.o \ No newline at end of file diff --git a/programs/develop/libraries/zlib/Makefile b/programs/develop/libraries/zlib/Makefile index a23752bf53..9a829a6a54 100644 --- a/programs/develop/libraries/zlib/Makefile +++ b/programs/develop/libraries/zlib/Makefile @@ -7,9 +7,9 @@ CPP=gcc -E CFLAGS= -O3 -c -fomit-frame-pointer -LDIMPORT:= -nostdlib +LDIMPORT:= -nostdlib --out-implib libzimp.a -LDFLAGS:= -shared -s -T ../newlib/dll.lds -Map map --image-base 0 +LDFLAGS:= -shared -s -T ../newlib/dll.lds --image-base 0 INCLUDES= -I../newlib/include @@ -30,14 +30,14 @@ OBJA = OBJS = $(OBJC) $(OBJA) -all: libz.a libz.dll +all: libz.a zlib.dll libz.a: $(OBJS) $(AR) $@ $(OBJS) -libz.dll: $(OBJECTS) Makefile - dlltool -d zlib.def -Dlibz.dll -e exports.o -l libzimp.a - ld $(LDFLAGS) $(LDIMPORT) --exclude-all-symbols $(LIBPATH) -o $@ $(OBJS) exports.o $(LIBS) +zlib.dll: $(OBJECTS) Makefile +# dlltool -d zlib.def -Dlibz.dll -e exports.o -l libzimp.a + ld $(LDFLAGS) $(LDIMPORT) $(LIBPATH) -o $@ $(OBJS) $(LIBS) zlib.def %.o: %.c Makefile