Compare commits

..

320 Commits

Author SHA1 Message Date
Markus F.X.J. Oberhumer ce6d99bdb4 More README updates.
committer: mfx <mfx> 1146086335 +0000
2006-04-26 21:18:55 +00:00
Markus F.X.J. Oberhumer 86d4125893 Updates.
committer: mfx <mfx> 1146086189 +0000
2006-04-26 21:16:29 +00:00
Markus F.X.J. Oberhumer 3a18f00379 Prepared 2.00 release notes.
committer: mfx <mfx> 1146085621 +0000
2006-04-26 21:07:01 +00:00
Markus F.X.J. Oberhumer e6274904a7 Rebuilt using i386-linux-ld-2.16.1 and i386-linux-objcopy-2.16.1.
committer: mfx <mfx> 1146079399 +0000
2006-04-26 19:23:19 +00:00
Markus F.X.J. Oberhumer 3677395444 Add version suffix to the binutils we use. Prefix all linux/386 tools
with i386-linux-.

committer: mfx <mfx> 1146079325 +0000
2006-04-26 19:22:05 +00:00
László Molnár 22ba35b3b5 new arm/pe assembly with UPX linker support
committer: ml1050 <ml1050> 1145955479 +0000
2006-04-25 08:57:59 +00:00
Markus F.X.J. Oberhumer 9c1ab9979b Split "$Id" strings so that CVS does not interfere. Explicitlty
use ".p2align" and ".balign" instead of ".align".

committer: mfx <mfx> 1145864788 +0000
2006-04-24 07:46:28 +00:00
John Reiser eaa463e1c9 Insert copyright notice (equivalent to ident_s.ash) into stub by hand
because buildLoader is not fully working yet
	l_lx_elf64amd.S l_lx_elfppc32.S l_mac_ppc32.S

committer: jreiser <jreiser> 1145825498 +0000
2006-04-23 20:51:38 +00:00
John Reiser 6984be48c3 build sync: compile using crosstool gcc-3.4.3.20050507-glibc-2.3.5
committer: jreiser <jreiser> 1145820281 +0000
2006-04-23 19:24:41 +00:00
John Reiser b739bd3d79 Work better with SELinux. We still require allow_execmem.
p_lx_elf.cpp
	stub/fold_elfppc32.h
	stub/l_lx_elfppc32.h
	stub/l_lx_elfppc32.S
	stub/m_lx_elfppc32.c

committer: jreiser <jreiser> 1145666524 +0000
2006-04-22 00:42:04 +00:00
John Reiser 23f3e4396c For elf64and and elfppc32: -fno-exceptions -fno-asynchronous-unwind-tables
committer: jreiser <jreiser> 1145666377 +0000
2006-04-22 00:39:37 +00:00
John Reiser c264750924 Adapt better to SELinux. We still need allow_execmem.
p_lx_elf.cpp
	stub/a_lx_elf64.c
	stub/l_lx_elf64amd.h
	stub/l_lx_elf64amd.lds
	stub/l_lx_elf64amd.S
	stub/fold_elf64amd.h

committer: jreiser <jreiser> 1145657332 +0000
2006-04-21 22:08:52 +00:00
John Reiser c155f0a5d5 Better fit with SELinux. Now requires only execmem, which Fedora Core 5
enables as default for non-confined [ordinary] executables.
	l_lx_elf.c
	l_lx_elf86.asm
	l_lx_elf86.h
	l_lx_elf86.lds
	fold_elf86.asm
	fold_elf86.h

committer: jreiser <jreiser> 1145634453 +0000
2006-04-21 15:47:33 +00:00
László Molnár 76734f086d added an arm/linux based loader/tester for arm/pe files
committer: ml1050 <ml1050> 1145605029 +0000
2006-04-21 07:37:09 +00:00
Markus F.X.J. Oberhumer 4f2d1172dd Added a note about --force-execve. Converted quoting from using
backticks to single-quotes.

committer: mfx <mfx> 1145444708 +0000
2006-04-19 11:05:08 +00:00
Markus F.X.J. Oberhumer 75caf4e297 Fix spelling in NEWS.
committer: mfx <mfx> 1145436378 +0000
2006-04-19 08:46:18 +00:00
Markus F.X.J. Oberhumer 509ab8261f Avoid code bloat in the official builds.
committer: mfx <mfx> 1145436321 +0000
2006-04-19 08:45:21 +00:00
Markus F.X.J. Oberhumer 1e05b40d4f Whitespace changes.
committer: mfx <mfx> 1145436164 +0000
2006-04-19 08:42:44 +00:00
Markus F.X.J. Oberhumer 451390f835 Updated NEWS.
committer: mfx <mfx> 1145435924 +0000
2006-04-19 08:38:44 +00:00
John Reiser 58cce9d2f8 Give message on stderr when SELinux enforcing mode inhibits execution.
l_lx_elf.c fold_elf86.asm fold_elf86.h

committer: jreiser <jreiser> 1145393418 +0000
2006-04-18 20:50:18 +00:00
László Molnár 2eb6e3b0ea arm/pe & w32/pe: disable filters for files with broken headers
committer: ml1050 <ml1050> 1145356307 +0000
2006-04-18 10:31:47 +00:00
John Reiser fb1181ed26 Allow executables >=3MB on elf64amd; -r1.69 on 2005-11-12 forgot to remove check.
committer: jreiser <jreiser> 1145139994 +0000
2006-04-15 22:26:34 +00:00
Markus F.X.J. Oberhumer 6d5e1d529d Updated NEWS.
committer: mfx <mfx> 1144968512 +0000
2006-04-13 22:48:32 +00:00
John Reiser 0e0ca08924 Propagate changes from linux.hh.
fold_elf86.h fold_pti86.h fold_sh86.h

committer: jreiser <jreiser> 1144967510 +0000
2006-04-13 22:31:50 +00:00
John Reiser 5d948a67a8 Propagate changes from linux.hh.
Also adjust calling segquence of upx_main() to shave a few bytes.
	l_lx_exec.c fold_exec86.asm fold_exec86.h

committer: jreiser <jreiser> 1144967447 +0000
2006-04-13 22:30:47 +00:00
John Reiser 6a4db2ecab Linux syscalls can clobber any input register, thanks to gcc and
the lack of a Linux kernel ABI.
	linux.hh

committer: jreiser <jreiser> 1144967342 +0000
2006-04-13 22:29:02 +00:00
Markus F.X.J. Oberhumer f700273624 Really bump the release date.
committer: mfx <mfx> 1144944628 +0000
2006-04-13 16:10:28 +00:00
Markus F.X.J. Oberhumer 0c198e0ccc Set tentative release date.
committer: mfx <mfx> 1144944070 +0000
2006-04-13 16:01:10 +00:00
Markus F.X.J. Oberhumer 71ffbbc420 Prepared 1.96 release.
committer: mfx <mfx> 1144943500 +0000
2006-04-13 15:51:40 +00:00
Markus F.X.J. Oberhumer 4fd09b889d Updated .cvsignore.
committer: mfx <mfx> 1144943334 +0000
2006-04-13 15:48:54 +00:00
László Molnár 4cb2a3eebe show image size change in info mode
committer: ml1050 <ml1050> 1144941392 +0000
2006-04-13 15:16:32 +00:00
László Molnár c25186b1f6 minor documentation updates
committer: ml1050 <ml1050> 1144941274 +0000
2006-04-13 15:14:34 +00:00
László Molnár 779033d0bc added filter (id: 0x50) support to the stub
the data cache is written back before the stub jumps to the uncompressed code

committer: ml1050 <ml1050> 1144931349 +0000
2006-04-13 12:29:09 +00:00
László Molnár 3e31560e7d added a new filter for ARM 24-bit naive calltrick
committer: ml1050 <ml1050> 1144931022 +0000
2006-04-13 12:23:42 +00:00
László Molnár d23d7e8775 removed unneeded entry point address check
committer: ml1050 <ml1050> 1144745835 +0000
2006-04-11 08:57:15 +00:00
László Molnár f6fdf5cb7f show image size change in info mode
committer: ml1050 <ml1050> 1144671675 +0000
2006-04-10 12:21:15 +00:00
Markus F.X.J. Oberhumer 1879ccd27d Next version will be 2.00.
committer: mfx <mfx> 1144586292 +0000
2006-04-09 12:38:12 +00:00
Markus F.X.J. Oberhumer 08c0796719 Avoid warnings when building for m68k.
committer: mfx <mfx> 1144523702 +0000
2006-04-08 19:15:02 +00:00
Markus F.X.J. Oberhumer edc7994ce5 Prepared 1.95 release.
committer: mfx <mfx> 1144522884 +0000
2006-04-08 19:01:24 +00:00
Markus F.X.J. Oberhumer bcfcfbd064 Added some more operators.
committer: mfx <mfx> 1144522838 +0000
2006-04-08 19:00:38 +00:00
Markus F.X.J. Oberhumer 9e79b3258d Make const-correct to avoid warning.
committer: mfx <mfx> 1144522792 +0000
2006-04-08 18:59:52 +00:00
John Reiser 243873cd2d Workaround inconsistent SIZEOF_HEADERS in stub/*.lds.
Test with --force-execve and --no-filter.
	p_lx_exc.cpp p_lx_sh.cpp stub/l_lx_sh86.asm stub/l_lx_sh86.h

committer: jreiser <jreiser> 1144381286 +0000
2006-04-07 03:41:26 +00:00
Markus F.X.J. Oberhumer c7b8a4b0c1 Updated.
committer: mfx <mfx> 1144320028 +0000
2006-04-06 10:40:28 +00:00
Markus F.X.J. Oberhumer e39e0c7140 Added .gitignore files.
committer: mfx <mfx> 1144319429 +0000
2006-04-06 10:30:29 +00:00
Markus F.X.J. Oberhumer d4a3f11dbb Whitespace changes.
committer: mfx <mfx> 1144318755 +0000
2006-04-06 10:19:15 +00:00
Markus F.X.J. Oberhumer 0962f266b3 Whitespace changes.
committer: mfx <mfx> 1144314053 +0000
2006-04-06 09:00:53 +00:00
Markus F.X.J. Oberhumer 69e4d3fdad Bumped tentative release date.
committer: mfx <mfx> 1144313563 +0000
2006-04-06 08:52:43 +00:00
Markus F.X.J. Oberhumer c0908f463a Added files to "clean" target.
committer: mfx <mfx> 1144313493 +0000
2006-04-06 08:51:33 +00:00
Markus F.X.J. Oberhumer b00a61a17b Updated.
committer: mfx <mfx> 1144313468 +0000
2006-04-06 08:51:08 +00:00
László Molnár 553c2f886a arm/pe: thumb mode dll support added
committer: ml1050 <ml1050> 1144312217 +0000
2006-04-06 08:30:17 +00:00
László Molnár 4fd9c5772a arm/pe:
v4 ARM mode stub support with assembly decompressor by John
dll support for v4 ARM mode
unpacking support

committer: ml1050 <ml1050> 1144249762 +0000
2006-04-05 15:09:22 +00:00
Markus F.X.J. Oberhumer 04e0e06d85 Whitespace changes.
committer: mfx <mfx> 1144235344 +0000
2006-04-05 11:09:04 +00:00
Markus F.X.J. Oberhumer 4d7829d72b New ACC version.
committer: mfx <mfx> 1144235271 +0000
2006-04-05 11:07:51 +00:00
John Reiser 6b751aac57 Fix return from THUMB to ARM mode on ARMv4T. Document r6 unused.
committer: jreiser <jreiser> 1143650112 +0000
2006-03-29 16:35:12 +00:00
László Molnár 813349fd23 arm/pe: support for nrv2b, support for cpu = 0x1c2, certificate info now removed
committer: ml1050 <ml1050> 1143614738 +0000
2006-03-29 06:45:38 +00:00
John Reiser 16a2744782 find_SEGMENT_gap() like find_LOAD_gap(). Use it to avoid checksum trouble.
p_mach.cpp p_mach.h

committer: jreiser <jreiser> 1143576015 +0000
2006-03-28 20:00:15 +00:00
John Reiser 7b6870db22 Fix bug: bad test for reaching back too far in SAFE mode. (Thank you, Laszlo.)
committer: jreiser <jreiser> 1143564998 +0000
2006-03-28 16:56:38 +00:00
Markus F.X.J. Oberhumer 3e38e7d52c Small cleanups.
committer: mfx <mfx> 1143474969 +0000
2006-03-27 15:56:09 +00:00
László Molnár 8142d3474d get_le32 reimplemented in assembly
committer: ml1050 <ml1050> 1143473260 +0000
2006-03-27 15:27:40 +00:00
Markus F.X.J. Oberhumer 8773649de6 Make code warning-free.
committer: mfx <mfx> 1143464312 +0000
2006-03-27 12:58:32 +00:00
Markus F.X.J. Oberhumer c117920ff9 Add -Wall -Werror to cross-compiler flags.
committer: mfx <mfx> 1143463128 +0000
2006-03-27 12:38:48 +00:00
László Molnár c8dd2a3eb8 arm/pe: use -march=armv4t instead of v5
committer: ml1050 <ml1050> 1143462067 +0000
2006-03-27 12:21:07 +00:00
Markus F.X.J. Oberhumer 90b1817e92 Undef PAGE_{MASK,SIZE} in conf.h.
committer: mfx <mfx> 1143454717 +0000
2006-03-27 10:18:37 +00:00
Markus F.X.J. Oberhumer d6c3ff5997 Cleanups.
committer: mfx <mfx> 1143454663 +0000
2006-03-27 10:17:43 +00:00
László Molnár 984ec25132 arm/pe: the assembly thumb mode decompressor is used in the stub
arm/pe: the C part of the stub is compiled as thumb

committer: ml1050 <ml1050> 1143449862 +0000
2006-03-27 08:57:42 +00:00
John Reiser a7bff34784 Fix THUMB mode return to ARM mode on ARMv4T. Spend 18 bytes to inline
most of get1b via conditional subroutine call idiom.

committer: jreiser <jreiser> 1143302120 +0000
2006-03-25 15:55:20 +00:00
John Reiser a6e7afbc91 Fix bug: first 'add' instead of 'adc' at get1_n2b. (Thank you, Laszlo.)
committer: jreiser <jreiser> 1143228535 +0000
2006-03-24 19:28:55 +00:00
John Reiser 33f1d63b64 Fix bug: first 'add' at get1_n2e instead of 'adc'.
Also conditionally assemble SAFE mode for buffer checking (default off).

committer: jreiser <jreiser> 1143228361 +0000
2006-03-24 19:26:01 +00:00
John Reiser f95e171e11 Workaround linux-2.6.14 binfmt_elf.c: SIGKILL if (0==.p_memsz) on a page boundary.
p_lx_elf.cpp p_lx_exc.cpp

committer: jreiser <jreiser> 1143057770 +0000
2006-03-22 20:02:50 +00:00
Markus F.X.J. Oberhumer c82b50b212 Bumped tentative release date.
committer: mfx <mfx> 1142610024 +0000
2006-03-17 15:40:24 +00:00
Markus F.X.J. Oberhumer 2b402b77f1 Updated short-list of supported executable formats.
committer: mfx <mfx> 1142609852 +0000
2006-03-17 15:37:32 +00:00
Markus F.X.J. Oberhumer adcb551020 Increase alignment to 16.
committer: mfx <mfx> 1142608657 +0000
2006-03-17 15:17:37 +00:00
Markus F.X.J. Oberhumer 2680aabe06 Removed bogus __attribute_packed from struct udll.
committer: mfx <mfx> 1142607440 +0000
2006-03-17 14:57:20 +00:00
Markus F.X.J. Oberhumer d5c0533b74 Allow the PE sections to cross a page boundary.
committer: mfx <mfx> 1142603590 +0000
2006-03-17 13:53:10 +00:00
Markus F.X.J. Oberhumer 609307668b Use $(MAKEFILE_LIST) for dependencies.
committer: mfx <mfx> 1142527291 +0000
2006-03-16 16:41:31 +00:00
Markus F.X.J. Oberhumer cdaf36572a Use UPX_VERSION_DATE_ISO from src/version.h.
committer: mfx <mfx> 1142527194 +0000
2006-03-16 16:39:54 +00:00
Markus F.X.J. Oberhumer 033c8d5d51 Updated.
committer: mfx <mfx> 1142523608 +0000
2006-03-16 15:40:08 +00:00
Markus F.X.J. Oberhumer 6216ec1d6a Mention John as a main author.
committer: mfx <mfx> 1142522272 +0000
2006-03-16 15:17:52 +00:00
László Molnár 6c9c67f6c5 DEP hack: it seems we need to patch the flags of section "UPX1" too
committer: ml1050 <ml1050> 1142508181 +0000
2006-03-16 11:23:01 +00:00
Markus F.X.J. Oberhumer 5bd32b5521 Commented out "int3" debugging leftovers.
committer: mfx <mfx> 1142312678 +0000
2006-03-14 05:04:38 +00:00
Markus F.X.J. Oberhumer 549336f75b Use boolean instead of bitwise logic.
committer: mfx <mfx> 1142311485 +0000
2006-03-14 04:44:45 +00:00
Markus F.X.J. Oberhumer f0e75f30b3 Fixed typo in comment.
committer: mfx <mfx> 1142310885 +0000
2006-03-14 04:34:45 +00:00
Markus F.X.J. Oberhumer 144c09f175 Rebuilt i386-linux stubs by gcc-3.4.6.
committer: mfx <mfx> 1142310823 +0000
2006-03-14 04:33:43 +00:00
Markus F.X.J. Oberhumer ee50c0f97c Corrected app_*.pl dependency.
committer: mfx <mfx> 1142309988 +0000
2006-03-14 04:19:48 +00:00
John Reiser ade921bf02 %.asy and %.asx depend onf $(APP_I386)
committer: jreiser <jreiser> 1142306625 +0000
2006-03-14 03:23:45 +00:00
John Reiser 676cacff04 gcc-4.1.0 vs. mmap()
linux.hh
	fold_elf86.asm  l_lx_elf.c
	fold_exec86.asm l_lx_exec.c
	fold_pti86.asm  l_lx_pti.c
	fold_sh86.asm   l_lx_sh.c    l_lx_sh86.asm
	l_lx_sep.c

committer: jreiser <jreiser> 1142305438 +0000
2006-03-14 03:03:58 +00:00
Markus F.X.J. Oberhumer a3097d5e25 Added a dependency.
committer: mfx <mfx> 1142303569 +0000
2006-03-14 02:32:49 +00:00
Markus F.X.J. Oberhumer fd78148558 Fixed typo in disabled code.
committer: mfx <mfx> 1142302679 +0000
2006-03-14 02:17:59 +00:00
Markus F.X.J. Oberhumer a4d79d7375 Small cosmetic changes.
committer: mfx <mfx> 1142302586 +0000
2006-03-14 02:16:26 +00:00
Markus F.X.J. Oberhumer df04e8183d Filter parameters should be called "ft" instead of "fp".
committer: mfx <mfx> 1142301730 +0000
2006-03-14 02:02:10 +00:00
Markus F.X.J. Oberhumer c43c484a62 Re-synced both files a little bit.
committer: mfx <mfx> 1142301586 +0000
2006-03-14 01:59:46 +00:00
Markus F.X.J. Oberhumer 0608c35669 Added some more OBJSTRIP. Small cleanups.
committer: mfx <mfx> 1142298790 +0000
2006-03-14 01:13:10 +00:00
Markus F.X.J. Oberhumer 7dd4d06e26 Added some more calls to $(OBJSTRIP_LINUX_I386) after $(NASM) invocations.
committer: mfx <mfx> 1142288478 +0000
2006-03-13 22:21:18 +00:00
John Reiser 1ee0310b86 silence complaint from ld "cannot find entry symbol _start; defaulting to 10000000"
committer: jreiser <jreiser> 1142285749 +0000
2006-03-13 21:35:49 +00:00
Markus F.X.J. Oberhumer cc0a52038f Rebuilt i386-linux stubs with gcc-4.1.0 for small size decrease.
committer: mfx <mfx> 1142248018 +0000
2006-03-13 11:06:58 +00:00
Markus F.X.J. Oberhumer 6aed1fe231 Updated.
committer: mfx <mfx> 1142247976 +0000
2006-03-13 11:06:16 +00:00
Markus F.X.J. Oberhumer 680608fe18 Portability fix.
committer: mfx <mfx> 1142247872 +0000
2006-03-13 11:04:32 +00:00
Markus F.X.J. Oberhumer ec6acbc602 Small fix to make valid ANSI C again.
committer: mfx <mfx> 1142247837 +0000
2006-03-13 11:03:57 +00:00
John Reiser cb7ee4c5d2 _syscall1nr() for _exit; [still wastes 4 bytes]
committer: jreiser <jreiser> 1142210712 +0000
2006-03-13 00:45:12 +00:00
Markus F.X.J. Oberhumer 88d5798f45 Bumped versions for starting 1.95 development.
committer: mfx <mfx> 1142090576 +0000
2006-03-11 15:22:56 +00:00
Markus F.X.J. Oberhumer fcc22a0aa3 Added UPX_VERSION_DATE_ISO.
committer: mfx <mfx> 1142085195 +0000
2006-03-11 13:53:15 +00:00
Markus F.X.J. Oberhumer aabefff298 Prepared for release 1.94.
committer: mfx <mfx> 1142081862 +0000
2006-03-11 12:57:42 +00:00
Markus F.X.J. Oberhumer ed25c64e97 Updated.
committer: mfx <mfx> 1142081797 +0000
2006-03-11 12:56:37 +00:00
Markus F.X.J. Oberhumer b7dc870c2d Centered strings.
committer: mfx <mfx> 1142081776 +0000
2006-03-11 12:56:16 +00:00
Markus F.X.J. Oberhumer 9bea608843 Don't suppress errors with -qq.
committer: mfx <mfx> 1142081041 +0000
2006-03-11 12:44:01 +00:00
Markus F.X.J. Oberhumer 9db1732c36 Added a note that we should upgrade to gcc-4.1.0 on i386-linux.
committer: mfx <mfx> 1142074774 +0000
2006-03-11 10:59:34 +00:00
Markus F.X.J. Oberhumer 39f1a70174 Small update.
committer: mfx <mfx> 1142036155 +0000
2006-03-11 00:15:55 +00:00
Markus F.X.J. Oberhumer 1810440355 Added __attribute__((__sentinel__)) to Packer::addLoader(). This is
a new gcc-4.1 feature.

committer: mfx <mfx> 1142035833 +0000
2006-03-11 00:10:33 +00:00
Markus F.X.J. Oberhumer 37ac8f179e New ACC version.
committer: mfx <mfx> 1142035385 +0000
2006-03-11 00:03:05 +00:00
Markus F.X.J. Oberhumer 626a09328f Updated.
committer: mfx <mfx> 1141807336 +0000
2006-03-08 08:42:16 +00:00
Markus F.X.J. Oberhumer 8d489d0d77 New ACC version.
committer: mfx <mfx> 1141798968 +0000
2006-03-08 06:22:48 +00:00
Markus F.X.J. Oberhumer 776f3db0d7 Detabified.
committer: mfx <mfx> 1141795978 +0000
2006-03-08 05:32:58 +00:00
John Reiser 6046057b88 Commentary on SELinux and UPX.
committer: jreiser <jreiser> 1141686040 +0000
2006-03-06 23:00:40 +00:00
Markus F.X.J. Oberhumer 7e85d9e549 Updated.
committer: mfx <mfx> 1141679044 +0000
2006-03-06 21:04:04 +00:00
Markus F.X.J. Oberhumer 01c8a8b1c2 Disabled an expensive run-time assertion.
committer: mfx <mfx> 1141642878 +0000
2006-03-06 11:01:18 +00:00
Markus F.X.J. Oberhumer c9bf6ac9ae No need to preserve eax in clearstack.
committer: mfx <mfx> 1141642647 +0000
2006-03-06 10:57:27 +00:00
John Reiser 62e4d69be9 re-compile from changed m_lx_elfppc32.c
committer: jreiser <jreiser> 1141605710 +0000
2006-03-06 00:41:50 +00:00
John Reiser 62ac733b09 simplify and save a few bytes
committer: jreiser <jreiser> 1141488398 +0000
2006-03-04 16:06:38 +00:00
John Reiser c3b3e1b1b9 MAP_DENYWRITE
committer: jreiser <jreiser> 1141484579 +0000
2006-03-04 15:02:59 +00:00
John Reiser a791e96e00 Fix do_xmap() to work under SElinux. Also trim unneeded code.
committer: jreiser <jreiser> 1141413353 +0000
2006-03-03 19:15:53 +00:00
John Reiser e87f5521c1 conditionally compile debugging printf
committer: jreiser <jreiser> 1141365595 +0000
2006-03-03 05:59:55 +00:00
John Reiser 366a708f3a Generalize to more than 2 PT_LOAD using find_LOAD_gap; needed for linux/ElfAMD.
Also simplifies, and applies to both ::pack and ::unpack.
	p_lx_elf.cpp p_lx_elf.h

committer: jreiser <jreiser> 1141348876 +0000
2006-03-03 01:21:16 +00:00
John Reiser 70ba662574 Avoid overwrite of obuf when hdr_buf and non-first method.
committer: jreiser <jreiser> 1141327368 +0000
2006-03-02 19:22:48 +00:00
John Reiser b389abd99f PackLinuxElf64amd::getCompressionMethods allows both nrv2b and nrv2e
committer: jreiser <jreiser> 1141326792 +0000
2006-03-02 19:13:12 +00:00
John Reiser 4aa2d14fe3 acknowledge unused results to avoid compiler warnings treated as errors
committer: jreiser <jreiser> 1141326721 +0000
2006-03-02 19:12:01 +00:00
John Reiser af7de75ad4 Allow unfilter when verifyOverlappingDecompression, for convenience
in end-to-end checksum.
	packer.h packer.cpp p_unix.cpp

committer: jreiser <jreiser> 1141252960 +0000
2006-03-01 22:42:40 +00:00
John Reiser d461ebbda1 fix packExtent checksums and lengths (of uncompressed data) for 0!=hdr_ulen
committer: jreiser <jreiser> 1141241763 +0000
2006-03-01 19:36:03 +00:00
John Reiser 55ef94abcd 8-bit decompressors for ARM; minimize space aggressively
arm_nrv2b_d8.S arm_nrv2e_d8.S

committer: jreiser <jreiser> 1140993873 +0000
2006-02-26 22:44:33 +00:00
John Reiser afaf489d99 save space aggressively
committer: jreiser <jreiser> 1140713717 +0000
2006-02-23 16:55:17 +00:00
John Reiser 20e4cbfd13 passes first tests! Only untested feature: large offset which forces
minimum match length to be >=3.
	arm_nrv2b_d32.S arm_nrv2e_d32.S

committer: jreiser <jreiser> 1140677145 +0000
2006-02-23 06:45:45 +00:00
John Reiser f3b8c9f34e debugging
committer: jreiser <jreiser> 1140634679 +0000
2006-02-22 18:57:59 +00:00
John Reiser 45e8ff25a5 hand-tuned decompressors for 32-bit NRV on ARM
arm_nrv2b_d32.S arm_nrv2e_d32.S

committer: jreiser <jreiser> 1140535945 +0000
2006-02-21 15:32:25 +00:00
John Reiser 268e322e1c Extra parameter for compressWithFilters and packExtent,
to fix 2-pass problem with --brute on linux/elf386.
Only one decompression method is allowed, chosen by
smallest output for .text; but Elf headers come first.
	packer.cpp packer.h p_unix.cpp p_unix.h p_lx_elf.cpp

committer: jreiser <jreiser> 1140241030 +0000
2006-02-18 05:37:10 +00:00
Markus F.X.J. Oberhumer d3bcba6a05 Removed "volatile" from global var "opt" - this was only needed
a long time ago to work around problems with ancient C++ compilers.

committer: mfx <mfx> 1140002094 +0000
2006-02-15 11:14:54 +00:00
Markus F.X.J. Oberhumer cc4ef1944d Make sure we only touch exactly one page. Update comments.
committer: mfx <mfx> 1139928961 +0000
2006-02-14 14:56:01 +00:00
Markus F.X.J. Oberhumer 5aa8486265 Prefer restoring the original protection flags.
committer: mfx <mfx> 1139928517 +0000
2006-02-14 14:48:37 +00:00
László Molnár fd181673cd a little more comments on the DEP hack stuff
committer: ml1050 <ml1050> 1139927444 +0000
2006-02-14 14:30:44 +00:00
László Molnár 62c9547c4e added some comments on the DEP hack stuff
committer: ml1050 <ml1050> 1139918135 +0000
2006-02-14 11:55:35 +00:00
Markus F.X.J. Oberhumer cdd117bfb9 Rearranged debug options.
committer: mfx <mfx> 1139916141 +0000
2006-02-14 11:22:21 +00:00
Markus F.X.J. Oberhumer 304ba57dad Clear the dirty stack on win32/pe.
committer: mfx <mfx> 1139914965 +0000
2006-02-14 11:02:45 +00:00
Markus F.X.J. Oberhumer 69eaaa4177 Revert previous checkin.
committer: mfx <mfx> 1139914479 +0000
2006-02-14 10:54:39 +00:00
Markus F.X.J. Oberhumer 452ac52fcb Added an overloaded addLoader() method.
committer: mfx <mfx> 1139913550 +0000
2006-02-14 10:39:10 +00:00
Markus F.X.J. Oberhumer 40cf489290 Avoid possibly clobbering edx.
committer: mfx <mfx> 1139881592 +0000
2006-02-14 01:46:32 +00:00
Markus F.X.J. Oberhumer 891d6be4a6 Removed options_t::win32_pe::strip_loadconf.
For compatibility reasons the option is still accepted (but
ignored) during commandline parsing.

committer: mfx <mfx> 1139866279 +0000
2006-02-13 21:31:19 +00:00
Markus F.X.J. Oberhumer 5d45ce5cf7 Removed an already fixed item.
committer: mfx <mfx> 1139864523 +0000
2006-02-13 21:02:03 +00:00
Markus F.X.J. Oberhumer a0f2241f3a Added comment.
committer: mfx <mfx> 1139862668 +0000
2006-02-13 20:31:08 +00:00
Markus F.X.J. Oberhumer aa513bf7d3 Quick fix for the Win32 startup crash. Needs more testing.
committer: mfx <mfx> 1139861398 +0000
2006-02-13 20:09:58 +00:00
Markus F.X.J. Oberhumer b2d65febc8 Small update.
committer: mfx <mfx> 1139843847 +0000
2006-02-13 15:17:27 +00:00
Markus F.X.J. Oberhumer 23a6d326e8 Bump tentative release date. Update READMEs.
committer: mfx <mfx> 1139840129 +0000
2006-02-13 14:15:29 +00:00
Markus F.X.J. Oberhumer 5b2f1b6d8b Introduced UPX_VERSION_YEAR.
committer: mfx <mfx> 1139826163 +0000
2006-02-13 10:22:43 +00:00
Markus F.X.J. Oberhumer b4e9ad031b Break strings so that CVS does not try to expand keywords.
committer: mfx <mfx> 1139786765 +0000
2006-02-12 23:26:05 +00:00
Markus F.X.J. Oberhumer 8b7ebcf040 Enter 2006.
committer: mfx <mfx> 1139778883 +0000
2006-02-12 21:14:43 +00:00
Markus F.X.J. Oberhumer af05296631 Made ps1/exe work again.
committer: mfx <mfx> 1139776798 +0000
2006-02-12 20:39:58 +00:00
Markus F.X.J. Oberhumer 29d693de2d New ACC version.
committer: mfx <mfx> 1139772863 +0000
2006-02-12 19:34:23 +00:00
Markus F.X.J. Oberhumer 51ac5172f5 #undef PAGE_{MASK,SIZE} to fix build problems on some machines.
committer: mfx <mfx> 1139743226 +0000
2006-02-12 11:20:26 +00:00
Markus F.X.J. Oberhumer 24ce1ef5e7 Enter 2006.
committer: mfx <mfx> 1139742400 +0000
2006-02-12 11:06:40 +00:00
Markus F.X.J. Oberhumer f6d1e269d1 Prepare for new release.
committer: mfx <mfx> 1139742224 +0000
2006-02-12 11:03:44 +00:00
Markus F.X.J. Oberhumer 62c2f5228d Rebuilt stubs.
committer: mfx <mfx> 1139742130 +0000
2006-02-12 11:02:10 +00:00
Markus F.X.J. Oberhumer 9882d9683b Updated.
committer: mfx <mfx> 1139741935 +0000
2006-02-12 10:58:55 +00:00
Markus F.X.J. Oberhumer 45ce89ee1f Removed trailing whitespace.
committer: mfx <mfx> 1139741919 +0000
2006-02-12 10:58:39 +00:00
László Molnár bfb9df1553 win32/pe: R6002 runtime errors worked around
committer: ml1050 <ml1050> 1139505685 +0000
2006-02-09 17:21:25 +00:00
László Molnár a5f79204ce set use_dep_hack to true
committer: ml1050 <ml1050> 1139404812 +0000
2006-02-08 13:20:12 +00:00
László Molnár e322613d84 workaround added for a msvc runtime "protection"
committer: ml1050 <ml1050> 1139393823 +0000
2006-02-08 10:17:03 +00:00
Markus F.X.J. Oberhumer fbb60f5191 Refactored a new mem_replace() function.
committer: mfx <mfx> 1138984802 +0000
2006-02-03 16:40:02 +00:00
Markus F.X.J. Oberhumer 899e7d2f39 Added internal debugging options '--fake-stub-version=X.XX' and
'--fake-stub-year=XXXX'.

These might prove useful for building up a test suite which is able to
check binary identity of compressed executables between UPX releases
where the implementation of a specific format has not changed.

committer: mfx <mfx> 1138960010 +0000
2006-02-03 09:46:50 +00:00
László Molnár 8e2aa07747 load config support for win32/pe dlls
committer: ml1050 <ml1050> 1138878465 +0000
2006-02-02 11:07:45 +00:00
Markus F.X.J. Oberhumer a0d262cd76 New ACC version.
committer: mfx <mfx> 1138683583 +0000
2006-01-31 04:59:43 +00:00
Markus F.X.J. Oberhumer b43a7edee4 Preliminary bump some version information.
committer: mfx <mfx> 1138080865 +0000
2006-01-24 05:34:25 +00:00
Markus F.X.J. Oberhumer 7760bbd77c New ACC version.
committer: mfx <mfx> 1138080385 +0000
2006-01-24 05:26:25 +00:00
Markus F.X.J. Oberhumer 9c0f1b02a7 Small Makefile updates.
committer: mfx <mfx> 1138080320 +0000
2006-01-24 05:25:20 +00:00
Markus F.X.J. Oberhumer 4ecfff4d8d Print a #define for the _SIZE. Enter 2006. Add John's name.
committer: mfx <mfx> 1138080110 +0000
2006-01-24 05:21:50 +00:00
László Molnár ac03b89f38 docs updates for 1.94
committer: ml1050 <ml1050> 1137999714 +0000
2006-01-23 07:01:54 +00:00
László Molnár 620174aea9 copyright text added
committer: ml1050 <ml1050> 1137999649 +0000
2006-01-23 07:00:49 +00:00
Markus F.X.J. Oberhumer ab50d28bc4 New ACC version.
committer: mfx <mfx> 1134926345 +0000
2005-12-18 17:19:05 +00:00
Markus F.X.J. Oberhumer b5318602d1 Fixed compilation problem.
committer: mfx <mfx> 1134926052 +0000
2005-12-18 17:14:12 +00:00
John Reiser bff2a63ea2 prefetching does not help length of match
l_lx_elf64amd.S amd_d_nrv2b.S amd_d_nrv2e.S

committer: jreiser <jreiser> 1132290120 +0000
2005-11-18 05:02:00 +00:00
László Molnár aacfb8820e better load_conf directory support. still needs some work.
committer: ml1050 <ml1050> 1132077577 +0000
2005-11-15 17:59:37 +00:00
John Reiser 98e8c031d0 generated header files
fold_elf64amd.h l_lx_elf64amd.h

committer: jreiser <jreiser> 1131994505 +0000
2005-11-14 18:55:05 +00:00
John Reiser beb4319d1e tune for better branch prediction by avoiding more than 3 in a 16-byte block
amd_d_nrv2b.S amd_d_nrv2e.S l_lx_elf64amd.S

committer: jreiser <jreiser> 1131994471 +0000
2005-11-14 18:54:31 +00:00
John Reiser 2558243c83 de-tabify; also speculate 1-byte loads to save a cycle or two
amd_d_nrv2b.S amd_d_nrv2e.S l_lx_elf64amd.S

committer: jreiser <jreiser> 1131943590 +0000
2005-11-14 04:46:30 +00:00
John Reiser b670e8d1ac tuning
amd_bxx.S amd_d_nrv2b.S amd_d_nrv2e.S l_lx_elf64amd.S

committer: jreiser <jreiser> 1131939243 +0000
2005-11-14 03:34:03 +00:00
John Reiser 68f8358f06 tune: avoid MOVSB for literals; inline default case of NEXTB macros
committer: jreiser <jreiser> 1131923823 +0000
2005-11-13 23:17:03 +00:00
John Reiser db5a099097 CLD and documentation
amd_d_nrv2e.S l_lx_elf64amd.S fold_elf64amd.S

committer: jreiser <jreiser> 1131854052 +0000
2005-11-13 03:54:12 +00:00
John Reiser ce33ffb62a handle compressed executables larger than 3MB on Elf64amd
committer: jreiser <jreiser> 1131833508 +0000
2005-11-12 22:11:48 +00:00
John Reiser 59a2fb9cfd recompile generated .h after source changes
fold_elf64amd.h l_lx_elf64amd.h

committer: jreiser <jreiser> 1131824699 +0000
2005-11-12 19:44:59 +00:00
John Reiser 75bba319de tuning, and prepare for large executables (>3MB compressed)
p_lx_elf.cpp stub/a_lx_elf64.c stub/amd_d_nrv2e.S
	stub/fold_elf64amd.S stub/l_lx_elf64amd.S

committer: jreiser <jreiser> 1131824655 +0000
2005-11-12 19:44:15 +00:00
John Reiser f78e9261f3 Do initLoader() properly, instead of relying on the amount of stack space
that is in use when ::buildLinuxLoader is called.

committer: jreiser <jreiser> 1131597922 +0000
2005-11-10 04:45:22 +00:00
Markus F.X.J. Oberhumer 5f77562333 Cleanup.
committer: mfx <mfx> 1131596991 +0000
2005-11-10 04:29:51 +00:00
Markus F.X.J. Oberhumer 5c4f01a68d New ACC version.
committer: mfx <mfx> 1131596966 +0000
2005-11-10 04:29:26 +00:00
Markus F.X.J. Oberhumer 35f6f998e6 Avoid warnings. Detabified.
committer: mfx <mfx> 1131593815 +0000
2005-11-10 03:36:55 +00:00
John Reiser 6737a3ae09 PackLinuxElf64amd
p_lx_elf.h p_lx_elf.cpp packmast.cpp

committer: jreiser <jreiser> 1131570778 +0000
2005-11-09 21:12:58 +00:00
John Reiser 09559bee8c Elf64
p_unix.h p_elf.h

committer: jreiser <jreiser> 1131570530 +0000
2005-11-09 21:08:50 +00:00
John Reiser f487ea27a8 UPX_F_LINUX_ELF64_AMD
committer: jreiser <jreiser> 1131568333 +0000
2005-11-09 20:32:13 +00:00
John Reiser a3d95f239a Generated .h header files for AMD x86_64
fold_elf64amd.h l_lx_elf64amd.h

committer: jreiser <jreiser> 1131566912 +0000
2005-11-09 20:08:32 +00:00
John Reiser 023c06e178 Support for 64-bit AMD x86_64
Makefile
Added Files:
	a_lx_elf64.c amd_bxx.S amd_d_nrv2e.S amd_regs.h
	fold_elf64amd.S l_lx_elf64amd.S l_lx_elf64amd.lds

committer: jreiser <jreiser> 1131566835 +0000
2005-11-09 20:07:15 +00:00
John Reiser 414a6c1c9e Enhance to handle both Elf32 and Elf64, and little/big endian.
http://buildroot.uclibc.org/cgi-bin/viewcvs.cgi/trunk/buildroot/toolchain/sstrip/sstrip.c
Revision 11028 [Added Tue Aug 2 18:20:34 2005 PDT (3 months, 1 week ago) by mjn3]

committer: jreiser <jreiser> 1131566192 +0000
2005-11-09 19:56:32 +00:00
John Reiser 910e18fb22 b_method 5th argument to f_decompress
l_lx_exec.c l_lx_pti.c l_lx_sep.c l_lx_sh.c

committer: jreiser <jreiser> 1131565060 +0000
2005-11-09 19:37:40 +00:00
John Reiser ac441fd1cf definitions for Elf64_*
committer: jreiser <jreiser> 1131564732 +0000
2005-11-09 19:32:12 +00:00
John Reiser 0c328372b5 Allow __uClibc_main and __uClibc_start_main like __libc_start_main.
committer: jreiser <jreiser> 1127269046 +0000
2005-09-21 02:17:26 +00:00
Markus F.X.J. Oberhumer 55ef60a6d4 Rebuilt with gcc-3.4.4.
committer: mfx <mfx> 1127188101 +0000
2005-09-20 03:48:21 +00:00
Markus F.X.J. Oberhumer c33584e683 Detabified.
committer: mfx <mfx> 1126929315 +0000
2005-09-17 03:55:15 +00:00
Markus F.X.J. Oberhumer ee8c7453bd Small updates.
committer: mfx <mfx> 1126927283 +0000
2005-09-17 03:21:23 +00:00
John Reiser 0330369603 remove debugging strut
l_lx_elf86.asm l_lx_elf86.h

committer: jreiser <jreiser> 1126892616 +0000
2005-09-16 17:43:36 +00:00
John Reiser 3f7b642c7d Linux i386 allow compression of position-independent main executables (gcc -pie).
p_elf.h p_lx_elf.cpp p_lx_elf.h p_lx_exc.cpp
	stub/fold_elf86.asm stub/fold_elf86.h stub/l_lx_elf.c
	stub/l_lx_elf86.asm stub/l_lx_elf86.h stub/l_lx_elf86.lds
	stub/linux.hh

committer: jreiser <jreiser> 1126886896 +0000
2005-09-16 16:08:16 +00:00
László Molnár eb6c51426a fixed a nasty relocation handling error which could produce broken
compressed files

committer: ml1050 <ml1050> 1126865811 +0000
2005-09-16 10:16:51 +00:00
Markus F.X.J. Oberhumer 0337bdb9fd Added support for UCL_USE_ASM.
committer: mfx <mfx> 1126844111 +0000
2005-09-16 04:15:11 +00:00
Markus F.X.J. Oberhumer 7aedc62058 Removed some old and dead code.
committer: mfx <mfx> 1126744217 +0000
2005-09-15 00:30:17 +00:00
Markus F.X.J. Oberhumer bfc835cbbf Added some more tests to upx_sanity_check(). Disable these for production
builds - code bloat.

committer: mfx <mfx> 1126743964 +0000
2005-09-15 00:26:04 +00:00
Markus F.X.J. Oberhumer 5c6ba30c48 New ACC version.
committer: mfx <mfx> 1126741199 +0000
2005-09-14 23:39:59 +00:00
Markus F.X.J. Oberhumer 8fe4824ed2 Fix typo.
committer: mfx <mfx> 1126295791 +0000
2005-09-09 19:56:31 +00:00
Markus F.X.J. Oberhumer d40cb3bd55 Cosmetic cleanups.
committer: mfx <mfx> 1126295335 +0000
2005-09-09 19:48:55 +00:00
Markus F.X.J. Oberhumer 4bcd3ac5d7 Mention arm/pe.
committer: mfx <mfx> 1126294945 +0000
2005-09-09 19:42:25 +00:00
Markus F.X.J. Oberhumer e2b8e9dea9 Avoid some warnings about unused args.
committer: mfx <mfx> 1126294727 +0000
2005-09-09 19:38:47 +00:00
László Molnár 572314bf3f support for arm/WinCE ("arm/pe") exes
committer: ml1050 <ml1050> 1126255781 +0000
2005-09-09 08:49:41 +00:00
Markus F.X.J. Oberhumer 14d303d331 Small updates according to latest glibc headers.
committer: mfx <mfx> 1126184484 +0000
2005-09-08 13:01:24 +00:00
Markus F.X.J. Oberhumer 24ffaa0738 Added BE64 and LE64 types.
committer: mfx <mfx> 1126183138 +0000
2005-09-08 12:38:58 +00:00
Markus F.X.J. Oberhumer 5d9b6d056d Small updates.
committer: mfx <mfx> 1126029328 +0000
2005-09-06 17:55:28 +00:00
Markus F.X.J. Oberhumer 5c28ff15ba Changes for new ACC version.
committer: mfx <mfx> 1126029282 +0000
2005-09-06 17:54:42 +00:00
Markus F.X.J. Oberhumer 06ceb2f2a1 New ACC version.
committer: mfx <mfx> 1126029264 +0000
2005-09-06 17:54:24 +00:00
Markus F.X.J. Oberhumer 7373e1dd8b Updated.
committer: mfx <mfx> 1122416155 +0000
2005-07-26 22:15:55 +00:00
Markus F.X.J. Oberhumer 4b1a9e714d New ACC version.
committer: mfx <mfx> 1122416002 +0000
2005-07-26 22:13:22 +00:00
Markus F.X.J. Oberhumer 9d76136358 Use gcc-3.4.4 for Linux stubs.
committer: mfx <mfx> 1122415958 +0000
2005-07-26 22:12:38 +00:00
Markus F.X.J. Oberhumer b3502420ad Removed patches/patch-elfcode.h and the patches/ directory - these
fixes now are already in upstream binutils for quite some time.

committer: mfx <mfx> 1119797919 +0000
2005-06-26 14:58:39 +00:00
Markus F.X.J. Oberhumer dd7ac7cca9 Updated.
committer: mfx <mfx> 1119614331 +0000
2005-06-24 11:58:51 +00:00
Markus F.X.J. Oberhumer 31dfa18e9b Updated.
committer: mfx <mfx> 1119613913 +0000
2005-06-24 11:51:53 +00:00
Markus F.X.J. Oberhumer 3e785008d3 Avoid warnings.
committer: mfx <mfx> 1119613856 +0000
2005-06-24 11:50:56 +00:00
Markus F.X.J. Oberhumer 6b7c7f755c Avoid warnings about unused vars.
committer: mfx <mfx> 1119613814 +0000
2005-06-24 11:50:14 +00:00
Markus F.X.J. Oberhumer c55a8a8703 Added some more sanity checks.
committer: mfx <mfx> 1119613748 +0000
2005-06-24 11:49:08 +00:00
Markus F.X.J. Oberhumer 64c97308ac Portability fix for gcc -ftrapv option.
committer: mfx <mfx> 1119613504 +0000
2005-06-24 11:45:04 +00:00
Markus F.X.J. Oberhumer 3551b0b95a Updated.
committer: mfx <mfx> 1119613441 +0000
2005-06-24 11:44:01 +00:00
Markus F.X.J. Oberhumer 9f16b5c4af Recompiled stubs.
committer: mfx <mfx> 1119613249 +0000
2005-06-24 11:40:49 +00:00
Markus F.X.J. Oberhumer 9777e549cb New upstream version.
committer: mfx <mfx> 1119613222 +0000
2005-06-24 11:40:22 +00:00
Markus F.X.J. Oberhumer fbfced1b93 New ACC version.
committer: mfx <mfx> 1119613192 +0000
2005-06-24 11:39:52 +00:00
John Reiser 1a84b4681c fix sign-extend bug
committer: jreiser <jreiser> 1114311664 +0000
2005-04-24 03:01:04 +00:00
John Reiser 4bf81b8e1c propagate compiled changes due to ppc_bxx.S
stub/fold_elfppc32.h stub/fold_machppc32.h

committer: jreiser <jreiser> 1114229942 +0000
2005-04-23 04:19:02 +00:00
John Reiser c282e7fdb4 PPC branch+call trick: filter first 4MB only
filteri.cpp filter/ppcbxx.h stub/ppc_bxx.S

committer: jreiser <jreiser> 1114229877 +0000
2005-04-23 04:17:57 +00:00
John Reiser d339ee3135 PackLinuxElf32::unpack forgot several get_native32()
committer: jreiser <jreiser> 1114229735 +0000
2005-04-23 04:15:35 +00:00
Markus F.X.J. Oberhumer 1de95de299 Updated.
committer: mfx <mfx> 1111664629 +0000
2005-03-24 11:43:49 +00:00
Markus F.X.J. Oberhumer 96c998a1d7 Updated for current glibc.
committer: mfx <mfx> 1111664285 +0000
2005-03-24 11:38:05 +00:00
Markus F.X.J. Oberhumer b5413c0156 Added John to main banner.
committer: mfx <mfx> 1110936050 +0000
2005-03-16 01:20:50 +00:00
Markus F.X.J. Oberhumer 7371c195ff Allocate larger xtrasize based on ih.datasize.
committer: mfx <mfx> 1110936001 +0000
2005-03-16 01:20:01 +00:00
Markus F.X.J. Oberhumer 0866a1996b Added two checks for buffer overflows as suggested by Giovanni Bajo.
committer: mfx <mfx> 1110732210 +0000
2005-03-13 16:43:30 +00:00
Markus F.X.J. Oberhumer 41f44c4e78 Updated.
committer: mfx <mfx> 1110731666 +0000
2005-03-13 16:34:26 +00:00
Markus F.X.J. Oberhumer 131712c3bd New ACC version.
committer: mfx <mfx> 1110731645 +0000
2005-03-13 16:34:05 +00:00
Markus F.X.J. Oberhumer bae12aaab7 Added more global operators.
committer: mfx <mfx> 1110731448 +0000
2005-03-13 16:30:48 +00:00
Markus F.X.J. Oberhumer 74d5844d8c Tried to make 64-bit clean. John, please have a look!
committer: mfx <mfx> 1110731221 +0000
2005-03-13 16:27:01 +00:00
Markus F.X.J. Oberhumer c87908266a Fix a compilation problem with older compilers.
committer: mfx <mfx> 1110730245 +0000
2005-03-13 16:10:45 +00:00
Markus F.X.J. Oberhumer f788d76b8c Added several __attribute_packed.
committer: mfx <mfx> 1110730186 +0000
2005-03-13 16:09:46 +00:00
Markus F.X.J. Oberhumer 41031e572e Updated.
committer: mfx <mfx> 1110729509 +0000
2005-03-13 15:58:29 +00:00
Markus F.X.J. Oberhumer f8a0864c1b Final updates. Really.
committer: mfx <mfx> 1109817185 +0000
2005-03-03 02:33:05 +00:00
Markus F.X.J. Oberhumer 949587334c Updates.
committer: mfx <mfx> 1109816699 +0000
2005-03-03 02:24:59 +00:00
Markus F.X.J. Oberhumer 0bc6a1a7f1 Updated.
committer: mfx <mfx> 1109765803 +0000
2005-03-02 12:16:43 +00:00
Markus F.X.J. Oberhumer 0d9cbfe927 Updated.
committer: mfx <mfx> 1109756565 +0000
2005-03-02 09:42:45 +00:00
Markus F.X.J. Oberhumer 8742a524c3 Small updates.
committer: mfx <mfx> 1109750922 +0000
2005-03-02 08:08:42 +00:00
Markus F.X.J. Oberhumer 79bf2297b5 New simple and modern Makefile.
committer: mfx <mfx> 1109750619 +0000
2005-03-02 08:03:39 +00:00
Markus F.X.J. Oberhumer 32e9e23630 Removed old Makfiles (horrible cruft dating back from 1998).
committer: mfx <mfx> 1109750572 +0000
2005-03-02 08:02:52 +00:00
Markus F.X.J. Oberhumer 7f1cecba92 Got changed. We must sync our toolchains.
committer: mfx <mfx> 1109750498 +0000
2005-03-02 08:01:38 +00:00
Markus F.X.J. Oberhumer efd30c61c3 Use namespace.
committer: mfx <mfx> 1109750346 +0000
2005-03-02 07:59:06 +00:00
Markus F.X.J. Oberhumer 4c97b11207 Added OBJSTRIP_xxx variables.
committer: mfx <mfx> 1109734187 +0000
2005-03-02 03:29:47 +00:00
John Reiser 58ea0ab745 use "~0u" to force unsigned bitmasks
committer: jreiser <jreiser> 1109691309 +0000
2005-03-01 15:35:09 +00:00
Markus F.X.J. Oberhumer 3547c71ad5 New ACC version.
committer: mfx <mfx> 1109674986 +0000
2005-03-01 11:03:06 +00:00
Markus F.X.J. Oberhumer 044d6b2ce2 Updated some ELF constants.
committer: mfx <mfx> 1109674932 +0000
2005-03-01 11:02:12 +00:00
Markus F.X.J. Oberhumer a0b26b6c06 Added Elf32_Dyn.
committer: mfx <mfx> 1109671693 +0000
2005-03-01 10:08:13 +00:00
Markus F.X.J. Oberhumer 8e3bfde439 Use templates.
committer: mfx <mfx> 1109671197 +0000
2005-03-01 09:59:57 +00:00
Markus F.X.J. Oberhumer 6507de959b Remove "struct" keywords.
committer: mfx <mfx> 1109671153 +0000
2005-03-01 09:59:13 +00:00
Markus F.X.J. Oberhumer 56d09bf3b5 Avoid warning.
committer: mfx <mfx> 1109669763 +0000
2005-03-01 09:36:03 +00:00
Markus F.X.J. Oberhumer 232754b978 Removed trailing whitespace.
committer: mfx <mfx> 1109669261 +0000
2005-03-01 09:27:41 +00:00
Markus F.X.J. Oberhumer 75ef603308 Linker updates from Laszlo. Needs some testing.
committer: mfx <mfx> 1109669078 +0000
2005-03-01 09:24:38 +00:00
Markus F.X.J. Oberhumer a5a2fcee4d Avoid warning.
committer: mfx <mfx> 1109345414 +0000
2005-02-25 15:30:14 +00:00
John Reiser f86d57bfe3 mmap() needs in-range fd; b_method as arg5 to decompress
l_lx_elfppc32.S l_lx_elfppc32.h
	ppc_d_nrv2e.S
	ppc_d_nrv2b.S

committer: jreiser <jreiser> 1109217478 +0000
2005-02-24 03:57:58 +00:00
John Reiser 615615b1df Unmap the compressed program before running the uncompressed.
fold_elfppc32.S fold_elfppc32.h

committer: jreiser <jreiser> 1109129677 +0000
2005-02-23 03:34:37 +00:00
John Reiser aeba0ce170 add dependencies for ppc_bxx.S and ppc_d_nrv2e.S
Makefile fold_elfppc32.h l_mac_ppc32.h

committer: jreiser <jreiser> 1109093661 +0000
2005-02-22 17:34:21 +00:00
John Reiser 5ce60aad53 data cache prefetch
ppc_d_nrv2e.S l_lx_elfppc32.h

committer: jreiser <jreiser> 1109034808 +0000
2005-02-22 01:13:28 +00:00
John Reiser dbc01de9a0 remove debugg-only 'trap'
committer: jreiser <jreiser> 1109012788 +0000
2005-02-21 19:06:28 +00:00
John Reiser dfaf3f24fc fix bad merge
p_lx_elf.h p_lx_exc.cpp

committer: jreiser <jreiser> 1108944786 +0000
2005-02-21 00:13:06 +00:00
John Reiser 14b0527e79 fix compiler waring
committer: jreiser <jreiser> 1108941316 +0000
2005-02-20 23:15:16 +00:00
John Reiser f0148c3161 prepare for M_CL1B
committer: jreiser <jreiser> 1108940729 +0000
2005-02-20 23:05:29 +00:00
John Reiser 6a5e3d924d p_lx_interp, p_mach
committer: jreiser <jreiser> 1108940412 +0000
2005-02-20 23:00:12 +00:00
John Reiser 664a82e7c9 Start re-organizing the packing of Elf, by making Elf32 come first,
with Big endian and Little endian derived from it.
I386 still uses the old way, but PowerPC (both Linux and Darwin [Mac])
use the new way.
	p_elf.h p_lx_elf.cpp p_lx_elf.h p_lx_exc.cpp p_lx_exc.h
	p_unix.cpp p_unix.h p_vmlinx.cpp p_vmlinx.h p_vmlinz.cpp

committer: jreiser <jreiser> 1108940224 +0000
2005-02-20 22:57:04 +00:00
John Reiser e2763b4826 new packers PackMachPPC32 PackLinuxElf32ppc PackLinuxI386interp
packmast.cpp
	p_lx_interp.h

committer: jreiser <jreiser> 1108939957 +0000
2005-02-20 22:52:37 +00:00
John Reiser afb29b19c2 PowerPC branch [and call] trick
committer: jreiser <jreiser> 1108939726 +0000
2005-02-20 22:48:46 +00:00
John Reiser 8d60343940 allow better handling for no_filter option;
new options is_ptinterp, use_ptintep, make_ptinterp;
reserve codes for M_CL1B.
	compress.ch conf.h main.cpp options.h

committer: jreiser <jreiser> 1108939577 +0000
2005-02-20 22:46:17 +00:00
John Reiser 67a77f1880 Packer for Macintosh Darwin Mach-o PowerPC32
Added Files:
	p_mach.cpp p_mach.h

committer: jreiser <jreiser> 1108863998 +0000
2005-02-20 01:46:38 +00:00
John Reiser c933974174 branch trick for PowerPC32
committer: jreiser <jreiser> 1108863063 +0000
2005-02-20 01:31:03 +00:00
John Reiser 19715903fb New stubs pti86 (PT_INTERP for Linux x86), Linux Elf PowerPC-32,
Apple Macintosh Darwin PowerPC-32.

committer: jreiser <jreiser> 1108862148 +0000
2005-02-20 01:15:48 +00:00
John Reiser c88f72fd15 disinguish between __i386__ and generic
committer: jreiser <jreiser> 1108861387 +0000
2005-02-20 01:03:07 +00:00
John Reiser 7818596271 stub loader for Linux Elf PowerPC32
Added Files:
	m_lx_elfppc32.c l_lx_elfppc32.lds
	fold_elfppc32.S l_lx_elfppc32.S
	fold_elfppc32.h l_lx_elfppc32.h  [these two created by Makefile]

committer: jreiser <jreiser> 1108861182 +0000
2005-02-20 00:59:42 +00:00
John Reiser 9cb8d7bca6 stub loader for Macintosh (Darwin) Mach-o PowerPC32
Added Files:
	l_mac_ppc32.S fold_machppc32.S m_mac_mach32.c
	l_mac_ppc32.h fold_machppc32.h [these two created by Makefile]

committer: jreiser <jreiser> 1108860254 +0000
2005-02-20 00:44:14 +00:00
John Reiser 46f9256114 PowerPC unfilter, decompress, and register definitions
Added Files:
	ppc_bxx.S ppc_d_nrv2e.S ppc_regs.h

committer: jreiser <jreiser> 1108855959 +0000
2005-02-19 23:32:39 +00:00
John Reiser c26ef87202 Let the UPX loader be an Elf PT_INTERP /opt/upx/run
Added Files:
	p_lx_interp.cpp stub/l_lx_pti.c stub/fold_pti86.asm
	stub/fold_pti86.h stub/l_lx_pti86.asm stub/l_lx_pti86.h
	stub/l_lx_pti86.lds

committer: jreiser <jreiser> 1108855010 +0000
2005-02-19 23:16:50 +00:00
John Reiser 89fee5b835 allow more sections; print failing section on overflow
committer: jreiser <jreiser> 1108850756 +0000
2005-02-19 22:05:56 +00:00
John Reiser f5795eb01b make_hatch() is called from l_lx_sep86.asm, so cannot be 'static'
committer: jreiser <jreiser> 1108850437 +0000
2005-02-19 22:00:37 +00:00
László Molnár dbf0c9f016 msg.cpp: fixed possible sigsegv caused by a tricky filename
committer: ml1050 <ml1050> 1108382780 +0000
2005-02-14 12:06:20 +00:00
Markus F.X.J. Oberhumer 586b43048f Bump version.
committer: mfx <mfx> 1107807914 +0000
2005-02-07 20:25:14 +00:00
Markus F.X.J. Oberhumer 63b9ee61d2 Prepare UPX 1.93 release.
committer: mfx <mfx> 1107804731 +0000
2005-02-07 19:32:11 +00:00
Markus F.X.J. Oberhumer 3b9eff7f34 Enter 2005; added all needed stub files to CVS.
committer: mfx <mfx> 1107804447 +0000
2005-02-07 19:27:27 +00:00
John Reiser 59668c5fc1 ::pack3 to set .p_filesz; also set blocksize to allow giant scripts as input
p_lx_sh.cpp p_lx_sh.h

committer: jreiser <jreiser> 1105479043 +0000
2005-01-11 21:30:43 +00:00
Markus F.X.J. Oberhumer 3ed786fb5c Updated.
committer: mfx <mfx> 1103717402 +0000
2004-12-22 12:10:02 +00:00
Markus F.X.J. Oberhumer 0cd5eb5472 Use gcc-3.4.3 for Linux stubs.
committer: mfx <mfx> 1103717370 +0000
2004-12-22 12:09:30 +00:00
Markus F.X.J. Oberhumer ff571b96cb New ACC version.
committer: mfx <mfx> 1103717337 +0000
2004-12-22 12:08:57 +00:00
John Reiser 36b852e6bf %cs at entry to decompressor varies a _lot_ among Linux 2.4.x, 2.6.y kernels.
Decompressor must adapt; no universal constants exist for __BOOT_CS, _BOOT_DS.
	p_vmlinx.cpp stub/l_vmlinz.asm

committer: jreiser <jreiser> 1103605278 +0000
2004-12-21 05:01:18 +00:00
John Reiser f0c21c7203 Enhance documentation for process flow and testing.
Include some notes for compressing kernels from Linux 2.4.x.

committer: jreiser <jreiser> 1103513947 +0000
2004-12-20 03:39:07 +00:00
John Reiser 0516d8260c Fix stack synchronization bug at end of unfilter.
[The confusing fake "conditional compilation" strikes again!]

committer: jreiser <jreiser> 1103513713 +0000
2004-12-20 03:35:13 +00:00
John Reiser 1418f57b96 Fix bugs between Filter.addvalue and ckt32 macro call: [re-]compressed
Linux kernels were not booting.  Explain .addvalue better.
Set kernel stack pointer for boot-time decompression according to
Linux kernel documentation.
	     p_vmlinx.cpp      p_vmlinz.cpp
	stub/l_vmlinx.asm stub/l_vmlinz.asm
	filter/cto.h filter/ctoj.h filter/ctok.h

committer: jreiser <jreiser> 1103326936 +0000
2004-12-17 23:42:16 +00:00
Markus F.X.J. Oberhumer b24fb59c94 New upstream version.
committer: mfx <mfx> 1101602738 +0000
2004-11-28 00:45:38 +00:00
Markus F.X.J. Oberhumer 8fcf2bcd59 Fix bele.h to use strict PODs. This should fix build problems reported on ARM.
committer: mfx <mfx> 1098709362 +0000
2004-10-25 13:02:42 +00:00
Markus F.X.J. Oberhumer 079b808a56 Updated.
committer: mfx <mfx> 1098709263 +0000
2004-10-25 13:01:03 +00:00
Markus F.X.J. Oberhumer a4e01e28db New ACC version.
committer: mfx <mfx> 1098709116 +0000
2004-10-25 12:58:36 +00:00
Markus F.X.J. Oberhumer ec1ef9099f Updated.
committer: mfx <mfx> 1096637333 +0000
2004-10-01 13:28:53 +00:00
Markus F.X.J. Oberhumer ac724c7e6c New PS1 version from Jens.
committer: mfx <mfx> 1096637259 +0000
2004-10-01 13:27:39 +00:00
Markus F.X.J. Oberhumer ec25835525 New ACC version.
committer: mfx <mfx> 1096636709 +0000
2004-10-01 13:18:29 +00:00
Markus F.X.J. Oberhumer d4841a641c Updates.
committer: mfx <mfx> 1092135204 +0000
2004-08-10 10:53:24 +00:00
Markus F.X.J. Oberhumer 5612460720 New ACC version.
committer: mfx <mfx> 1092134926 +0000
2004-08-10 10:48:46 +00:00
John Reiser 465ea6429f "new []" requires matching "delete []"
committer: jreiser <jreiser> 1090882098 +0000
2004-07-26 22:48:18 +00:00
Markus F.X.J. Oberhumer ed9057ca83 Cleanups.
committer: mfx <mfx> 1090594763 +0000
2004-07-23 14:59:23 +00:00
Markus F.X.J. Oberhumer 14ced962db Cleanup.
committer: mfx <mfx> 1090583778 +0000
2004-07-23 11:56:18 +00:00
Markus F.X.J. Oberhumer 1aff6b862d Replaced ACC with miniACC.
committer: mfx <mfx> 1090583659 +0000
2004-07-23 11:54:19 +00:00
Markus F.X.J. Oberhumer ef490c4220 Updates.
committer: mfx <mfx> 1090577049 +0000
2004-07-23 10:04:09 +00:00
Markus F.X.J. Oberhumer 0dda83cbbc Updated.
committer: mfx <mfx> 1090577037 +0000
2004-07-23 10:03:57 +00:00
Markus F.X.J. Oberhumer fa4efec3b5 Bumped version numbers.
committer: mfx <mfx> 1090283329 +0000
2004-07-20 00:28:49 +00:00
229 changed files with 27360 additions and 9922 deletions
+9 -3
View File
@@ -1,7 +1,13 @@
.bzr*
.darcs*
.git*
.hg*
_darcs _darcs
B B
ChangeLog.cvs* build*
TODO.*
build
doxygen doxygen
maint maint
ChangeLog.cvs*
GNUmakefile
MMakefile
TODO.*
+13
View File
@@ -0,0 +1,13 @@
.bzr*
.darcs*
.git*
.hg*
_darcs
B
build*
doxygen
maint
ChangeLog.cvs*
GNUmakefile
MMakefile
TODO.*
+1 -1
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2004 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2006 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
+15 -8
View File
@@ -1,6 +1,8 @@
# Toplevel Makefile for UPX # Toplevel Makefile for UPX
SHELL = /bin/sh MAKEFLAGS += -rR
.SUFFIXES:
export SHELL = /bin/sh
srcdir = . srcdir = .
top_srcdir = . top_srcdir = .
@@ -18,19 +20,24 @@ all mostlyclean clean distclean maintainer-clean:
dist: distclean dist: distclean
false false
zip:
cd .. && rm -f upx-current.zip && zip -r upx-current.zip upx ifneq ($(wildcard CVS/R*),)
CVS_ROOT := $(shell cat CVS/Root)
CVS_REPO := $(shell cat CVS/Repository)
endif
cvs-info:
@echo 'CVS info: $(CVS_ROOT) $(CVS_REPO)'
cvs-admin-ko: cvs-admin-ko:
cvs admin -ko . cvs admin -ko .
cvs update -P -d cvs -q -z6 update -P -d
ChangeLog: # automatically generate ChangeLog from CVS
ChangeLog ChangeLog.cvs:
perl $(srcdir)/scripts/cvs2cl.pl --utc -f ChangeLog.cvs perl $(srcdir)/scripts/cvs2cl.pl --utc -f ChangeLog.cvs
.PHONY: all mostlyclean clean distclean maintainer-clean .PHONY: all mostlyclean clean distclean maintainer-clean
.PHONY: dist cvs-admin-ko ChangeLog .PHONY: dist cvs-info cvs-admin-ko ChangeLog ChangeLog.cvs
.NOEXPORT:
+57 -30
View File
@@ -2,11 +2,41 @@
User visible changes for UPX User visible changes for UPX
================================================================== ==================================================================
[ UNSTABLE BETA VERSION - please see README.1ST for some more info ] Changes in 2.00 (27 Apr 2006):
* linux/386: the stub now prints an error message if some strict
SELinux mode does prevent runtime decompression and execution
(for a fully SELinux-compatible but otherwise inferior compression
format you can use the '--force-execve' option)
* linux/386: worked around a problem where certain Linux kernels
clobber the %ebx register during a syscall
* win32/pe: disable filters for files with broken PE headers
Changes in 1.96 beta (13 Apr 2006):
* arm/pe: added filter support
* win32/pe: removed an unnecessary check so that Delphi 2006 and
Digital Mars C++ programs finally are supported
Changes in 1.95 beta (09 Apr 2006):
* arm/pe: added DLL support
* arm/pe: added thumb mode stub support
* arm/pe: added unpacking support
* win32/pe: really worked around R6002 runtime errors
Changes in 1.94 beta (11 Mar 2006):
* new format: added support for arm/pe (ARM executables running on WinCE)
* new format: added support for linux elf/amd64
* new format: added support for linux elf/ppc32
* new format: added support for mach/ppc32 (Apple Mac OS X)
* win32/pe: hopefully working "load config" support
* win32/pe: R6002 runtime errors worked around
* win32/pe: the stub now clears the dirty stack
Changes in 1.93 beta (07 Feb 2005):
* vmlinuz/386: fixes to support more kernels
Changes in 1.92 beta (20 Jul 2004): Changes in 1.92 beta (20 Jul 2004):
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING * win32/pe: added option '--strip-loadconf' to strip the SEH load
* win32/pe: added option `--strip-loadconf' to strip the SEH load config section config section [NOTE: this option is obsolete since UPX 1.94]
* win32/pe: try to detect .NET (win32/net) files [not yet supported by UPX] * win32/pe: try to detect .NET (win32/net) files [not yet supported by UPX]
* vmlinux/386: new format that directly supports building Linux kernels * vmlinux/386: new format that directly supports building Linux kernels
* source code: now compiles cleanly under Win64 * source code: now compiles cleanly under Win64
@@ -17,7 +47,7 @@ Changes in 1.91 beta (30 Jun 2004):
* vmlinuz/386: added support for recent kernels * vmlinuz/386: added support for recent kernels
* watcom/le: don't crash on files without relocations * watcom/le: don't crash on files without relocations
* win32/pe: stricter checks of some PE values * win32/pe: stricter checks of some PE values
* option `--brute' now implies `--crp-ms=999999'. * option '--brute' now implies '--crp-ms=999999'.
* source code: much improved portability using ACC, the * source code: much improved portability using ACC, the
Automatic Compiler Configuration Automatic Compiler Configuration
* source code: compile fixes for strict ISO C++ compilers * source code: compile fixes for strict ISO C++ compilers
@@ -25,17 +55,15 @@ Changes in 1.91 beta (30 Jun 2004):
* re-synced with upx 1.25 branch * re-synced with upx 1.25 branch
Changes in 1.90 beta (11 Nov 2002): Changes in 1.90 beta (11 Nov 2002):
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING
* implemented several new options for finer compression control: * implemented several new options for finer compression control:
`--all-methods', `--all-filters' and `--brute' '--all-methods', '--all-filters' and '--brute'
* ps1/exe: new format - UPX now supports PlayStation One programs * ps1/exe: new format - UPX now supports PlayStation One programs
* linux/386: added the option `--force-execve' * linux/386: added the option '--force-execve'
* vmlinuz/386: better kernel detection and sanity checks * vmlinuz/386: better kernel detection and sanity checks
* re-synced with upx 1.24 branch * re-synced with upx 1.24 branch
* documentation updates * documentation updates
Changes in 1.11 beta (20 Dec 2000): Changes in 1.11 beta (20 Dec 2000):
* UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING
* vmlinuz/386: new format - UPX now supports bootable linux kernels * vmlinuz/386: new format - UPX now supports bootable linux kernels
* linux/elf386: added the new ELF direct-to-memory executable format - no * linux/elf386: added the new ELF direct-to-memory executable format - no
more temp files are needed for decompression! more temp files are needed for decompression!
@@ -75,9 +103,9 @@ Changes in 1.22 (27 Jun 2002)
Digital Mars C++ and Watcom C++ Digital Mars C++ and Watcom C++
Changes in 1.21 (01 Jun 2002) Changes in 1.21 (01 Jun 2002)
* New option `--crp-ms=' for slightly better compression at the cost * New option '--crp-ms=' for slightly better compression at the cost
of higher memory requirements during compression. of higher memory requirements during compression.
Try `upx --best --crp-ms=100000'. See the docs for more info. Try 'upx --best --crp-ms=100000'. See the docs for more info.
* source code: portability fixes * source code: portability fixes
* source code: compile fixes for g++ 3.0 and g++ 3.1 * source code: compile fixes for g++ 3.0 and g++ 3.1
@@ -91,7 +119,6 @@ Changes in 1.20 (23 May 2001)
our unstable development releases 1.1x and 1.9x] our unstable development releases 1.1x and 1.9x]
Changes in 1.08 (30 Apr 2001) Changes in 1.08 (30 Apr 2001)
* INFO: http://upx.sourceforge.net now is the new permanent UPX home page
* new native port to atari/tos * new native port to atari/tos
* win32/pe: shortened the identstring * win32/pe: shortened the identstring
* source code: portability fixes - UPX now builds cleanly under m68k CPUs * source code: portability fixes - UPX now builds cleanly under m68k CPUs
@@ -116,7 +143,7 @@ Changes in 1.05 (24 Jan 2001)
at the unstable UPX 1.1x beta versions for that) at the unstable UPX 1.1x beta versions for that)
Changes in 1.04 (19 Dec 2000) Changes in 1.04 (19 Dec 2000)
* dos/exe: fixed an internal error when using `--no-reloc' * dos/exe: fixed an internal error when using '--no-reloc'
* win32/pe: fixed a rare bug in the relocation handling code * win32/pe: fixed a rare bug in the relocation handling code
* some tunings for the default compression level * some tunings for the default compression level
@@ -124,7 +151,7 @@ Changes in 1.03 (30 Nov 2000)
* linked with a new version of the NRV compression library: * linked with a new version of the NRV compression library:
- improved compression ratio a little bit - improved compression ratio a little bit
- overall significantly faster compression - overall significantly faster compression
- much faster when using high compression levels like `-9' or `--best' - much faster when using high compression levels like '-9' or '--best'
- much faster with large files - much faster with large files
* atari/tos: added support for FreeMiNT * atari/tos: added support for FreeMiNT
* the 32-bit DOS version now uses the new CWSDSTUB extender * the 32-bit DOS version now uses the new CWSDSTUB extender
@@ -132,7 +159,7 @@ Changes in 1.03 (30 Nov 2000)
Changes in 1.02 (13 Sep 2000) Changes in 1.02 (13 Sep 2000)
* watcom/le: fixed a problem with the Causeway extender * watcom/le: fixed a problem with the Causeway extender
* win32/pe: don't automatically strip relocs if they seem needed * win32/pe: don't automatically strip relocs if they seem needed
* support multiple backup generations when using `-k' * support multiple backup generations when using '-k'
* updated the console screen driver * updated the console screen driver
Changes in 1.01 (09 Apr 2000) Changes in 1.01 (09 Apr 2000)
@@ -160,7 +187,7 @@ Changes in 0.99.1 (29 Feb 2000)
Changes in 0.99 (25 Feb 2000) Changes in 0.99 (25 Feb 2000)
* FULL SOURCE CODE RELEASED UNDER THE TERMS OF THE GNU GPL * FULL SOURCE CODE RELEASED UNDER THE TERMS OF THE GNU GPL
* win32/pe: changed default to `--strip-relocs=1' * win32/pe: changed default to '--strip-relocs=1'
* dos/com and dos/sys: fixed a bad decompressor problem * dos/com and dos/sys: fixed a bad decompressor problem
* linux/386: the counter for the progress indicator was off by one * linux/386: the counter for the progress indicator was off by one
@@ -183,7 +210,7 @@ Changes in 0.91 (13 Nov 1999)
* dos/exe: correctly restore cs when uncompressing * dos/exe: correctly restore cs when uncompressing
Changes in 0.90 (10 Nov 1999) Changes in 0.90 (10 Nov 1999)
* all formats: `--overlay=copy' now is the default overlay mode * all formats: '--overlay=copy' now is the default overlay mode
* improved compression ratio for most files * improved compression ratio for most files
* win32/pe: uncompression is finally supported * win32/pe: uncompression is finally supported
* win32/pe: never compress REGISTRY resources * win32/pe: never compress REGISTRY resources
@@ -193,7 +220,7 @@ Changes in 0.90 (10 Nov 1999)
* win32/pe: somewhat less memory is required during compression * win32/pe: somewhat less memory is required during compression
* linux/386: fixed compression of scripts which was broken since 0.71 * linux/386: fixed compression of scripts which was broken since 0.71
* linux/386: more FreeBSD compatibility issues * linux/386: more FreeBSD compatibility issues
* changed option: `-i' now prints some more details during compression * changed option: '-i' now prints some more details during compression
(not finished yet) (not finished yet)
Changes in 0.84 (04 Oct 1999) Changes in 0.84 (04 Oct 1999)
@@ -209,7 +236,7 @@ Changes in 0.83 (17 Sep 1999)
Changes in 0.82 (16 Aug 1999) Changes in 0.82 (16 Aug 1999)
* dos/exe: fixed a decompressor bug which could cause crash on some files * dos/exe: fixed a decompressor bug which could cause crash on some files
* linux/386: section headers are now stripped from the stub so that * linux/386: section headers are now stripped from the stub so that
`strip' won't ruin a compressed file any longer 'strip' won't ruin a compressed file any longer
* wc/le: support for stack not in the last object disabled again * wc/le: support for stack not in the last object disabled again
* win32/pe: removed some unneeded data * win32/pe: removed some unneeded data
@@ -218,32 +245,32 @@ Changes in 0.81 (04 Aug 1999)
* dos/com: fixed an internal error that could happen with very small files * dos/com: fixed an internal error that could happen with very small files
Changes in 0.80 (03 Aug 1999) Changes in 0.80 (03 Aug 1999)
* you can set some default options in the environment var `UPX' * you can set some default options in the environment var 'UPX'
* dos/com: the decompressor stub now checks for enough free memory * dos/com: the decompressor stub now checks for enough free memory
* dos/exe: decompressor rewritten, some bugs are fixed * dos/exe: decompressor rewritten, some bugs are fixed
* dos/exe: new option `--no-reloc': no relocation data is put into * dos/exe: new option '--no-reloc': no relocation data is put into
the DOS header the DOS header
* tmt/adam: added support for more stubs, detect already packed files * tmt/adam: added support for more stubs, detect already packed files
* tmt/adam: new option `--copy-overlay' * tmt/adam: new option '--copy-overlay'
* wc/le: reduced memory requirement during uncompression * wc/le: reduced memory requirement during uncompression
* wc/le: support files which do not contain their stack in the last object * wc/le: support files which do not contain their stack in the last object
* wc/le: fixed a bug which could cause a crash, improved relocation * wc/le: fixed a bug which could cause a crash, improved relocation
handling handling
* wc/le: new option `--copy-overlay' * wc/le: new option '--copy-overlay'
* win32/pe: `--compress-icons=2' is now the default * win32/pe: '--compress-icons=2' is now the default
* win32/pe: even better TLS support * win32/pe: even better TLS support
* win32/pe: versioninfo works on NT * win32/pe: versioninfo works on NT
* win32/pe: import by ordinal from kernel32.dll works * win32/pe: import by ordinal from kernel32.dll works
* win32/pe: other import improvements: importing a nonexistant DLL * win32/pe: other import improvements: importing a nonexistant DLL
results in a usual Windows message, importing a nonexistant function results in a usual Windows message, importing a nonexistant function
results in program exit (instead of crash ;-) results in program exit (instead of crash ;-)
* win32/pe: new option: `--compress-resources=0' * win32/pe: new option: '--compress-resources=0'
* win32/pe: reduced memory requirement during uncompression, some * win32/pe: reduced memory requirement during uncompression, some
files might even require LESS memory when they're compressed files might even require LESS memory when they're compressed
* win32/pe: TYPELIBs should work now * win32/pe: TYPELIBs should work now
* win32/pe: improved relocation handling, 16-bit relocations should work * win32/pe: improved relocation handling, 16-bit relocations should work
* win32/pe: new option `--strip-relocs' (only if you know what you are doing) * win32/pe: new option '--strip-relocs' (only if you know what you are doing)
* win32/pe: new option `--copy-overlay' * win32/pe: new option '--copy-overlay'
* important internal changes: now the stubs are built at runtime * important internal changes: now the stubs are built at runtime
Changes in 0.72 (12 May 1999) Changes in 0.72 (12 May 1999)
@@ -257,20 +284,20 @@ Changes in 0.72 (12 May 1999)
* linux/386: minor decompressor stub updates, nicer progress bar * linux/386: minor decompressor stub updates, nicer progress bar
Changes in 0.71 (19 Apr 1999) Changes in 0.71 (19 Apr 1999)
* dos/exe: added option `--no-overlay' * dos/exe: added option '--no-overlay'
* linux/386: various improvements in the stub, most notably the * linux/386: various improvements in the stub, most notably the
overhead for an extra cleanup process has been removed overhead for an extra cleanup process has been removed
* win32/pe: added support for export forwarders * win32/pe: added support for export forwarders
* win32/pe: added support for DLLs without entry point or imports * win32/pe: added support for DLLs without entry point or imports
* win32/pe: yet another .bss fix * win32/pe: yet another .bss fix
* win32/pe: new option `--compress-icons=2': compress all icons * win32/pe: new option '--compress-icons=2': compress all icons
which are not in the first icon directory which are not in the first icon directory
* win32/pe: rearranged stub to avoid false alerts from some virus scanners * win32/pe: rearranged stub to avoid false alerts from some virus scanners
Changes in 0.70 (30 Mar 1999) Changes in 0.70 (30 Mar 1999)
* added support for linux/386 executables * added support for linux/386 executables
* improved compression ratio quite a bit * improved compression ratio quite a bit
* added new compression level `--best' to squeeze out even some more bytes * added new compression level '--best' to squeeze out even some more bytes
* win32/pe: TLS support is much better now * win32/pe: TLS support is much better now
* win32/pe: --compress-icons=0 should now work as well * win32/pe: --compress-icons=0 should now work as well
* the usual minor fixes for win32/pe * the usual minor fixes for win32/pe
@@ -311,7 +338,7 @@ Changes in 0.40 (05 Oct 1998)
* fixed a small but fatal bug in dos/sys introduced in 0.30 * fixed a small but fatal bug in dos/sys introduced in 0.30
* fixed a rare bug in dos/exe * fixed a rare bug in dos/exe
* worked around a bug in djgpp's strip 2.8 * worked around a bug in djgpp's strip 2.8
* Allegro packfile support should work now * djgpp/coff: Allegro packfile support should work now
* added dos/exeh compression method (works on 386+) * added dos/exeh compression method (works on 386+)
Changes in 0.30 (27 Jul 1998) Changes in 0.30 (27 Jul 1998)
+1 -3
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2004 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2006 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
@@ -42,8 +42,6 @@ More formats:
- freebsd/386 (generic), freebsd/elf386 (specialized). - freebsd/386 (generic), freebsd/elf386 (specialized).
Probably could share most of the linux code. Probably could share most of the linux code.
- Windows CE
- add support for self-extracting HTML pages using a Javascript stub - add support for self-extracting HTML pages using a Javascript stub
(like the AlgART HTML Packer "AHP") (like the AlgART HTML Packer "AHP")
+9 -29
View File
@@ -8,32 +8,11 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2004 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2006 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
WARNING - UNSTABLE BETA VERSION
===============================
All versions 1.9x are unstable beta releases - use them only for testing,
and never distribute a program that is packed with them !
There will be hidden bugs. Really.
The current stable release is 1.25, and the next stable release
will be called version 2.00.
The main news since 1.25 are:
- slightly better compression using the new NRV2E algorithm
- new options for compression tuining (e.g. `--brute')
- support for bootable Linux kernels ("vmlinuz/386")
- support for Linux kernel building ("vmlinux/386")
- direct Linux ELF-to-memory decompression ("linux/elf386") and
shell-to-memory decompression ("linux/sh386")
- support for playstation exes ("ps1/exe")
- lots of new bugs ;-) take care
WELCOME WELCOME
======= =======
@@ -58,7 +37,7 @@ and run exactly as before, with no runtime or memory penalty for most
of the supported formats. of the supported formats.
UPX supports a number of different executable formats, including UPX supports a number of different executable formats, including
Windows 95/98/ME/NT/2000/XP programs and DLLs, DOS programs, Windows 95/98/ME/NT/2000/XP/CE programs and DLLs, DOS programs,
and Linux executables and kernels. and Linux executables and kernels.
UPX is free software distributed under the term of the GNU General UPX is free software distributed under the term of the GNU General
@@ -76,8 +55,8 @@ UPX aims to be Commercial Quality Freeware.
SHORT DOCUMENTATION SHORT DOCUMENTATION
=================== ===================
`upx program.exe' will compress a program or DLL. For best compression 'upx program.exe' will compress a program or DLL. For best compression
results try `upx --best program.exe'. results try 'upx --brute program.exe'.
Please see the file UPX.DOC for the full documentation. The files Please see the file UPX.DOC for the full documentation. The files
NEWS and BUGS also contain various tidbits of information. NEWS and BUGS also contain various tidbits of information.
@@ -91,7 +70,7 @@ UPX comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
Having said that, we think that UPX is quite stable now. Indeed we Having said that, we think that UPX is quite stable now. Indeed we
have compressed lots of files without any problems. Also, the have compressed lots of files without any problems. Also, the
current version has undergone several months of beta testing - current version has undergone several months of beta testing -
actually it's more than 4 years since our first public beta. actually it's almost 8 years since our first public beta.
This is the first production quality release, and we plan that future This is the first production quality release, and we plan that future
releases will be backward compatible with this version. releases will be backward compatible with this version.
@@ -129,8 +108,9 @@ THE FUTURE
COPYRIGHT COPYRIGHT
========= =========
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
This program may be used freely, and you are welcome to This program may be used freely, and you are welcome to
redistribute it under certain conditions. redistribute it under certain conditions.
@@ -149,7 +129,7 @@ Markus & Laszlo
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
+17 -17
View File
@@ -8,26 +8,26 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2006 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net
WARNING - UNSTABLE BETA VERSION MAJOR NEWS IN UPX 2
=============================== ===================
All versions 1.9x are unstable beta releases - use them only for testing,
and never distribute a program that is packed with them !
There will be hidden bugs. Really.
The current stable release is 1.25, and the next stable release
will be called version 2.00.
The main news since 1.25 are: The main news since 1.25 are:
- slightly better compression using the new NRV2E algorithm
- new options for compression tuining (e.g. `--brute') * new format: added support for arm/pe (ARM executables running on WinCE)
- support for bootable Linux kernels ("vmlinuz/386") * new format: added support for linux elf/amd64
- support for Linux kernel building ("vmlinux/386") * new format: added support for linux elf/ppc32
- direct Linux ELF-to-memory decompression ("linux/elf386") and * new format: added support for mach/ppc32 (Apple Mac OS X)
shell-to-memory decompression ("linux/sh386") * new format: added support for bootable Linux kernels ("vmlinuz/386")
- support for playstation exes ("ps1/exe") * new format: added support for Playstation exes ("ps1/exe")
- lots of new bugs ;-) take care
* slightly better compression using the new NRV2E algorithm
* new options for compression tuning (e.g. '--brute')
* improved win32/pe compatibility
* direct ELF-to-memory decompression
* various bug fixes
+21 -15
View File
@@ -69,11 +69,7 @@ Tools needed to build/modify the UPX sources
- A C++ compiler supporting inner classes, templates, exceptions - A C++ compiler supporting inner classes, templates, exceptions
and RTTI. and RTTI.
- GNU make 3.80 for Win32 - GNU make 3.80 or better
http://www.cygwin.com/
- GNU make 3.80 for DOS
http://www.delorie.com/djgpp/
To compile the packer sources To compile the packer sources
@@ -81,8 +77,8 @@ To compile the packer sources
set the environment variable UCLDIR to point to your UCL installation, e.g. set the environment variable UCLDIR to point to your UCL installation, e.g.
set UCLDIR=c:\src\ucl-1.02 (DOS / Windows) set UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
export UCLDIR=$HOME/local/src/ucl-1.02 (Unix) export UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
then type then type
@@ -96,19 +92,30 @@ To compile the packer sources
If you want to modify the stub sources you'll also need If you want to modify the stub sources you'll also need
------------------------------------------------------- -------------------------------------------------------
- Nasm 0.98.38 - the Netwide Assembler
http://upx.sourceforge.net/download/tools/
http://sourceforge.net/projects/nasm/
- A68K - a 68000 macro assembler - A68K - a 68000 macro assembler
http://upx.sourceforge.net/download/tools/ http://upx.sourceforge.net/download/tools/
- ASM5900 - a MIPS R3000 assembler
http://upx.sourceforge.net/download/tools/
- djasm - an assembler for the djgpp stub - djasm - an assembler for the djgpp stub
http://upx.sourceforge.net/download/tools/ http://upx.sourceforge.net/download/tools/
- Perl 5.6 or better - nasm 0.98.39 - the Netwide Assembler
http://upx.sourceforge.net/download/tools/
http://sourceforge.net/projects/nasm/
- Linux (for the linux/386 stubs) - Perl & Python
- Certain versions of some i386-linux tools:
- gcc-2.95.3
- gcc-3.4.6
- binutils-2.16.1
- Other cross compilers targeted at the following architectures:
- arm-9tdmi-linux-gnu
- powerpc-750-linux-gnu
- x86_64-unknown-linux-gnu
Misc. notes Misc. notes
@@ -124,8 +131,7 @@ Misc. notes
- Use gcc extensions and other compiler specific stuff only through - Use gcc extensions and other compiler specific stuff only through
macros. macros.
- Keep in mind that it should be possible to build UPX on braindead - Keep in mind that it should be possible to build UPX on braindead
file systems (FAT). Don't use long file names or other things case insensitive file systems (FAT).
that break building under plain DOS.
*** ***
+1 -3
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2004 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2006 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
@@ -39,8 +39,6 @@ Ice
for debugging the PE headersize problem down for debugging the PE headersize problem down
Joergen Ibsen <jibz@hotmail.com> and d'b Joergen Ibsen <jibz@hotmail.com> and d'b
for the relocation & address optimization ideas for the relocation & address optimization ideas
John F. Reiser <jreiser@BitWagon.com>
for the new Linux executable formats
John S. Fine <johnfine@erols.com> John S. Fine <johnfine@erols.com>
for the new version of the dos/exe decompressor for the new version of the dos/exe decompressor
Lukundoo <Lukundoo@softhome.net> Lukundoo <Lukundoo@softhome.net>
+4 -4
View File
@@ -1,13 +1,15 @@
UPX TODO list. Last updated 2004-07-19. UPX TODO list. Last updated 2006-03-11.
IMPORTANT PROBLEMS THAT SHOULD BE FIXED SOON: IMPORTANT PROBLEMS THAT SHOULD BE FIXED SOON:
- stub ctojr32 needs CPU 486 because of bswap - [None]
OTHER: OTHER:
- docs: convert docs from upx.pod to use AsciiDoc
- check all <const_cast> to make sure they are not invalid - check all <const_cast> to make sure they are not invalid
- throwNotCompressible() is not a real error, so make the output nicer - throwNotCompressible() is not a real error, so make the output nicer
@@ -106,8 +108,6 @@ FORMAT WIN32/PE
2 - easy - mfx + ml) new switch(es) : do not compress resource types x,y,z 2 - easy - mfx + ml) new switch(es) : do not compress resource types x,y,z
or resource names a,b,c or resource names a,b,c
3 - medium - ml) rebuild exports
3 - difficult) don't compress the BSS section and other holes. 3 - difficult) don't compress the BSS section and other holes.
4 - medium - ml) fix when objectalign < 0x1000 4 - medium - ml) fix when objectalign < 0x1000
+6
View File
@@ -0,0 +1,6 @@
upx.1
upx.doc
upx.html
upx.man
upx.ps
upx.tex
+4 -4
View File
@@ -1,9 +1,11 @@
MAKEFLAGS += -rR
.SUFFIXES:
SHELL = /bin/sh SHELL = /bin/sh
top_srcdir = .. top_srcdir = ..
PACKAGE = upx PACKAGE = upx
VERSION_DATE = 20 Jul 2004 VERSION_DATE := $(shell sed -n 's/^.*UPX_VERSION_DATE_ISO .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h) VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h)
TRIMSPACE = cat TRIMSPACE = cat
@@ -62,7 +64,5 @@ maintainer-clean: distclean
### dependencies ### dependencies
### ###
$(BUILT_SOURCES): $(top_srcdir)/src/version.h Makefile $(BUILT_SOURCES): $(top_srcdir)/src/version.h $(MAKEFILE_LIST)
.NOEXPORT:
+1 -1
View File
@@ -11,7 +11,7 @@ loads of cryptic comments like `__PERELOC2__'.
If you look at the C++ source files, however you can notice that these If you look at the C++ source files, however you can notice that these
comment strings (without the leading and trailing underscores) are used comment strings (without the leading and trailing underscores) are used
in the following way (they are all 8 character length strings): in the following way:
addLoader("PEMAIN20", addLoader("PEMAIN20",
ih.entry ? "PEDOJUMP" : "PERETURN", ih.entry ? "PEDOJUMP" : "PERETURN",
+43
View File
@@ -0,0 +1,43 @@
UPX and SELinux
March 6, 2006
When a program that has been compressed by UPX is run, the decompressor
must create and write new memory pages of executable instructions.
SELinux (Security Enhanced Linux) directly controls the conditions
under which generating and/or executing new instructions is allowed,
so the configuration settings of SELinux affect the running of programs
that have been compressed by UPX.
In SELinux "strict enforcing" mode (the most restrictive), generating
new instructions at runtime is not allowed at all: any page with
PROT_EXEC permission must be mapped from a file in a mounted filesystem
that has 'x' [eXecute] permission, and the generation of such files is
also tightly controlled. A program that was compressed by UPX will not
run in SELinux strict enforcing mode. Attempts will fail with exit
code 127, and a record will be added to the history file
/var/log/audit/audit.log.
In "targeted enforcing" mode, SELinux pays close attention mostly to
designated processes that run with elevated privileges: web server,
print server, login server, etc. Ordinary user excutables receive
much less scrutiny. However, one of the eventual goals of SELinux is to
eradicate runtime generation of instructions because of the possibility
for exploitation by malware (virus, trojan, key logger, privilege
elevation exploit, etc.) Thus targeted enforcing mode notices and
logs the use of "execmem" capability that is used by a program which
was compressed by UPX. In keeping with the goal of eventual prohibition,
SELinux ordinarily would deny execmem. However, most current SELinux
systems, including Fedora Core 5 [set for release March 15, 2006],
override this with "allow_exemem=1" in /etc/selinux/targeted/booleans.
Thus a program compressed by UPX will run in the default installed
configuration (targeted enforcing, allow_execmem=1) of SELinux under
Fedora Core 5. Each invocation will add a few lines to the log file
/var/log/audit/audit.log, one line for each use of execmem. If the
SELinux policy becomes more restrictive in the future, then a special
SELinux class or other mechanism must be created for compressed programs,
or else UPX-compressed executables will not run then.
In its "permissive" modes, SELinux just logs the potential problems,
but otherwise does not interfere. A program compressed by UPX will run
in any permissive mode.
+35 -30
View File
@@ -13,7 +13,7 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
=head1 ABSTRACT =head1 ABSTRACT
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2004 Markus Oberhumer & Laszlo Molnar Copyright (c) 1996-2006 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net http://upx.sourceforge.net
@@ -75,8 +75,13 @@ B<UPX> is a versatile executable packer with the following features:
* rtm32/pe * rtm32/pe
* tmt/adam * tmt/adam
* vmlinuz/386 [bootable Linux kernel] * vmlinuz/386 [bootable Linux kernel]
* vmlinux/386
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay) * watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
* win32/pe * win32/pe (exe and dll)
* arm/pe (exe and dll)
* linux/elfamd64
* linux/elfppc32
* mach/elfppc32
- portable: UPX is written in portable endian-neutral C++ - portable: UPX is written in portable endian-neutral C++
@@ -224,9 +229,6 @@ copies the overlay after the compressed image. This works with some
files, but doesn't work with others, depending on how an application files, but doesn't work with others, depending on how an application
actually accesses this overlayed data. actually accesses this overlayed data.
Since version 0.90 UPX defaults to B<--overlay=copy> for
all executable formats.
--overlay=copy Copy any extra data attached to the file. [DEFAULT] --overlay=copy Copy any extra data attached to the file. [DEFAULT]
--overlay=strip Strip any overlay from the program instead of --overlay=strip Strip any overlay from the program instead of
@@ -695,10 +697,10 @@ Extra options available for this executable format:
This is the executable format used by the Sony PlayStation (PSone), This is the executable format used by the Sony PlayStation (PSone),
a Mips R3000 based gaming console which is popular since the late '90s. a Mips R3000 based gaming console which is popular since the late '90s.
Support of this format is very similar to the Atari one, because of Support of this format is very similar to the Atari one, because of
nostalgic feelings of one of the authors, but this format maybe serves nostalgic feelings of one of the authors.
a practical purpose ;-).
Packed programs will be byte-identical to the original after uncompression. Packed programs will be byte-identical to the original after uncompression,
until further notice.
Maximum uncompressed size: ~1998848 bytes. Maximum uncompressed size: ~1998848 bytes.
@@ -721,21 +723,19 @@ Extra options available for this executable format:
the compression ratio in some cases, but usually the compression ratio in some cases, but usually
the default method gives the best results anyway. the default method gives the best results anyway.
--console-run This enables client/target transfer compatibility. --boot-only The format will only run from a CD and may slightly
This format also run from a CD, except the "--no-align" improves the compression ratio. The decompression
option is used. Upto 2024 bytes larger files routines are faster than default ones.
than [default] will be the result, also a But it cannot be used for host/client transfer !
slower decompression speed can be expected.
--no-align This option disables CD mode 2 data sector format --no-align This option disables CD mode 2 data sector format
alignment, and enables "--console-run". alignment. May slightly improves the compression ratio,
This will slightly improve the compression ratio,
but the compressed executable will not boot from a CD. but the compressed executable will not boot from a CD.
So use it for client/target transfer only!. Use it for client/target transfer only !
=head2 NOTES FOR RTM32/PE =head2 NOTES FOR RTM32/PE and ARM/PE
Same as win32/pe. Same as win32/pe.
@@ -829,10 +829,11 @@ The PE support in B<UPX> is quite stable now, but probably there are
still some incompabilities with some files. still some incompabilities with some files.
Because of the way B<UPX> (and other packers for this format) works, you Because of the way B<UPX> (and other packers for this format) works, you
can see increased memory usage of your compressed files. If you start can see increased memory usage of your compressed files because the whole
several instances of huge compressed programs you're wasting memory program is loaded into memory at startup.
because the common segements of the program won't get shared If you start several instances of huge compressed programs you're
across the instances. wasting memory because the common segements of the program won't
get shared across the instances.
On the other hand if you're compressing only smaller programs, or On the other hand if you're compressing only smaller programs, or
running only one instance of larger programs, then this penalty is running only one instance of larger programs, then this penalty is
smaller, but it's still there. smaller, but it's still there.
@@ -840,12 +841,19 @@ smaller, but it's still there.
If you're running executables from network, then compressed programs If you're running executables from network, then compressed programs
will load faster, and require less bandwidth during execution. will load faster, and require less bandwidth during execution.
DLLs are supported. DLLs are supported. But UPX compressed DLLs can not share common data and
code when they got used by multiple applications. So compressing msvcrt.dll
is a waste of memory, but compressing the dll plugins of a particular
application may be a better idea.
Screensavers are supported, with the restriction that the filename Screensavers are supported, with the restriction that the filename
must end in ".scr" (as screensavers are handled slightly different must end with ".scr" (as screensavers are handled slightly different
than normal exe files). than normal exe files).
UPX compressed PE files has some minor memory overhead (usually in the
10 - 30 kbytes range) which can be seen by specifying the "-i" command
line switch during compression.
Extra options available for this executable format: Extra options available for this executable format:
--compress-exports=0 Don't compress the export section. --compress-exports=0 Don't compress the export section.
@@ -869,9 +877,6 @@ Extra options available for this executable format:
unexpected value in a header field. unexpected value in a header field.
Use with care. Use with care.
--strip-loadconf=0 Don't strip Structured Exception Handling load config [DEFAULT].
--strip-loadconf=1 Strip Structured Exception Handling load config.
--strip-relocs=0 Don't strip relocation records. --strip-relocs=0 Don't strip relocation records.
--strip-relocs=1 Strip relocation records. [DEFAULT] --strip-relocs=1 Strip relocation records. [DEFAULT]
This option only works on executables with base This option only works on executables with base
@@ -924,13 +929,13 @@ Please report all bugs immediately to the authors.
=head1 COPYRIGHT =head1 COPYRIGHT
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser Copyright (C) 2000-2006 John F. Reiser
Copyright (C) 2002-2004 Jens Medoch Copyright (C) 2002-2006 Jens Medoch
This program may be used freely, and you are welcome to This program may be used freely, and you are welcome to
redistribute it under certain conditions. redistribute it under certain conditions.
View File
-101
View File
@@ -1,101 +0,0 @@
The GNU bfd binary file descriptor package, part of the GNU binutils package,
contains code to recognize an Elf file by looking at fields in the file header.
Many programs (such as gdb, size, objdump, objcopy, strip and others) use bfd.
Unfortunately, bfd has been overly strict. In releases
binutils-2.9.1.0.4, binutils-2.9.1.0.23, binutils-2.9.5.0.0,
binutils-2.10.1,
gdb-4.17, gdb-5.0,
and probably others,
bfd does not recognize a file with zero in Elf32_Ehdr.e_shoff, .e_shentsize,
or .e_shnum, even though the operating system kernel does not care, and many
bfd clients would work just fine in these cases.
Because of its desire to create small size compressed executables, UPX
generates and uses Elf files with zero in .e_shoff, .e_shentsizes, and .e_shnum.
As a result, many widely-distributed instances of gdb, size, objdump, etc.,
refuse to work on UPX-packed executables.
Here is a patch to bfd/elfcode.h which enables many bfd clients to work
with UPX-packed executables. The last two lines of the patch are
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
return -1;
--- elfcode.h.orig Mon Jun 16 11:45:32 1997
+++ elfcode.h Sat Apr 22 10:18:56 2000
@@ -1,5 +1,5 @@
/* ELF executable support for BFD.
- Copyright 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Copyright 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
in "UNIX System V Release 4, Programmers Guide: ANSI C and
@@ -517,14 +517,14 @@
elf_debug_file (i_ehdrp);
#endif
- /* If there is no section header table, we're hosed. */
- if (i_ehdrp->e_shoff == 0)
+ /* If there is no section header table, and relocatable, then we're hosed. */
+ if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_type == ET_REL)
goto got_wrong_format_error;
/* As a simple sanity check, verify that the what BFD thinks is the
size of each section header table entry actually matches the size
- recorded in the file. */
- if (i_ehdrp->e_shentsize != sizeof (x_shdr))
+ recorded in the file, but only if there are any sections. */
+ if (i_ehdrp->e_shentsize != sizeof (x_shdr) && i_ehdrp->e_shnum != 0)
goto got_wrong_format_error;
ebd = get_elf_backend_data (abfd);
@@ -579,6 +579,7 @@
/* Allocate space for a copy of the section header table in
internal form, seek to the section header table in the file,
read it in, and convert it to internal form. */
+ if (i_ehdrp->e_shnum!=0) {
i_shdrp = ((Elf_Internal_Shdr *)
bfd_alloc (abfd, sizeof (*i_shdrp) * i_ehdrp->e_shnum));
elf_elfsections (abfd) = ((Elf_Internal_Shdr **)
@@ -609,6 +610,7 @@
if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
goto got_no_match;
}
+ }
/* Read in the program headers. */
if (i_ehdrp->e_phnum == 0)
@@ -644,6 +646,7 @@
bfd_section_from_shdr with it (since this particular strtab is
used to find all of the ELF section names.) */
+ if (i_ehdrp->e_shstrndx != 0) {
shstrtab = bfd_elf_get_str_section (abfd, i_ehdrp->e_shstrndx);
if (!shstrtab)
goto got_no_match;
@@ -657,6 +660,7 @@
if (! bfd_section_from_shdr (abfd, shindex))
goto got_no_match;
}
+ }
/* Let the backend double check the format and override global
information. */
@@ -930,7 +934,7 @@
{
Elf_Internal_Shdr *hdr;
Elf_Internal_Shdr *verhdr;
- long symcount; /* Number of external ELF symbols */
+ unsigned long symcount; /* Number of external ELF symbols */
elf_symbol_type *sym; /* Pointer to current bfd symbol */
elf_symbol_type *symbase; /* Buffer for generated bfd symbols */
Elf_Internal_Sym i_sym;
@@ -978,7 +982,7 @@
sym = symbase = NULL;
else
{
- long i;
+ unsigned long i;
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
return -1;
View File
+89 -41
View File
@@ -1,4 +1,4 @@
#! /usr/bin/perl -w #! /usr/bin/perl
############################################################## ##############################################################
@@ -7,9 +7,9 @@
### ### ### ###
############################################################## ##############################################################
## $Revision: 2.57 $ ## $Revision: 2.59 $
## $Date: 2004/07/10 19:38:37 $ ## $Date: 2005/05/18 05:34:34 $
## $Author: fluffy $ ## $Author: kfogel $
## ##
use strict; use strict;
@@ -17,8 +17,8 @@ use strict;
use File::Basename qw( fileparse ); use File::Basename qw( fileparse );
use Getopt::Long qw( GetOptions ); use Getopt::Long qw( GetOptions );
use Text::Wrap qw( ); use Text::Wrap qw( );
use User::pwent qw( getpwnam );
use Time::Local qw( timegm ); use Time::Local qw( timegm );
use User::pwent qw( getpwnam );
# The Plan: # The Plan:
# #
@@ -141,7 +141,7 @@ use Time::Local qw( timegm );
# Globals -------------------------------------------------------------------- # Globals --------------------------------------------------------------------
# In case we have to print it out: # In case we have to print it out:
my $VERSION = '$Revision: 2.57 $'; my $VERSION = '$Revision: 2.59 $';
$VERSION =~ s/\S+\s+(\S+)\s+\S+/$1/; $VERSION =~ s/\S+\s+(\S+)\s+\S+/$1/;
## Vars set by options: ## Vars set by options:
@@ -955,7 +955,20 @@ sub pretty_file_list {
# ------------------------------------- # -------------------------------------
sub output_tagdate { sub output_tagdate {
# NOT YET DONE my $self = shift;
my ($fh, $time, $tag) = @_;
my ($y, $m, $d, $H, $M, $S) = (gmtime($time))[5,4,3,2,1,0];
# Ideally, this would honor $UTC_Times and use +HH:MM syntax
my $isoDate = sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",
$y + 1900, $m + 1, $d, $H, $M, $S);
print $fh "<tagdate>\n";
print $fh "<tagisodate>$isoDate</tagisodate>\n";
print $fh "<tagdatetag>$tag</tagdatetag>\n";
print $fh "</tagdate>\n\n";
return;
} }
# ------------------------------------- # -------------------------------------
@@ -1051,11 +1064,6 @@ sub _revision_is_wanted {
my $follow_branches = $self->{follow_branches}; my $follow_branches = $self->{follow_branches};
my $follow_only = $self->{follow_only}; my $follow_only = $self->{follow_only};
#print STDERR "IG: ", join(',', keys %{$self->{ignore_tags}}), "\n";
#print STDERR "IX: ", join(',', @{$qunk->{tags}}), "\n" if defined $qunk->{tags};
#print STDERR "IQ: ", join(',', keys %{$qunk->{branch_numbers}}), "\n" if defined $qunk->{branch_numbers};
#use Data::Dumper; print STDERR Dumper $qunk;
for my $ignore_tag (keys %{$self->{ignore_tags}}) { for my $ignore_tag (keys %{$self->{ignore_tags}}) {
return return
if defined $qunk->{tags} and grep $_ eq $ignore_tag, @{$qunk->{tags}}; if defined $qunk->{tags} and grep $_ eq $ignore_tag, @{$qunk->{tags}};
@@ -1095,12 +1103,13 @@ sub _revision_is_wanted {
($branch_number . ".") ) { ($branch_number . ".") ) {
if ( $followsub ) { if ( $followsub ) {
return 1; return 1;
} elsif (length($revision) == length($branch_number)+2 ) { # } elsif ( length($revision) == length($branch_number)+2 ) {
} elsif ( substr($revision, length($branch_number)+1) =~ /^\d+$/ ) {
return 1; return 1;
} }
} elsif ( length($branch_number) > length($revision) } elsif ( length($branch_number) > length($revision)
and and
$No_Ancestors ) { ! $No_Ancestors ) {
# Non-trivial case: check if rev is ancestral to branch # Non-trivial case: check if rev is ancestral to branch
# r_left still has the trailing "." # r_left still has the trailing "."
@@ -1213,13 +1222,13 @@ my $self = shift; my $class = ref $self;
# XML output includes everything else, we might as well make # XML output includes everything else, we might as well make
# it always include Day Of Week too, for consistency. # it always include Day Of Week too, for consistency.
my $authorhash = $changelog{$time}; my $authorhash = $changelog{$time};
if ($Show_Tag_Dates) { if ( $Show_Tag_Dates || $XML_Output ) {
my %tags; my %tags;
while (my ($author,$mesghash) = each %$authorhash) { while (my ($author,$mesghash) = each %$authorhash) {
while (my ($msg,$qunk) = each %$mesghash) { while (my ($msg,$qunk) = each %$mesghash) {
foreach my $qunkref2 (@$qunk) { for my $qunkref2 (@$qunk) {
if (defined ($qunkref2->tags)) { if (defined ($qunkref2->tags)) {
foreach my $tag (@{$qunkref2->tags}) { for my $tag (@{$qunkref2->tags}) {
$tags{$tag} = 1; $tags{$tag} = 1;
} }
} }
@@ -1308,9 +1317,9 @@ my $self = shift; my $class = ref $self;
while (<OLD_LOG>) { while (<OLD_LOG>) {
if ( ! $passed_first_entry ) { if ( ! $passed_first_entry ) {
if ( ( ! $started_first_entry ) if ( ( ! $started_first_entry )
and /^(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)/ ) { and /^(\d\d\d\d-\d\d-\d\d\s+(\w+\s+)?\d\d:\d\d)/ ) {
$started_first_entry = 1; $started_first_entry = 1;
} elsif ( /^(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)/ ) { } elsif ( /^(\d\d\d\d-\d\d-\d\d\s+(\w+\s+)?\d\d:\d\d)/ ) {
$passed_first_entry = 1; $passed_first_entry = 1;
print NEW_LOG $_; print NEW_LOG $_;
} }
@@ -1924,22 +1933,38 @@ sub grand_poobah { $_[0]->{grand_poobah} }
sub read_changelog { sub read_changelog {
my ($self, $command) = @_; my ($self, $command) = @_;
# my $grand_poobah = CVS::Utils::ChangeLog::EntrySet->new; local (*READER, *WRITER);
my $pid;
if (! $Input_From_Stdin) { if (! $Input_From_Stdin) {
my $Log_Source_Command = join(' ', @$command); pipe(READER, WRITER)
&main::debug ("(run \"${Log_Source_Command}\")\n"); or die "Couldn't form pipe: $!\n";
open (LOG_SOURCE, "$Log_Source_Command |") $pid = fork;
or die "unable to run \"${Log_Source_Command}\""; die "Couldn't fork: $!\n"
if ! defined $pid;
if ( ! $pid ) { # child
open STDOUT, '>&=' . fileno WRITER
or die "Couldn't dup stderr to ", fileno WRITER, "\n";
# strangely, some perls give spurious warnings about STDIN being opened
# for output only these close calls precede the STDOUT reopen above.
# I think they must be reusing fd 1.
close READER;
close STDIN;
exec @$command;
}
close WRITER;
&main::debug ("(run \"@$command\")\n");
} }
else { else {
open (LOG_SOURCE, "-") or die "unable to open stdin for reading"; open READER, '-' or die "unable to open stdin for reading";
} }
binmode LOG_SOURCE; binmode READER;
XX_Log_Source: XX_Log_Source:
while (<LOG_SOURCE>) { while (<READER>) {
chomp; chomp;
s!\r$!!; s!\r$!!;
@@ -1967,17 +1992,19 @@ sub read_changelog {
# log message texts: # log message texts:
$self->{rev_msg} .= $_ . "\n"; # Normally, just accumulate the message... $self->{rev_msg} .= $_ . "\n"; # Normally, just accumulate the message...
} else { } else {
my $noadd = 0;
if ( ! $self->{rev_msg} if ( ! $self->{rev_msg}
or $self->{rev_msg} =~ /^\s*(\.\s*)?$/ or $self->{rev_msg} =~ /^\s*(\.\s*)?$/
or index($self->{rev_msg}, EMPTY_LOG_MESSAGE) > -1 ) { or index($self->{rev_msg}, EMPTY_LOG_MESSAGE) > -1 ) {
# ... until a msg separator is encountered: # ... until a msg separator is encountered:
# Ensure the message contains something: # Ensure the message contains something:
$self->clear_msg $self->clear_msg, $noadd = 1
if $Prune_Empty_Msgs; if $Prune_Empty_Msgs;
$self->{rev_msg} = "[no log message]\n"; $self->{rev_msg} = "[no log message]\n";
} }
$self->add_file_entry; $self->add_file_entry
unless $noadd;
if ( $_ eq FILE_SEPARATOR ) { if ( $_ eq FILE_SEPARATOR ) {
$self->clear_file; $self->clear_file;
@@ -1987,9 +2014,15 @@ sub read_changelog {
} }
} }
close LOG_SOURCE close READER
or die sprintf("Problem reading log input (exit/signal/core: %d/%d/%d)\n", or die "Couldn't close pipe reader: $!\n";
$? >> 8, $? & 127, $? & 128); if ( defined $pid ) {
my $rv;
waitpid $pid, 0;
0 == $?
or $!=1, die sprintf("Problem reading log input (pid/exit/signal/core: %d/%d/%d/%d)\n",
$pid, $? >> 8, $? & 127, $? & 128);
}
return; return;
} }
@@ -2126,9 +2159,8 @@ sub read_file_path {
($base, undef, undef) = fileparse($path); ($base, undef, undef) = fileparse($path);
my $xpath = $Case_Insensitive ? lc($path) : $path; my $xpath = $Case_Insensitive ? lc($path) : $path;
if ( grep index($path, $_) > -1, @Ignore_Files ) { return
return; if grep $path =~ /$_/, @Ignore_Files;
}
} }
$self->{filename} = $path; $self->{filename} = $path;
@@ -2359,7 +2391,7 @@ sub maybe_grab_accumulation_date {
my $boundary_date; my $boundary_date;
while (<LOG>) while (<LOG>)
{ {
if (/^(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d)/) if (/^(\d\d\d\d-\d\d-\d\d\s+(\w+\s+)?\d\d:\d\d)/)
{ {
$boundary_date = "$1"; $boundary_date = "$1";
last; last;
@@ -2398,7 +2430,7 @@ sub derive_changelog {
my $accumulation_date = maybe_grab_accumulation_date; my $accumulation_date = maybe_grab_accumulation_date;
if ($accumulation_date) { if ($accumulation_date) {
# Insert -d immediately after 'cvs log' # Insert -d immediately after 'cvs log'
my $Log_Date_Command = "-d\'>${accumulation_date}\'"; my $Log_Date_Command = "-d>${accumulation_date}";
my ($log_index) = grep $command->[$_] eq 'log', 0..$#$command; my ($log_index) = grep $command->[$_] eq 'log', 0..$#$command;
splice @$command, $log_index+1, 0, $Log_Date_Command; splice @$command, $log_index+1, 0, $Log_Date_Command;
@@ -2455,6 +2487,7 @@ sub common_path_prefix {
} }
# ------------------------------------- # -------------------------------------
sub parse_options { sub parse_options {
# Check this internally before setting the global variable. # Check this internally before setting the global variable.
my $output_file; my $output_file;
@@ -2604,7 +2637,7 @@ sub parse_options {
) )
or die "options parsing failed\n"; or die "options parsing failed\n";
push @log_source_command, map "'$_'", @ARGV; push @log_source_command, map "$_", @ARGV;
## Check for contradictions... ## Check for contradictions...
@@ -2857,7 +2890,8 @@ times.
=item B<-I> I<REGEXP>, B<--ignore> I<REGEXP> =item B<-I> I<REGEXP>, B<--ignore> I<REGEXP>
Ignore files whose names match I<REGEXP>. This option may be used multiple Ignore files whose names match I<REGEXP>. This option may be used multiple
times. times. The regexp is a perl regular expression. It is matched as is; you may
want to prefix with a ^ or suffix with a $ to anchor the match.
=item B<-C>, B<--case-insensitive> =item B<-C>, B<--case-insensitive>
@@ -3037,6 +3071,14 @@ systems) for more information.
Note that the rules for quoting under windows shells are different. Note that the rules for quoting under windows shells are different.
=item *
To run in an automated environment such as CGI or PHP, suidperl may be needed
in order to execute as the correct user to enable /cvsroot read lock files to
be written for the 'cvs log' command. This is likely just a case of changing
the /usr/bin/perl command to /usr/bin/suidperl, and explicitly declaring the
PATH variable.
=back =back
=head1 EXAMPLES =head1 EXAMPLES
@@ -3098,6 +3140,8 @@ Contributions from
=item Terry Kane =item Terry Kane
=item Pete Kempf
=item Akos Kiss =item Akos Kiss
=item Claus Klein =item Claus Klein
@@ -3120,7 +3164,11 @@ Contributions from
=item Thomas Parmelan =item Thomas Parmelan
=item Johanne Stezenbach =item Jordan Russell
=item Jacek Sliwerski
=item Johannes Stezenbach
=item Joseph Walton =item Joseph Walton
+4 -8
View File
@@ -1,4 +1,3 @@
GNUmakefile
*.0?? *.0??
*.d *.d
*.dat *.dat
@@ -10,15 +9,12 @@ GNUmakefile
*.rel *.rel
*.res *.res
*.pdb *.pdb
*.out
*.upx *.upx
.gdbinit .gdbinit
.Attic GNUmakefile
.deps MMakefile
B
compress_nrv.* compress_nrv.*
upx upx
upx_nrv
upx_nrv.*
upx_ucl
upx_ucl.*
version1*.h version1*.h
version2*.h
+20
View File
@@ -0,0 +1,20 @@
*.0??
*.d
*.dat
*.idb
*.img
*.map
*.raw
*.rc
*.rel
*.res
*.pdb
*.out
*.upx
.gdbinit
GNUmakefile
MMakefile
compress_nrv.*
upx
version1*.h
version2*.h
-42
View File
@@ -1,42 +0,0 @@
ifeq ($(DEPS_DONE),)
DEPS_DONE := 1
# /***********************************************************************
# // automated dependencies
# ************************************************************************/
ifeq ($(DEPMODE),gcc)
EXTRA_CFLAGS += -Wp,-MMD,.deps/$(*F).d
EXTRA_CXXFLAGS += -Wp,-MMD,.deps/$(*F).d
HAVE_DEPS := 1
endif
ifeq ($(DEPMODE),linux-intelc)
EXTRA_CFLAGS += -MMD -MF.deps/$(*F).d
EXTRA_CXXFLAGS += -MMD -MF.deps/$(*F).d
HAVE_DEPS := 1
endif
ifeq ($(DEPMODE),linux-pgi)
## NOTE: -MMD does not work...
EXTRA_CFLAGS += -MD.deps/$(*F).d
EXTRA_CXXFLAGS += -MD.deps/$(*F).d
HAVE_DEPS := 1
endif
ifeq ($(HAVE_DEPS),1)
ifeq ($(strip $(wildcard .deps)),)
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
else
DEPS_FILES := $(wildcard .deps/*.d)
ifneq ($(strip $(DEPS_FILES)),)
include $(DEPS_FILES)
endif
endif
endif
endif # DEPS_DONE
-71
View File
@@ -1,71 +0,0 @@
DEPMODE := gcc
# /***********************************************************************
# // defaults for gcc
# ************************************************************************/
CC = gcc
CXX = g++
CFLAGS_OUTPUT = -o $@
LINK_EXE_OUTPUT = -o $@
CFLAGS_W =
CFLAGS_M =
CFLAGS_O =
CXXFLAGS_W =
CXXFLAGS_M =
CXXFLAGS_O =
CFLAGS = $(call __mkflags,CFLAGS_W) $(call __mkflags,CFLAGS_M) $(call __mkflags,CFLAGS_O)
CXXFLAGS = $(call __mkflags,CXXFLAGS_W) $(call __mkflags,CXXFLAGS_M) $(call __mkflags,CXXFLAGS_O)
#
# cflags
#
##CFLAGS_WERROR = -Werror
CFLAGS_WERROR =
CFLAGS_W = $(CFLAGS_WERROR) -Wall -W -Wbad-function-cast -Wcast-align -Wcast-qual -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wwrite-strings
CXXFLAGS_W = $(CFLAGS_WERROR) -Wall -W -Wcast-align -Wcast-qual -Winline -Woverloaded-virtual -Wpointer-arith -Wshadow -Wsign-promo -Wsynth -Wwrite-strings
##CFLAGS_M += -fno-builtin
##CFLAGS_M += -malign-functions=0 -malign-jumps=0 -malign-loops=0
CXXFLAGS_M = $(CFLAGS_M)
ifeq ($(DEBUG),1)
CFLAGS_O = -g -O0
else
##CFLAGS_O = -Os -fstrict-aliasing
CFLAGS_O = -O2 -fstrict-aliasing
##CFLAGS_O = -O2 -fno-strict-aliasing
endif
CXXFLAGS_O = $(CFLAGS_O) -fconserve-space
##CXXFLAGS += -fasynchronous-exceptions
#
# cxxflags for g++ 3.2 or better
##CXXFLAGS_W += -Wdisabled-optimization -Wpacked
#
# ldflags
#
ifeq ($(DEBUG),1)
LDFLAGS += -g
else
LDFLAGS += -s
endif
LDFLAGS += -Wl,-Map,$T.map
ifeq ($(WITH_ZLIB),1)
LDLIBS += -lz
endif
# vi:nowrap
-48
View File
@@ -1,48 +0,0 @@
UDIR := $($(U)DIR)
ifneq ($(strip $(wildcard $(UDIR)/include)),) # { include
DEFS += -DWITH_$(U)
INCLUDES += -I$(UDIR)/include
ifeq ($(DEBUG),1)
ifneq ($(strip $(wildcard $(UDIR)/build/debug/src/.libs)),)
LIBDIRS += $(UDIR)/build/debug/src/.libs
endif
endif
ifneq ($(strip $(wildcard $(UDIR)/build/$(release)/src/.libs)),)
LIBDIRS += $(UDIR)/build/$(release)/src/.libs
else
ifneq ($(strip $(wildcard $(UDIR)/build/$(target)/src/.libs)),)
LIBDIRS += $(UDIR)/build/$(target)/src/.libs
else
ifneq ($(strip $(wildcard $(UDIR)/src/.libs)),)
LIBDIRS += $(UDIR)/src/.libs
else
ifneq ($(strip $(wildcard $(UDIR)/build/release/src/.libs)),)
LIBDIRS += $(UDIR)/build/release/src/.libs
else
ifneq ($(strip $(wildcard $(UDIR)/build/src/.libs)),)
LIBDIRS += $(UDIR)/build/src/.libs
else
ifneq ($(strip $(wildcard $(UDIR))),)
LIBDIRS += $(UDIR)
DOS_LIBDIRS := $(DOS_LIBDIRS);$(UDIR)
endif
endif
endif
endif
endif
endif
LDLIBS += -l$(u)
DOS_LDLIBS += $(u).lib
DEFS := $(DEFS)
INCLUDES := $(INCLUDES)
LIBDIRS := $(LIBDIRS)
LDLIBS := $(LDLIBS)
DOS_LDLIBS := $(DOS_LDLIBS)
endif # } include
+41 -72
View File
@@ -1,86 +1,55 @@
# #
# UPX Makefile (GNU make) - works with unix/win32/djgpp2 # UPX Makefile - needs GNU make 3.80 or better
#
# usage:
# `make target=linux' # linux
# `make target=dos32-djggp2' # dos32 - djggp2
# `make target=win32-cygwin' # win32 - cygwin
# `make target=win32-mingw32' # win32 - mingw32
# `make target=win32-rsxnt' # win32 - rsxnt
# `make target=win32-bc' # win32 - Borland C++
# `make target=win32-dm' # win32 - Digital Mars C++
# `make target=win32-ic' # win32 - Intel C++
# `make target=win32-vc' # win32 - Visual C++
# `make target=win32-wc' # win32 - Watcom C++
# `make target=cross-amd64-linux' # x86_64-linux cross compiler
# `make target=cross-mingw32' # i586-mingw32msvc cross compiler
# `make target=cross-mint' # m68k-atari-mint cross compiler
# `make target=gcc' # generic gcc
#
# you can also set the `UPX_MAKE_TARGET' environment variable.
# #
MAKEFLAGS += -rR
.SUFFIXES:
export SHELL = /bin/sh
override e = $($1) $(EXTRA_$1) $(upx_$1) $($(basename $(notdir $@)).$1)
# configuration section srcdir ?= $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
ifneq ($(srcdir),./)
ifeq ($(strip $(UCLDIR)),) srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,')
# change this to reflect where the UCL library is ##$(info Info: using VPATH . $(srcdir))
UCLDIR = $(HOME)/local/src/ucl-1.02 VPATH := . $(srcdir)
endif endif
## you can set the default target here ifeq ($(CXX),)
##target = CXX = g++
endif
ifeq ($(CXX),g++)
CXXFLAGS += -O2 -MMD
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wpointer-arith -Wwrite-strings -Werror
endif
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
CXXLD ?= $(CXX)
DEBUG = 0 exeext ?= .out
libext ?= .a
objext ?= .o
srcdir = . # we need UCL and zlib - you can set envvar UCLDIR
top_srcdir = .. ifneq ($(wildcard $(UCLDIR)/include/ucl/ucl.h),)
INCLUDES += -I$(UCLDIR)/include
LIBS += $(addprefix -L,$(dir $(wildcard $(UCLDIR)/libucl$(libext) $(UCLDIR)/src/.libs/libucl$(libext))))
endif
LIBS += -lucl -lz
upx_SOURCES := $(wildcard $(srcdir)/*.cpp)
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
##### You should not have to change anything below this line. ##### all: upx$(exeext)
upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
$($(notdir $@).PRE_LINK_STEP)
$(strip $(CXXLD) $(call e,CPPFLAGS) $(call e,CXXFLAGS) $(call e,LDFLAGS) -o $@ $(upx_OBJECTS) $(call e,LDADD) $(call e,LIBS))
$($(notdir $@).POST_LINK_STEP)
# /*********************************************************************** %.o : %.cpp
# // object files $(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
# ************************************************************************/
# these use exceptions & RTTI mostlyclean clean distclean maintainer-clean:
OBJECTS1 = \ rm -f *.d *.map *.o *.obj *.res upx.exe upx.out upx.ttp upx$(exeext)
compress$o except$o file$o lefile$o \
filter$o linker$o mem$o msg$o stdcxx$o work$o ui$o \
packer$o packerf$o packhead$o packmast$o \
p_com$o p_djgpp2$o p_elks$o p_exe$o \
p_lx_elf$o p_lx_exc$o p_lx_sep$o p_lx_sh$o \
p_ps1$o p_sys$o p_tmt$o p_tos$o \
p_unix$o p_vmlinz$o p_vmlinx$o p_w16ne$o p_w32pe$o p_wcle$o
# no exceptions or RTTI -include *.d
OBJECTS2 = \ .PHONY: all mostlyclean clean distclean maintainer-clean
filteri$o help$o main$o mygetopt$o snprintf$o util$o \
c_init$o c_file$o c_none$o c_screen$o \
s_object$o s_djgpp2$o s_vcsa$o s_win32$o
# pure C sources
OBJECTS3 =
OBJECTS = $(OBJECTS1) $(OBJECTS2) $(OBJECTS3)
LIBS =
RESOURCES =
# /***********************************************************************
# // main
# ************************************************************************/
override WITH_ZLIB = 1
include $(srcdir)/Makefile.bld
# /***********************************************************************
# // dependencies
# ************************************************************************/
include $(srcdir)/Makedefs.dep
# vi:nowrap
-720
View File
@@ -1,720 +0,0 @@
# /***********************************************************************
# // perpare setup
# ************************************************************************/
SHELL = /bin/sh
.SUFFIXES:
.SUFFIXES: .a .c .cpp .exe .lib .o .obj .rc .res .ttp
ifeq ($(srcdir),)
srcdir = .
endif
VPATH = $(srcdir)
# auto-detect the target unless given on the commandline
ifeq ($(strip $(target)),)
# try environment variable UPX_MAKE_TARGET
target := $(UPX_MAKE_TARGET)
endif
ifeq ($(strip $(target)),)
ifneq ($(strip $(wildcard /usr/include/linux)),)
target = linux
endif
##ifneq ($(strip $(wildcard /platform/sun4?/kernel/unix)),)
##target = sparc-sun-solaris
##endif
endif
ifeq ($(strip $(target)),)
include please_specify_a_target
endif
# util var for use in the rules - basename of the current target
override T = $(basename $@)
# expand "VAR" into "$(VAR) $(EXTRA_VAR) $(UPX_EXTRA_VAR)"
override __mkflags = $(strip $($(1)) $(EXTRA_$(1)) $(UPX_EXTRA_$(1)))
# /***********************************************************************
# // compiler defaults
# ************************************************************************/
CC_SRC = $<
CXX_SRC = $<
CC_COMPILE = $(CC) $(CCARCH) $(call __mkflags,DEFS) $(call __mkflags,INCLUDES) $(call __mkflags,CFLAGS) $(CFLAGS_OUTPUT) -c $(CC_SRC)
CXX_COMPILE = $(CXX) $(CXXARCH) $(call __mkflags,DEFS) $(call __mkflags,INCLUDES) $(call __mkflags,CXXFLAGS) $(CXXFLAGS_OUTPUT) -c $(CXX_SRC)
CXX_LINK_EXE = $(CXXLD) $(CXXLDARCH) $(call __mkflags,LDFLAGS) $(LINK_EXE_OUTPUT) $^ $(call __mkflags,LDLIBS)
STUBEDIT_EXE =
STUBIFY_EXE =
CHMOD_EXE =
o = .o
a = .a
e =
DEFS =
INCLUDES =
LIBDIRS =
DOS_LDLIBS =
DOS_LIBDIRS =
# CC defaults
CC = INVALID_TARGET_CC
CCARCH =
CFLAGS =
CFLAGS_OUTPUT =
# CXX defaults
CXX = $(CC)
CXXARCH = $(CCARCH)
CXXFLAGS = $(CFLAGS)
CXXFLAGS_OUTPUT = $(CFLAGS_OUTPUT)
# CXXLD defaults
CXXLD = $(CXX)
CXXLDARCH = $(CXXARCH)
LDFLAGS =
LINK_EXE_OUTPUT =
LDLIBS =
LINK_EXE_LDFLAGS =
ifeq ($(DEBUG),1)
DEFS += -DDEBUG
## DEFS += -DTESTING
endif
# /***********************************************************************
# // compression libraries
# ************************************************************************/
ifeq ($(WITH_ZLIB),1)
DOS_LDLIBS += zlib.lib
ZLIBDIR:=$(strip $(subst \,/,$(ZLIBDIR)))
ifneq ($(strip $(wildcard $(ZLIBDIR))),)
ifneq ($(strip $(wildcard $(ZLIBDIR)/include/zlib.h)),)
INCLUDES += -I$(ZLIBDIR)/include
else
ifneq ($(strip $(wildcard $(ZLIBDIR)/src/zlib.h)),)
INCLUDES += -I$(ZLIBDIR)/src
else
ifneq ($(strip $(wildcard $(ZLIBDIR)/zlib.h)),)
INCLUDES += -I$(ZLIBDIR)
endif
endif
endif
endif
endif
UCLDIR:=$(strip $(subst \,/,$(UCLDIR)))
NRVDIR:=$(strip $(subst \,/,$(NRVDIR)))
u = ucl
U = UCL
upx_exe_tail =
include $(srcdir)/Makedefs.inc
ifneq ($(strip $(wildcard $(NRVDIR)/include/nrv)),)
u = nrv
U = NRV
upx_exe_tail := _$(u)
include $(srcdir)/Makedefs.inc
endif
upx_exe = upx$(upx_exe_tail)$(e)
override tmp := -Wl,--rpath,
LDRPATH := $(addprefix $(tmp),$(LIBDIRS))
LIBDIRS += .
LDLIBDIRS := $(addprefix -L,$(LIBDIRS))
##LDFLAGS += $(LDRPATH)
LDFLAGS += $(LDLIBDIRS)
# /***********************************************************************
# // compiler settings
# ************************************************************************/
###
### generic gcc
###
ifeq ($(target),gcc)
include $(srcdir)/Makedefs.gcc
endif
###
### linux - gcc
###
ifeq ($(target),linux)
include $(srcdir)/Makedefs.gcc
override arch := $(shell uname -m | sed -e 's/^i[3456789]86$$/i386/')
ifeq ($(arch),i386)
CCARCH += -march=i386 -mcpu=i686
endif
DEFS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lmcheck
##CFLAGS_WERROR = -Werror
ifeq ($(DEBUG),1)
else
##LDFLAGS += -static
STUBEDIT_EXE = objcopy -S -R .comment -R .note $@
ifeq ($(arch),i386)
## STUBIFY_EXE = perl $(srcdir)/stub/scripts/brandelf.pl $@
endif
endif
CHMOD_EXE = chmod 755 $@
endif # linux
###
### linux/i386 - Borland C++ 5.7 (Kylix 3)
###
ifeq ($(target),linux-bc57)
##DEPMODE := linux-XXX ## FIXME
CC = bc++ -q -3
CFLAGS = -w '-w!'
CFLAGS_OUTPUT = -o$@
LDFLAGS += -ls
LINK_EXE_OUTPUT = -e$@
ifeq ($(WITH_ZLIB),1)
LDLIBS += -lz
endif
# warning: do not use option `-d' --> incorrect string merging will happen
ifeq ($(DEBUG),1)
CFLAGS += -Od -dc
else
CFLAGS += -O2 -dc
endif
# transform `-lxx -lyy' into `libxx.a libyy.a'
LDLIBS := $(shell echo "$(LDLIBS)" | perl -pe 's/-l(.+?)\b/lib\1.a/g')
endif
###
### linux/i386 - Intel C++
###
ifeq ($(target),linux-intelc)
DEPMODE := linux-intelc
CC = icc
CXX = icpc
CCARCH += -march=i386 -mcpu=i686 -nolib_inline
DEFS += -D_FILE_OFFSET_BITS=64
CFLAGS_OUTPUT = -o $@
LINK_EXE_OUTPUT = -o $@
ifeq ($(WITH_ZLIB),1)
LDLIBS += -lz
endif
CFLAGS = $(CFLAGS_WERROR)
ifeq ($(DEBUG),1)
CFLAGS += -g -O0
else
CFLAGS += -O2
endif
LDFLAGS += -Wl,-Map,$T.map
endif
###
### linux/i386 - Portland Group PGI C++ 5.x
###
ifeq ($(target),linux-pgi)
DEPMODE := linux-pgi
CC = pgcc
CXX = pgCC
CCARCH += -tp=p6
DEFS += -D_FILE_OFFSET_BITS=64
CFLAGS_OUTPUT = -o $@
LINK_EXE_OUTPUT = -o $@
ifeq ($(WITH_ZLIB),1)
LDLIBS += -lz
endif
##CFLAGS += -Minform=info
CXXFLAGS = $(CFLAGS) -tused
ifeq ($(DEBUG),1)
else
CFLAGS += -O2
endif
endif
###
### Linux cross compilers
###
ifeq ($(target),cross-amd64-linux)
include $(srcdir)/Makedefs.gcc
CC = x86_64-linux-gcc
CXX = x86_64-linux-g++
LDLIBS += -lmcheck
endif # cross-amd64-linux
ifeq ($(target),cross-m68k-linux)
include $(srcdir)/Makedefs.gcc
CC = m68k-linux-gcc
CXX = m68k-linux-g++
##LDLIBS += -lmcheck
endif # cross-m68k-linux
###
### sparc-sun-solaris2.8
###
ifeq ($(target),sparc-sun-solaris)
include $(srcdir)/Makedefs.gcc
endif
###
### Atari cross compilers
###
ifeq ($(target),cross-mint)
include $(srcdir)/Makedefs.gcc
e = .ttp
CC = m68k-atari-mint-gcc
CXX = m68k-atari-mint-g++
CCARCH += -m68000
endif
ifeq ($(target),cross-mint-m68040)
include $(srcdir)/Makedefs.gcc
e = .ttp
CC = m68k-atari-mint-gcc
CXX = m68k-atari-mint-g++
CCARCH += -m68040
endif
ifeq ($(target),cross-mint-m68020-60)
include $(srcdir)/Makedefs.gcc
e = .ttp
CC = m68k-atari-mint-gcc
CXX = m68k-atari-mint-g++
CCARCH += -m68020-60 -m68881
endif
###
### dos32 - djgpp2 / emx
###
ifeq ($(target),dos32-djgpp2)
include $(srcdir)/Makedefs.gcc
e = .exe
CXX = gxx
CCARCH += -march=i386 -mcpu=i686
CFLAGS_WERROR = -Werror
STUBEDIT_EXE = stubedit $@ bufsize=0xfc00
ifneq ($(strip $(wildcard $(DJDIR)/bin/mfxdjstubify.ex[eE])),)
ifneq ($(strip $(wildcard $(DJDIR)/bin/cwsdstub.ex[eE])),)
STUBIFY_EXE = mfxdjstubify -v -s $(DJDIR)/bin/cwsdstub.exe $@
endif
endif
endif
ifeq ($(target),dos32-emx)
include $(srcdir)/Makedefs.gcc
e = .exe
CXX = gcc
CFLAGS_O = -O2
CCARCH += -mno-probe
LDFLAGS = -L. -s
endif
###
### win32 - cygwin / mingw32 / rsxnt
###
ifeq ($(target),win32-cygwin)
include $(srcdir)/Makedefs.gcc
##CXX = g++-2
e = .exe
CCARCH += -march=i386 -mcpu=i686
LDLIBS += -lwinmm
endif
ifeq ($(target),win32-mingw32)
include $(srcdir)/Makedefs.gcc
e = .exe
CCARCH += -march=i386 -mcpu=i686
LDLIBS += -lwinmm
endif
# mingw32 cross compiler
ifeq ($(target),cross-mingw32)
include $(srcdir)/Makedefs.gcc
e = .exe
CC = i586-mingw32msvc-gcc
CXX = i586-mingw32msvc-g++
CCARCH += -march=i386 -mcpu=i686
LDLIBS += -lwinmm
endif
# rsxnt (g++ 2.8.1)
ifeq ($(target),win32-rsxnt)
include $(srcdir)/Makedefs.gcc
e = .exe
CXX = gcc
CFLAGS_O = -O2
CCARCH += -Zwin32 -Zsys -mno-probe
LDFLAGS = -L. -s
STUBEDIT_EXE = pestack -s1024 -c1024 $@
endif
###
### win32 - Borland C++
###
ifeq ($(target),win32-bc)
o = .obj
a = .lib
e = .exe
CC = bcc32 -3
ifeq ($(UPX_BROKEN_INCLUDES),1)
ifneq ($(srcdir),.)
INCLUDES += -I$(srcdir)
endif
INCLUDES += -I$(srcdir)/acc
ifneq ($(strip $(wildcard $(srcdir)/filter)),)
INCLUDES += -I$(srcdir)/filter
endif
endif
CFLAGS = -w -w-inl -g1
CFLAGS_OUTPUT = -o$@
LDFLAGS = -ls
LINK_EXE_OUTPUT = -e$@
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -Od -d
else
CFLAGS += -O2 -d
endif
endif # win32-bc
###
### win32 - Digital Mars C++
###
ifeq ($(target),win32-dm)
o = .obj
a = .lib
e = .exe
CC = dmc -mn
CFLAGS = -w- -wx
CXXFLAGS = $(CFLAGS) -Aa -Ab -Ae -Ar
CFLAGS_OUTPUT = -o$@
LDFLAGS = -L/map
LINK_EXE_OUTPUT = -o$@
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -o- -g -s
else
CFLAGS += -o
endif
endif # win32-dm
###
### win32 - Intel C++
###
ifeq ($(target),win32-ic)
o = .obj
a = .lib
e = .exe
CC = icl -nologo
CFLAGS = -W3 -WX
CXXFLAGS = $(CFLAGS) -EHac -GR
LDFLAGS =
LINK_EXE_OUTPUT = -Fe$@
LINK_EXE_LDFLAGS = /link /map:$T.map
##LINK_EXE_LDFLAGS += /verbose
ifeq (1,2)
# statically link libcmt.lib
CC += -MT
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
else
# link against msvcrt.dll
CC += -MD
endif
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -Od -ZI
LINK_EXE_LDFLAGS += /debug
else
CFLAGS += -O1 -GF
LINK_EXE_LDFLAGS += /release
endif
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
endif # win32-ic
###
### win32 - Metrowerks C++
###
ifeq ($(target),win32-mwerks)
o = .obj
a = .lib
e = .exe
CC = mwcc -gccinc
CFLAGS = -w on
CXXFLAGS = $(CFLAGS)
CFLAGS_OUTPUT = -o $@
LDFLAGS = -lwinmm.lib -map $T.map
LINK_EXE_OUTPUT = -o $@
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -opt full
else
CFLAGS +=
endif
endif # win32-mwerks
###
### win32 - Symantec C++
###
ifeq ($(target),win32-sc)
o = .obj
a = .lib
e = .exe
CC = sc -mn
CFLAGS = -w- -wx
CXXFLAGS = $(CFLAGS) -EH -ER
CFLAGS_OUTPUT = -o$@
LDFLAGS = -L/map
LINK_EXE_OUTPUT = -o$@
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -o- -g -s
else
CFLAGS += -o
endif
endif # win32-sc
###
### win32 - Visual C++
###
ifeq ($(target),win32-vc)
o = .obj
a = .lib
e = .exe
CC = cl -nologo
CFLAGS = -W4 -WX
CXXFLAGS = $(CFLAGS) -EHac -GR
LDFLAGS =
LINK_EXE_OUTPUT = -Fe$@
LINK_EXE_LDFLAGS = /link /map:$T.map
##LINK_EXE_LDFLAGS += /verbose
ifeq (1,1)
# statically link libcmt.lib
CC += -MT
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
else
# link against msvcrt.dll
CC += -MD
endif
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -Od -ZI
LINK_EXE_LDFLAGS += /debug
else
CFLAGS += -O1 -GF
LINK_EXE_LDFLAGS += /release
##LINK_EXE_LDFLAGS += /opt:nowin98
endif
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
endif # win32-vc
###
### win32 - Watcom C++
###
ifeq ($(target),win32-wc)
o = .obj
a = .lib
e = .exe
CC = wcl386 -zq -bt=nt -mf -5r
##CC = wcl386 -zq -bt=dos -l=CauseWay -mf -5r
CFLAGS = -zc -w5 -we
CXXFLAGS = $(CFLAGS) -xs -xr
CFLAGS_OUTPUT = -fo=$@
LDFLAGS = -k0x100000 -fm
LINK_EXE_OUTPUT = -fe=$@
LDLIBS = $(DOS_LDLIBS)
CC_SRC = $(subst /,\\,$<)
CXX_SRC = $(subst /,\\,$<)
INCLUDES := $(strip $(subst /,\\,$(INCLUDES)))
ifeq (1,2)
WCL386 := $(INCLUDES)
export WCL386
INCLUDES :=
endif
ifeq ($(DEBUG),1)
CFLAGS +=
else
# note: it seems that the optimizer is generating bad code with `-ox'
CFLAGS += -olr
endif
endif # win32-wc
###
### win64 - Intel C++ [Itanium]
###
ifeq ($(target),win64-ic)
o = .obj
a = .lib
e = .exe
CC = ecl -nologo
CFLAGS = -W3
CXXFLAGS = $(CFLAGS) -EHac -GR
LDFLAGS =
LINK_EXE_OUTPUT = -Fe$@
LINK_EXE_LDFLAGS = /link /map:$T.map
##LINK_EXE_LDFLAGS += /verbose
ifeq (1,2)
# statically link libcmt.lib
CC += -MT
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
else
# link against msvcrt.dll
CC += -MD
endif
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -Od -ZI
LINK_EXE_LDFLAGS += /debug
else
CFLAGS += -O1 -GF
LINK_EXE_LDFLAGS += /release
endif
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
endif # win64-ic
###
### win64 - Visual C++ [AMD64 or Itanium]
###
ifeq ($(target),win64-vc)
o = .obj
a = .lib
e = .exe
CC = cl -nologo
CFLAGS = -W4 -Wall
CXXFLAGS = $(CFLAGS) -EHac -GR
LDFLAGS =
LINK_EXE_OUTPUT = -Fe$@
LINK_EXE_LDFLAGS = /link /map:$T.map
##LINK_EXE_LDFLAGS += /verbose
ifeq (1,1)
# statically link libcmt.lib
CC += -MT
## DOS_LDLIBS := $(DOS_LDLIBS:.lib=_ml.lib)
else
# link against msvcrt.dll
CC += -MD
endif
LDLIBS = $(DOS_LDLIBS)
ifeq ($(DEBUG),1)
CFLAGS += -Od -ZI
LINK_EXE_LDFLAGS += /debug
else
CFLAGS += -O1 -GF
LINK_EXE_LDFLAGS += /release
endif
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
endif # win64-vc
# /***********************************************************************
# // malloc debuggers and memory checkers - obsolete, use valgrind
# ************************************************************************/
ifeq (1,2)
# compile in extra valgrind support
DEFS += -DWITH_VALGRIND
endif
ifeq (1,2)
LDLIBS += -lefence
endif
ifeq (1,2)
DEFS += -DWITH_DMALLOC
LDLIBS += -ldmalloc
endif
ifeq (1,2)
DEFS += -DWITH_GC -DLINUX_THREADS -D_REENTRANT
LDLIBS += -lgc -lpthread
# only needed when using -static:
##LDFLAGS += -Wl,-defsym,_DYNAMIC=0
endif
# /***********************************************************************
# // main targets
# ************************************************************************/
-include ./Makefile.local
all: $(upx_exe)
$(upx_exe): $(OBJECTS) $(LIBS) $(RESOURCES)
$(strip $(CXX_LINK_EXE))
$(strip $(STUBEDIT_EXE))
$(strip $(STUBIFY_EXE))
$(strip $(CHMOD_EXE))
mostlyclean:
-rm -f *.d *.err *.i *.log *.map gdb-trans*
clean: mostlyclean
-rm -f *.a *.lib *.o *.obj *.res *.tds tags TAGS ID
-rm -f *.idb *.pdb
-rm -f $(upx_exe) upx upx.exe upx.ttp upx_nrv upx_nrv.exe upx_nrv.ttp upx_ucl upx_ucl.exe upx_ucl.ttp
-rm -rf .deps _deps
distclean: clean
maintainer-clean: distclean
.PHONY: all mostlyclean clean distclean maintainer-clean
# /***********************************************************************
# // rules
# ************************************************************************/
%$o : %.c
$(strip $(CC_COMPILE))
%$o : %.cpp
$(strip $(CXX_COMPILE))
%.res : %.rc
rc -l 0x409 -fo$@ $<
# vi:nowrap
-1
View File
@@ -1 +0,0 @@
GNUmakefile
-340
View File
@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
-94
View File
@@ -1,94 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*
* Possible configuration values:
*
* ACC_CONFIG_NO_HEADER
* ACC_CONFIG_HEADER if given, then use this as <config.h>
* ACC_CONFIG_INCLUDE include path to acc_ files
*
* ACC_CONFIG_PREFER___INT64 [acc_type.h]
*/
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED 1
#define ACC_VERSION 20040715L
#if !defined(ACC_CONFIG_INCLUDE)
# define ACC_CONFIG_INCLUDE(file) file
#endif
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
# define __CYGWIN__ __CYGWIN32__
#endif
#if defined(__IBMCPP__) && !defined(__IBMC__)
# define __IBMC__ __IBMCPP__
#endif
#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
# define __INTEL_COMPILER __ICL
#endif
#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
# define _ALL_SOURCE 1
#endif
/* disable pedantic warnings for undefined preprocessing symbols */
#if defined(__INTEL_COMPILER) && defined(__linux__)
# pragma warning(disable: 193)
#endif
#if defined(__KEIL__) && defined(__C166__)
# pragma warning disable = 322
#elif 0 && defined(__C251__)
# pragma warning disable = 322
#endif
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
# if (_MSC_VER >= 1300)
# pragma warning(disable: 4668)
# endif
#endif
#if 0 && defined(__WATCOMC__)
# if (__WATCOMC__ < 1060)
# pragma warning 203 9
# endif
#endif
#include <limits.h>
#include ACC_CONFIG_INCLUDE("acc_init.h")
#include ACC_CONFIG_INCLUDE("acc_os.h")
#include ACC_CONFIG_INCLUDE("acc_cc.h")
#include ACC_CONFIG_INCLUDE("acc_arch.h")
#include ACC_CONFIG_INCLUDE("acc_mm.h")
#include ACC_CONFIG_INCLUDE("acc_defs.h")
#if defined(ACC_CONFIG_NO_HEADER)
#elif defined(ACC_CONFIG_HEADER)
# include ACC_CONFIG_HEADER
#else
# include ACC_CONFIG_INCLUDE("acc_auto.h")
#endif
#include ACC_CONFIG_INCLUDE("acc_type.h")
#endif /* already included */
/*
vi:ts=4:et
*/
-124
View File
@@ -1,124 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*
* CPU architecture - exactly one of:
*
* ACC_ARCH_UNKNOWN [default]
* ACC_ARCH_ALPHA
* ACC_ARCH_AMD64 aka x86-64 or ia32e
* ACC_ARCH_C166
* ACC_ARCH_IA16 Intel Architecture (8088, 8086, 80186, 80286)
* ACC_ARCH_IA32 Intel Architecture (80386+)
* ACC_ARCH_IA64 Intel Architecture (Itanium)
* ACC_ARCH_M68K Motorola 680x0
* ACC_ARCH_MCS251
* ACC_ARCH_MCS51
* ACC_ARCH_PPC64 Power PC
* ACC_ARCH_SPARC64
*
* Optionally define one of:
* ACC_ENDIAN_LITTLE_ENDIAN
* ACC_ENDIAN_BIG_ENDIAN
*
* Note that this list is not exhaustive - actually we only really care
* about architectures which allow unaligned memory access at reasonable
* speed (for the moment this means IA16, IA32 and AMD64).
*/
#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
# define ACC_ARCH_IA16 1
# define ACC_INFO_ARCH "ia16"
#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
# define ACC_ARCH_AMD64 1
# define ACC_INFO_ARCH "amd64"
#elif (UINT_MAX <= ACC_0xffffL) && defined(__AVR__)
# define ACC_ARCH_AVR 1
# define ACC_INFO_ARCH "avr"
#elif (UINT_MAX == ACC_0xffffL) && defined(__C166__)
# define ACC_ARCH_C166 1
# define ACC_INFO_ARCH "c166"
#elif (UINT_MAX == ACC_0xffffL) && defined(__C251__)
# define ACC_ARCH_MCS251 1
# define ACC_INFO_ARCH "mcs-251"
#elif (UINT_MAX == ACC_0xffffL) && defined(__C51__)
# define ACC_ARCH_MCS51 1
# define ACC_INFO_ARCH "mcs-51"
#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
# define ACC_ARCH_IA32 1
# define ACC_INFO_ARCH "ia32"
#elif (ACC_CC_ZORTECHC && defined(__I86__))
# define ACC_ARCH_IA32 1
# define ACC_INFO_ARCH "ia32"
#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
# define ACC_ARCH_IA64 1
# define ACC_INFO_ARCH "ia64"
#elif (ACC_OS_DOS32 && ACC_CC_HIGHC) && defined(_I386)
# define ACC_ARCH_IA32 1
# define ACC_INFO_ARCH "ia32"
#elif (ACC_OS_DOS32 || ACC_OS_OS2)
# error "missing define for CPU architecture"
#elif (ACC_OS_WIN32)
# error "missing define for CPU architecture"
#elif (ACC_OS_WIN64)
/* # error "missing define for CPU architecture" */
#elif (ACC_OS_TOS) || defined(__m68000__)
# define ACC_ARCH_M68K 1
# define ACC_INFO_ARCH "m68k"
#elif defined(__alpha__) || defined(__alpha)
# define ACC_ARCH_ALPHA 1
# define ACC_INFO_ARCH "alpha"
#elif defined(__ppc64__) || defined(__ppc64)
# define ACC_ARCH_PPC64 1
# define ACC_INFO_ARCH "ppc64"
#elif defined(__sparc64__) || defined(__sparc64)
# define ACC_ARCH_SPARC64 1
# define ACC_INFO_ARCH "sparc64"
#else
# define ACC_ARCH_UNKNOWN 1
# define ACC_INFO_ARCH "unknown"
#endif
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA16 || ACC_ARCH_IA32)
# define ACC_ENDIAN_LITTLE_ENDIAN 1
# define ACC_INFO_ENDIAN "little-endian"
#elif (ACC_ARCH_M68K)
# define ACC_ENDIAN_BIG_ENDIAN 1
# define ACC_INFO_ENDIAN "big-endian"
#endif
#if (ACC_ARCH_IA16)
# if (UINT_MAX != ACC_0xffffL)
# error "this should not happen"
# endif
# if (ULONG_MAX != ACC_0xffffffffL)
# error "this should not happen"
# endif
#endif
#if (ACC_ARCH_IA32)
# if (UINT_MAX != ACC_0xffffffffL)
# error "this should not happen"
# endif
# if (ULONG_MAX != ACC_0xffffffffL)
# error "this should not happen"
# endif
#endif
/*
vi:ts=4:et
*/
-660
View File
@@ -1,660 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*
* Possible configuration values:
*
* ACC_CONFIG_AUTO_NO_HEADERS
* ACC_CONFIG_AUTO_NO_FUNCTIONS
* ACC_CONFIG_AUTO_NO_SIZES
*/
/*************************************************************************
// Checks for <stdint.h>
**************************************************************************/
#if !defined(ACC_CONFIG_AUTO_NO_HEADERS)
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
# if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1))
# define HAVE_STDINT_H 1
# endif
#elif defined(__dietlibc__)
# undef HAVE_STDINT_H /* incomplete */
#elif (ACC_CC_BORLANDC) && (__BORLANDC__ >= 0x560)
# undef HAVE_STDINT_H /* broken & incomplete */
#elif (ACC_CC_DMC) && (__DMC__ >= 0x825)
# define HAVE_STDINT_H 1
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#endif /* !defined(ACC_CONFIG_AUTO_NO_HEADERS) */
/*************************************************************************
// Checks for header files
**************************************************************************/
#if !defined(ACC_CONFIG_AUTO_NO_HEADERS)
#define STDC_HEADERS 1
#define HAVE_ASSERT_H 1
#define HAVE_CTYPE_H 1
#define HAVE_DIRENT_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MEMORY_H 1
#define HAVE_SETJMP_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_UTIME_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#undef HAVE_ALLOCA_H
#undef HAVE_CONIO_H
#undef HAVE_DIRECT_H
#undef HAVE_DOS_H
#undef HAVE_IO_H
#undef HAVE_SHARE_H
#undef HAVE_STDINT_H
#undef HAVE_STRINGS_H
#undef HAVE_SYS_UTIME_H
#if (ACC_OS_POSIX)
# define HAVE_STRINGS_H 1
# if (ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_MACOSX || ACC_OS_POSIX_OPENBSD)
# undef HAVE_MALLOC_H /* deprecated */
# elif (ACC_OS_POSIX_HPUX || ACC_OS_POSIX_INTERIX)
# define HAVE_ALLOCA_H 1
# endif
# if (ACC_OS_POSIX_MACOSX && ACC_CC_MWERKS) && defined(__MSL__)
/* FIXME ??? */
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H
# endif
#elif (ACC_OS_CYGWIN)
# define HAVE_IO_H 1
#elif (ACC_OS_EMX)
# define HAVE_ALLOCA_H 1
# define HAVE_IO_H 1
#elif (ACC_OS_TOS && ACC_CC_GNUC)
# if !defined(__MINT__)
# undef HAVE_MALLOC_H
# endif
#elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
# undef HAVE_DIRENT_H
# undef HAVE_FCNTL_H
# undef HAVE_MALLOC_H
# undef HAVE_MEMORY_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_STAT_H
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H
#endif
/* DOS, OS/2 & Windows */
#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
#define HAVE_CONIO_H 1
#define HAVE_DIRECT_H 1
#define HAVE_DOS_H 1
#define HAVE_IO_H 1
#define HAVE_SHARE_H 1
#if (ACC_CC_AZTECC)
# undef HAVE_CONIO_H
# undef HAVE_DIRECT_H
# undef HAVE_DIRENT_H
# undef HAVE_MALLOC_H
# undef HAVE_SHARE_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_STAT_H
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H
#elif (ACC_CC_BORLANDC)
# undef HAVE_UNISTD_H
# undef HAVE_SYS_TIME_H
# if (ACC_OS_WIN32 || ACC_OS_WIN64)
# undef HAVE_DIRENT_H /* pulls in <windows.h>; use <dir.h> instead */
# endif
# if (__BORLANDC__ < 0x0400)
# undef HAVE_DIRENT_H
# undef HAVE_UTIME_H
# endif
#elif (ACC_CC_DMC)
# undef HAVE_DIRENT_H /* not working */
# undef HAVE_UNISTD_H /* not working */
# define HAVE_SYS_DIRENT_H 1
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
#elif (ACC_OS_DOS32 && ACC_CC_HIGHC)
# define HAVE_ALLOCA_H 1
# undef HAVE_DIRENT_H
# undef HAVE_UNISTD_H
#elif (ACC_CC_IBMC && ACC_OS_OS2)
# undef HAVE_DOS_H
# undef HAVE_DIRENT_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
# define HAVE_SYS_UTIME_H 1
#elif (ACC_CC_INTELC || ACC_CC_MSC)
# undef HAVE_DIRENT_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
# define HAVE_SYS_UTIME_H 1
#elif (ACC_CC_LCC)
# undef HAVE_DIRENT_H
# undef HAVE_DOS_H
# undef HAVE_SYS_TIME_H
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__MINGW32__)
# undef HAVE_UTIME_H
# define HAVE_SYS_UTIME_H 1
#elif (ACC_OS_WIN32 && ACC_CC_MWERKS) && defined(__MSL__)
# define HAVE_ALLOCA_H 1
# undef HAVE_DOS_H
# undef HAVE_SHARE_H
# undef HAVE_SYS_TIME_H
#elif (ACC_CC_NDPC)
# undef HAVE_DIRENT_H
# undef HAVE_DOS_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
#elif (ACC_CC_PACIFICC)
# undef HAVE_DIRECT_H
# undef HAVE_DIRENT_H
# undef HAVE_FCNTL_H
# undef HAVE_IO_H
# undef HAVE_MALLOC_H
# undef HAVE_MEMORY_H
# undef HAVE_SHARE_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_STAT_H
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H
#elif (ACC_OS_WIN32 && ACC_CC_PELLESC)
# undef HAVE_DIRENT_H
# undef HAVE_DOS_H
# undef HAVE_MALLOC_H
# undef HAVE_SHARE_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
# if (__POCC__ < 280)
# else
# define HAVE_SYS_UTIME_H 1
# endif
#elif (ACC_OS_WIN32 && ACC_CC_PGI) && defined(__MINGW32__)
# undef HAVE_UTIME_H
# define HAVE_SYS_UTIME_H 1
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
#elif (ACC_CC_SYMANTECC)
# undef HAVE_DIRENT_H /* opendir() not implemented in libc */
# undef HAVE_UNISTD_H /* not working */
# if (__SC__ < 0x700)
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
# endif
#elif (ACC_CC_TOPSPEEDC)
# undef HAVE_DIRENT_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_STAT_H
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H
#elif (ACC_CC_TURBOC)
# undef HAVE_UNISTD_H
# undef HAVE_SYS_TIME_H
# undef HAVE_SYS_TYPES_H /* useless */
# if (ACC_OS_WIN32 || ACC_OS_WIN64)
# undef HAVE_DIRENT_H /* pulls in <windows.h>; use <dir.h> instead */
# endif
# if (__TURBOC__ < 0x0200)
# undef HAVE_SIGNAL_H /* not working */
# endif
# if (__TURBOC__ < 0x0400)
# undef HAVE_DIRECT_H
# undef HAVE_DIRENT_H
# undef HAVE_MALLOC_H
# undef HAVE_MEMORY_H
# undef HAVE_UTIME_H
# endif
#elif (ACC_CC_WATCOMC)
# undef HAVE_DIRENT_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
# define HAVE_SYS_UTIME_H 1
# if (__WATCOMC__ < 950)
# undef HAVE_UNISTD_H
# endif
#elif (ACC_CC_ZORTECHC)
# undef HAVE_DIRENT_H
# undef HAVE_MEMORY_H
# undef HAVE_UNISTD_H
# undef HAVE_UTIME_H
# undef HAVE_SYS_TIME_H
#endif
#endif /* DOS, OS/2 & Windows */
#if (HAVE_SYS_TIME_H && HAVE_TIME_H)
# define TIME_WITH_SYS_TIME 1
#endif
#endif /* !defined(ACC_CONFIG_AUTO_NO_HEADERS) */
/*************************************************************************
// Checks for library functions
**************************************************************************/
#if !defined(ACC_CONFIG_AUTO_NO_FUNCTIONS)
#define HAVE_ACCESS 1
#define HAVE_ALLOCA 1
#define HAVE_ATEXIT 1
#define HAVE_ATOI 1
#define HAVE_ATOL 1
#define HAVE_CHMOD 1
#define HAVE_CHOWN 1
#define HAVE_CTIME 1
#define HAVE_DIFFTIME 1
#define HAVE_FILENO 1
#define HAVE_FSTAT 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_GMTIME 1
#define HAVE_LOCALTIME 1
#define HAVE_LONGJMP 1
#define HAVE_LSTAT 1
#define HAVE_MEMCMP 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMSET 1
#define HAVE_MKTIME 1
#define HAVE_QSORT 1
#define HAVE_RAISE 1
#define HAVE_SETJMP 1
#define HAVE_SIGNAL 1
#define HAVE_SNPRINTF 1
#define HAVE_STAT 1
#define HAVE_STRCHR 1
#define HAVE_STRDUP 1
#define HAVE_STRERROR 1
#define HAVE_STRFTIME 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_TIME 1
#define HAVE_UMASK 1
#define HAVE_UTIME 1
#define HAVE_VSNPRINTF 1
#if (ACC_OS_BEOS || ACC_OS_CYGWIN || ACC_OS_POSIX || ACC_OS_QNX)
# define HAVE_STRCASECMP 1
# define HAVE_STRNCASECMP 1
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
# define HAVE_STRCASECMP 1
# define HAVE_STRNCASECMP 1
#else
# define HAVE_STRICMP 1
# define HAVE_STRNICMP 1
#endif
#if (ACC_OS_POSIX)
# if (ACC_CC_TINYC)
# undef HAVE_ALLOCA
# elif defined(__dietlibc__)
# endif
# if (ACC_OS_POSIX_MACOSX && ACC_CC_MWERKS) && defined(__MSL__)
/* FIXME ??? */
# undef HAVE_CHOWN
# undef HAVE_LSTAT
# endif
#elif (ACC_OS_CYGWIN)
# if (ACC_CC_GNUC < 0x025a00ul)
# undef HAVE_GETTIMEOFDAY
# undef HAVE_LSTAT
# endif
# if (ACC_CC_GNUC < 0x025f00ul)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# endif
#elif (ACC_OS_EMX)
# undef HAVE_CHOWN
# undef HAVE_LSTAT
#elif (ACC_OS_TOS && ACC_CC_GNUC)
# if !defined(__MINT__)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# endif
#elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
# undef HAVE_ALLOCA
# undef HAVE_ACCESS
# undef HAVE_CHMOD
# undef HAVE_CHOWN
# undef HAVE_FSTAT
# undef HAVE_GETTIMEOFDAY
# undef HAVE_LSTAT
# undef HAVE_SNPRINTF
# undef HAVE_UMASK
# undef HAVE_UTIME
# undef HAVE_VSNPRINTF
#endif
/* DOS, OS/2 & Windows */
#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
#undef HAVE_CHOWN
#undef HAVE_GETTIMEOFDAY
#undef HAVE_LSTAT
#undef HAVE_UMASK
#if (ACC_CC_AZTECC)
# undef HAVE_ALLOCA
# undef HAVE_DIFFTIME /* difftime() is in the math library */
# undef HAVE_FSTAT
# undef HAVE_STRDUP /* missing in 5.2a */
# undef HAVE_SNPRINTF
# undef HAVE_UTIME /* struct utimbuf is missing */
# undef HAVE_VSNPRINTF
#elif (ACC_CC_BORLANDC)
# if (__BORLANDC__ < 0x0400)
# undef HAVE_ALLOCA
# undef HAVE_UTIME
# endif
# if ((__BORLANDC__ < 0x0410) && ACC_OS_WIN16)
# undef HAVE_ALLOCA
# endif
# if (__BORLANDC__ < 0x0550)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# endif
#elif (ACC_CC_DMC)
# if (ACC_OS_WIN16)
# undef HAVE_ALLOCA
# endif
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_OS_DOS32 && ACC_CC_HIGHC)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_CC_IBMC)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_CC_INTELC)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#elif (ACC_CC_LCC)
# define utime _utime
#elif (ACC_CC_MSC)
# if (_MSC_VER < 600)
# undef HAVE_STRFTIME
# endif
# if (_MSC_VER < 700)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# else
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
# if ((_MSC_VER < 800) && ACC_OS_WIN16)
# undef HAVE_ALLOCA
# endif
# if (ACC_ARCH_IA16) && defined(__cplusplus)
# undef HAVE_LONGJMP
# undef HAVE_SETJMP
# endif
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__MINGW32__)
# if (ACC_CC_GNUC < 0x025f00ul)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# else
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
#elif (ACC_OS_WIN32 && ACC_CC_MWERKS) && defined(__MSL__)
# if (__MSL__ < 0x8000ul)
# undef HAVE_CHMOD /* <unix.h> which in turn pulls in <windows.h> */
# endif
#elif (ACC_CC_NDPC)
# undef HAVE_ALLOCA
# undef HAVE_SNPRINTF
# undef HAVE_STRNICMP
# undef HAVE_UTIME
# undef HAVE_VSNPRINTF
# if defined(__cplusplus)
# undef HAVE_STAT
# endif
#elif (ACC_CC_PACIFICC)
# undef HAVE_ACCESS
# undef HAVE_ALLOCA
# undef HAVE_CHMOD
# undef HAVE_DIFFTIME
# undef HAVE_FSTAT
# undef HAVE_MKTIME
# undef HAVE_RAISE
# undef HAVE_SNPRINTF
# undef HAVE_STRFTIME
# undef HAVE_UTIME
# undef HAVE_VSNPRINTF
#elif (ACC_OS_WIN32 && ACC_CC_PELLESC)
# if (__POCC__ < 280)
# define alloca _alloca
# undef HAVE_UTIME
# endif
#elif (ACC_OS_WIN32 && ACC_CC_PGI) && defined(__MINGW32__)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_CC_SYMANTECC)
# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE))
# undef HAVE_ALLOCA
# endif
# if (__SC__ < 0x600)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# else
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
# if (__SC__ < 0x700)
# undef HAVE_DIFFTIME /* difftime() is broken */
# undef HAVE_UTIME /* struct utimbuf is missing */
# endif
#elif (ACC_CC_TOPSPEEDC)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
#elif (ACC_CC_TURBOC)
# undef HAVE_ALLOCA
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# if (__TURBOC__ < 0x0200)
# undef HAVE_RAISE
# undef HAVE_SIGNAL
# endif
# if (__TURBOC__ < 0x0295)
# undef HAVE_MKTIME
# undef HAVE_STRFTIME
# endif
# if (__TURBOC__ < 0x0400)
# undef HAVE_UTIME
# endif
#elif (ACC_CC_WATCOMC)
# if (__WATCOMC__ < 1100)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# elif (__WATCOMC__ < 1200)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
#elif (ACC_CC_ZORTECHC)
# if (ACC_OS_WIN16 && (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE))
# undef HAVE_ALLOCA
# endif
# undef HAVE_DIFFTIME /* difftime() is broken */
# undef HAVE_SNPRINTF
# undef HAVE_UTIME /* struct utimbuf is missing */
# undef HAVE_VSNPRINTF
#endif
#endif /* DOS, OS/2 & Windows */
#endif /* !defined(ACC_CONFIG_AUTO_NO_FUNCTIONS) */
/*************************************************************************
// Checks for sizes
**************************************************************************/
#if !defined(ACC_CONFIG_AUTO_NO_SIZES)
#define SIZEOF_SHORT (__ACC_SHORT_BIT / 8)
#define SIZEOF_INT (__ACC_INT_BIT / 8)
#define SIZEOF_LONG (__ACC_LONG_BIT / 8)
#if (ACC_OS_WIN64) /* LLP64 programming model */
# define SIZEOF_PTRDIFF_T 8
# define SIZEOF_SIZE_T 8
# define SIZEOF_VOID_P 8
#elif (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
# define SIZEOF_SIZE_T 2
# if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
# define SIZEOF_VOID_P 2
# elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
# define SIZEOF_VOID_P 4
# else
# error "ACC_MM"
# endif
# if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
# define SIZEOF_PTRDIFF_T 2
# elif (ACC_MM_COMPACT || ACC_MM_LARGE)
# if (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# define SIZEOF_PTRDIFF_T 4
# else
# define SIZEOF_PTRDIFF_T 2
# endif
# elif (ACC_MM_HUGE)
# define SIZEOF_PTRDIFF_T 4
# else
# error "ACC_MM"
# endif
#elif (ACC_ARCH_AVR || ACC_ARCH_C166 || ACC_ARCH_MCS51 || ACC_ARCH_MCS251)
# define SIZEOF_PTRDIFF_T 2
# define SIZEOF_SIZE_T 2
# define SIZEOF_VOID_P 2
#else
# define SIZEOF_PTRDIFF_T SIZEOF_LONG
# define SIZEOF_SIZE_T SIZEOF_LONG
# define SIZEOF_VOID_P SIZEOF_LONG
#endif
#if !defined(SIZEOF_CHAR_P) && (SIZEOF_VOID_P > 0)
# define SIZEOF_CHAR_P SIZEOF_VOID_P
#endif
#if ((SIZEOF_LONG) > 0 && (SIZEOF_LONG) < 8)
#if (ACC_ARCH_IA16 && ACC_CC_DMC)
#elif (ACC_CC_GNUC)
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#elif ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MSC && (_MSC_VER >= 1400))
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#elif (ACC_OS_WIN64)
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif (ACC_ARCH_IA32 && (ACC_CC_DMC))
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#elif (ACC_ARCH_IA32 && (ACC_CC_SYMANTECC && (__SC__ >= 0x700)))
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#elif (ACC_ARCH_IA32 && (ACC_CC_INTELC && defined(__linux__)))
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#elif (ACC_ARCH_IA32 && (ACC_CC_MWERKS || ACC_CC_PELLESC || ACC_CC_PGI))
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#elif (ACC_ARCH_IA32 && (ACC_CC_INTELC || ACC_CC_MSC))
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif (ACC_ARCH_IA32 && (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
/* INFO: unsigned __int64 is somewhat broken in 0x0520; fixed in 0x0530 */
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif (ACC_ARCH_IA32 && (ACC_CC_WATCOMC && (__WATCOMC__ >= 1100)))
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif (ACC_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
# define SIZEOF___INT64 8
# define SIZEOF_UNSIGNED___INT64 8
#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define SIZEOF_LONG_LONG 8
# define SIZEOF_UNSIGNED_LONG_LONG 8
#endif
#endif
#if defined(__cplusplus) && defined(ACC_CC_GNUC)
# if (ACC_CC_GNUC < 0x020800ul)
# undef SIZEOF_LONG_LONG
# undef SIZEOF_UNSIGNED_LONG_LONG
# endif
#endif
#endif /* !defined(ACC_CONFIG_AUTO_NO_SIZES) */
/*************************************************************************
// misc
**************************************************************************/
#if defined(HAVE_SIGNAL) && !defined(RETSIGTYPE)
# define RETSIGTYPE void
#endif
/*
vi:ts=4:et
*/
-143
View File
@@ -1,143 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*
* C/C++ Compiler - exactly one of:
*
* ACC_CC_UNKNOWN [default]
* ACC_CC_GNUC
* ...
*/
#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
# define ACC_CC_CILLY 1
# define ACC_INFO_CC "Cilly"
# define ACC_INFO_CCVER "unknown"
#elif defined(__INTEL_COMPILER)
# define ACC_CC_INTELC 1
# define ACC_INFO_CC "Intel C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__INTEL_COMPILER)
#elif defined(__POCC__)
# define ACC_CC_PELLESC 1
# define ACC_INFO_CC "Pelles C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__POCC__)
#elif defined(__GNUC__) && defined(__VERSION__)
# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
# elif defined(__GNUC_MINOR__)
# define ACC_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
# else
# define ACC_CC_GNUC (__GNUC__ * 0x10000L)
# endif
# define ACC_INFO_CC "gcc"
# define ACC_INFO_CCVER __VERSION__
#elif defined(__AZTEC_C__)
# define ACC_CC_AZTECC 1
# define ACC_INFO_CC "Aztec C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__AZTEC_C__)
#elif defined(__BORLANDC__)
# define ACC_CC_BORLANDC 1
# define ACC_INFO_CC "Borland C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__BORLANDC__)
#elif defined(__DMC__)
# define ACC_CC_DMC 1
# define ACC_INFO_CC "Digital Mars C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__DMC__)
#elif defined(__DECC)
# define ACC_CC_DECC 1
# define ACC_INFO_CC "DEC C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__DECC)
#elif defined(__HIGHC__)
# define ACC_CC_HIGHC 1
# define ACC_INFO_CC "MetaWare High C"
# define ACC_INFO_CCVER "unknown"
#elif defined(__IBMC__)
# define ACC_CC_IBMC 1
# define ACC_INFO_CC "IBM C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__IBMC__)
#elif defined(__KEIL__) && defined(__C166__)
# define ACC_CC_KEILC 1
# define ACC_INFO_CC "Keil C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__C166__)
#elif defined(__LCC__)
# define ACC_CC_LCC 1
# define ACC_INFO_CC "lcc"
# define ACC_INFO_CCVER "unknown"
#elif defined(_MSC_VER)
# define ACC_CC_MSC 1
# define ACC_INFO_CC "Microsoft C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(_MSC_VER)
#elif defined(__MWERKS__)
# define ACC_CC_MWERKS 1
# define ACC_INFO_CC "Metrowerks C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__MWERKS__)
#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
# define ACC_CC_NDPC 1
# define ACC_INFO_CC "Microway NDP C"
# define ACC_INFO_CCVER "unknown"
#elif defined(__PACIFIC__)
# define ACC_CC_PACIFICC 1
# define ACC_INFO_CC "Pacific C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__PACIFIC__)
#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
# define ACC_CC_PGI 1
# define ACC_INFO_CC "Portland Group PGI C"
# define ACC_INFO_CCVER "unknown"
#elif defined(__PUREC__)
# define ACC_CC_PUREC 1
# define ACC_INFO_CC "Pure C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__PUREC__)
#elif defined(__SC__)
# define ACC_CC_SYMANTECC 1
# define ACC_INFO_CC "Symantec C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__SC__)
#elif defined(__SUNPRO_C)
# define ACC_CC_SUNPROC 1
# define ACC_INFO_CC "Sun C"
# define ACC_INFO_CCVER "unknown"
#elif defined(__TINYC__)
# define ACC_CC_TINYC 1
# define ACC_INFO_CC "Tiny C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__TINYC__)
#elif defined(__TSC__)
# define ACC_CC_TOPSPEEDC 1
# define ACC_INFO_CC "TopSpeed C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__TSC__)
#elif defined(__WATCOMC__)
# define ACC_CC_WATCOMC 1
# define ACC_INFO_CC "Watcom C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__WATCOMC__)
#elif defined(__TURBOC__)
# define ACC_CC_TURBOC 1
# define ACC_INFO_CC "Turbo C"
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__TURBOC__)
#elif defined(__ZTC__)
# define ACC_CC_ZORTECHC 1
# define ACC_INFO_CC "Zortech C"
# if (__ZTC__ == 0x310)
# define ACC_INFO_CCVER "0x310"
# else
# define ACC_INFO_CCVER ACC_CPP_MACRO_EXPAND(__ZTC__)
# endif
#else
# define ACC_CC_UNKNOWN 1
# define ACC_INFO_CC "unknown"
# define ACC_INFO_CCVER "unknown"
#endif
/*
vi:ts=4:et
*/
-455
View File
@@ -1,455 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*************************************************************************
//
**************************************************************************/
#if !defined(ACCCHK_ASSERT)
# define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT(expr)
#endif
/* compile-time sign */
#if !defined(ACCCHK_ASSERT_SIGN_T)
# define ACCCHK_ASSERT_SIGN_T(type,relop) \
ACCCHK_ASSERT( (type) (-1) relop (type) 0 ) \
ACCCHK_ASSERT( (type) (~(type)0) relop (type) 0 ) \
ACCCHK_ASSERT( (type) (~(type)0) == (type) (-1) )
#endif
#if !defined(ACCCHK_IS_SIGNED_T)
# define ACCCHK_ASSERT_IS_SIGNED_T(type) ACCCHK_ASSERT_SIGN_T(type,<)
#endif
#if !defined(ACCCHK_IS_UNSIGNED_T)
# if (ACC_BROKEN_INTEGRAL_PROMOTION)
# define ACCCHK_ASSERT_IS_UNSIGNED_T(type) \
ACCCHK_ASSERT( (type) (-1) > (type) 0 )
# else
# define ACCCHK_ASSERT_IS_UNSIGNED_T(type) ACCCHK_ASSERT_SIGN_T(type,>)
# endif
#endif
/*************************************************************************
// check preprocessor
**************************************************************************/
#if (ACC_0xffffffffL - ACC_UINT32L_C(4294967294) != 1)
# error "preprocessor error 1"
#endif
#if (ACC_0xffffffffL - ACC_UINT32L_C(0xfffffffd) != 2)
# error "preprocessor error 2"
#endif
#define ACCCHK_VAL 1
#define ACCCHK_TMP1 ACCCHK_VAL
#undef ACCCHK_VAL
#define ACCCHK_VAL 2
#define ACCCHK_TMP2 ACCCHK_VAL
#if (ACCCHK_TMP1 != 2)
# error "preprocessor error 3a"
#endif
#if (ACCCHK_TMP2 != 2)
# error "preprocessor error 3b"
#endif
#undef ACCCHK_VAL
#if (ACCCHK_TMP2)
# error "preprocessor error 3c"
#endif
#if (ACCCHK_TMP2 + 0 != 0)
# error "preprocessor error 3d"
#endif
#undef ACCCHK_TMP1
#undef ACCCHK_TMP2
/*************************************************************************
// check basic arithmetics
**************************************************************************/
ACCCHK_ASSERT(1 == 1)
ACCCHK_ASSERT(__ACC_INT_MAX(2) == 1)
ACCCHK_ASSERT(__ACC_INT_MAX(8) == 127)
ACCCHK_ASSERT(__ACC_INT_MAX(16) == 32767)
ACCCHK_ASSERT(__ACC_UINT_MAX(2) == 3)
ACCCHK_ASSERT(__ACC_UINT_MAX(16) == 0xffffU)
ACCCHK_ASSERT(__ACC_UINT_MAX(32) == 0xffffffffUL)
#if !defined(ACC_BROKEN_INTEGRAL_PROMOTION)
ACCCHK_ASSERT(__ACC_UINT_MAX(__ACC_INT_BIT) == ~(0u))
ACCCHK_ASSERT(__ACC_UINT_MAX(__ACC_LONG_BIT) == ~(0ul))
#endif
/*************************************************************************
// check basic types
**************************************************************************/
ACCCHK_ASSERT_IS_SIGNED_T(signed char)
ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned char)
ACCCHK_ASSERT(sizeof(signed char) == sizeof(char))
ACCCHK_ASSERT(sizeof(unsigned char) == sizeof(char))
ACCCHK_ASSERT(sizeof(char) == 1)
#if (ACC_CC_CILLY)
/* CIL is broken */
#else
ACCCHK_ASSERT(sizeof(char) == sizeof((char)0))
#endif
#if defined(__cplusplus)
ACCCHK_ASSERT(sizeof('\0') == sizeof(char))
#else
# if (ACC_CC_DMC)
/* Digital Mars C is broken */
# else
ACCCHK_ASSERT(sizeof('\0') == sizeof(int))
# endif
#endif
#if defined(acc_alignof)
ACCCHK_ASSERT(acc_alignof(char) == 1)
ACCCHK_ASSERT(acc_alignof(signed char) == 1)
ACCCHK_ASSERT(acc_alignof(unsigned char) == 1)
#endif
ACCCHK_ASSERT_IS_SIGNED_T(short)
ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned short)
ACCCHK_ASSERT(sizeof(short) == sizeof(unsigned short))
ACCCHK_ASSERT(sizeof(short) >= 2)
ACCCHK_ASSERT(sizeof(short) >= sizeof(char))
#if (ACC_CC_CILLY)
/* CIL is broken */
#else
ACCCHK_ASSERT(sizeof(short) == sizeof((short)0))
#endif
#if (SIZEOF_SHORT > 0)
ACCCHK_ASSERT(sizeof(short) == SIZEOF_SHORT)
#endif
ACCCHK_ASSERT_IS_SIGNED_T(int)
ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned int)
ACCCHK_ASSERT(sizeof(int) == sizeof(unsigned int))
ACCCHK_ASSERT(sizeof(int) >= 2)
ACCCHK_ASSERT(sizeof(int) >= sizeof(short))
ACCCHK_ASSERT(sizeof(int) == sizeof(0))
ACCCHK_ASSERT(sizeof(int) == sizeof((int)0))
#if (SIZEOF_INT > 0)
ACCCHK_ASSERT(sizeof(int) == SIZEOF_INT)
#endif
ACCCHK_ASSERT_IS_SIGNED_T(long)
ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned long)
ACCCHK_ASSERT(sizeof(long) == sizeof(unsigned long))
ACCCHK_ASSERT(sizeof(long) >= 4)
ACCCHK_ASSERT(sizeof(long) >= sizeof(int))
ACCCHK_ASSERT(sizeof(long) == sizeof(0L))
ACCCHK_ASSERT(sizeof(long) == sizeof((long)0))
#if (SIZEOF_LONG > 0)
ACCCHK_ASSERT(sizeof(long) == SIZEOF_LONG)
#endif
ACCCHK_ASSERT_IS_UNSIGNED_T(size_t)
ACCCHK_ASSERT(sizeof(size_t) >= sizeof(int))
ACCCHK_ASSERT(sizeof(size_t) == sizeof(sizeof(0))) /* sizeof() returns size_t */
#if (SIZEOF_SIZE_T > 0)
ACCCHK_ASSERT(sizeof(size_t) == SIZEOF_SIZE_T)
#endif
ACCCHK_ASSERT_IS_SIGNED_T(ptrdiff_t)
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int))
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t))
#if !defined(ACC_BROKEN_SIZEOF)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof((char*)0 - (char*)0))
# if (ACC_HAVE_MM_HUGE_PTR)
ACCCHK_ASSERT(4 == sizeof((char __huge*)0 - (char __huge*)0))
# endif
#endif
#if (SIZEOF_PTRDIFF_T > 0)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == SIZEOF_PTRDIFF_T)
#endif
ACCCHK_ASSERT(sizeof(void*) >= sizeof(char*))
#if (SIZEOF_VOID_P > 0)
ACCCHK_ASSERT(sizeof(void*) == SIZEOF_VOID_P)
#endif
#if (SIZEOF_CHAR_P > 0)
ACCCHK_ASSERT(sizeof(char*) == SIZEOF_CHAR_P)
#endif
#if (ACC_HAVE_MM_HUGE_PTR)
ACCCHK_ASSERT(4 == sizeof(void __huge*))
ACCCHK_ASSERT(4 == sizeof(char __huge*))
#endif
/*************************************************************************
// check arithmetics
**************************************************************************/
ACCCHK_ASSERT((((1u << 15) + 1) >> 15) == 1)
ACCCHK_ASSERT((((1ul << 31) + 1) >> 31) == 1)
#if (ACC_CC_TURBOC && (__TURBOC__ < 0x0150))
/* TC 1.0 bug, probably due to ACC_BROKEN_INTEGRAL_PROMOTION ?? */
#else
ACCCHK_ASSERT((1 << (8*SIZEOF_INT-1)) < 0)
#endif
ACCCHK_ASSERT((1u << (8*SIZEOF_INT-1)) > 0)
ACCCHK_ASSERT((1l << (8*SIZEOF_LONG-1)) < 0)
ACCCHK_ASSERT((1ul << (8*SIZEOF_LONG-1)) > 0)
#if defined(acc_int32e_t)
ACCCHK_ASSERT(sizeof(acc_int32e_t) == 4)
ACCCHK_ASSERT(sizeof(acc_int32e_t) == SIZEOF_ACC_INT32E_T)
ACCCHK_ASSERT(sizeof(acc_uint32e_t) == 4)
ACCCHK_ASSERT(sizeof(acc_int32e_t) == sizeof(acc_uint32e_t))
ACCCHK_ASSERT_IS_SIGNED_T(acc_int32e_t)
ACCCHK_ASSERT(((( (acc_int32e_t)1 << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT(((( ACC_INT32E_C(1) << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint32e_t)
ACCCHK_ASSERT(((( (acc_uint32e_t)1 << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT(((( ACC_UINT32E_C(1) << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT( (acc_int32e_t) (1 + ~(acc_int32e_t)0) == 0)
#if defined(ACCCHK_CONFIG_PEDANTIC)
/* compiler may warn about overflow */
ACCCHK_ASSERT( (acc_uint32e_t)(1 + ~(acc_uint32e_t)0) == 0)
#endif /* ACCCHK_CONFIG_PEDANTIC */
#if (SIZEOF_ACC_INT32E_T < SIZEOF_INT)
ACCCHK_ASSERT(sizeof(ACC_INT32E_C(0)) == sizeof(int))
ACCCHK_ASSERT(sizeof(ACC_UINT32E_C(0)) == sizeof(int))
#else
ACCCHK_ASSERT(sizeof(ACC_INT32E_C(0)) == SIZEOF_ACC_INT32E_T)
ACCCHK_ASSERT(sizeof(ACC_UINT32E_C(0)) == SIZEOF_ACC_INT32E_T)
#endif
ACCCHK_ASSERT((ACC_INT32E_C(1) << (8*SIZEOF_ACC_INT32E_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32E_C(1) << (8*SIZEOF_ACC_INT32E_T-1)) > 0)
ACCCHK_ASSERT((ACC_INT32E_C(1) << (int)(8*sizeof(ACC_INT32E_C(1))-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32E_C(1) << (int)(8*sizeof(ACC_UINT32E_C(1))-1)) > 0)
ACCCHK_ASSERT(ACC_INT32E_C(2147483647) > 0)
ACCCHK_ASSERT(ACC_INT32E_C(-2147483647) -1 < 0)
ACCCHK_ASSERT(ACC_UINT32E_C(4294967295) > 0)
ACCCHK_ASSERT(ACC_UINT32E_C(4294967295) == ACC_0xffffffffL)
#endif
ACCCHK_ASSERT(sizeof(acc_int32l_t) >= sizeof(int))
#if defined(acc_int32e_t)
ACCCHK_ASSERT(sizeof(acc_int32l_t) >= sizeof(acc_int32e_t))
#endif
ACCCHK_ASSERT(sizeof(acc_int32l_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_int32l_t) == SIZEOF_ACC_INT32L_T)
ACCCHK_ASSERT(sizeof(acc_uint32l_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_int32l_t) == sizeof(acc_uint32l_t))
ACCCHK_ASSERT_IS_SIGNED_T(acc_int32l_t)
ACCCHK_ASSERT(((( (acc_int32l_t)1 << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT(((( ACC_INT32L_C(1) << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint32l_t)
ACCCHK_ASSERT(((( (acc_uint32l_t)1 << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT(((( ACC_UINT32L_C(1) << 31) + 1) >> 31) == 1)
#if (SIZEOF_ACC_INT32L_T < SIZEOF_INT)
ACCCHK_ASSERT(sizeof(ACC_INT32L_C(0)) == sizeof(int))
ACCCHK_ASSERT(sizeof(ACC_UINT32L_C(0)) == sizeof(int))
#else
ACCCHK_ASSERT(sizeof(ACC_INT32L_C(0)) == SIZEOF_ACC_INT32L_T)
ACCCHK_ASSERT(sizeof(ACC_UINT32L_C(0)) == SIZEOF_ACC_INT32L_T)
#endif
ACCCHK_ASSERT((ACC_INT32L_C(1) << (8*SIZEOF_ACC_INT32L_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32L_C(1) << (8*SIZEOF_ACC_INT32L_T-1)) > 0)
ACCCHK_ASSERT((ACC_INT32L_C(1) << (int)(8*sizeof(ACC_INT32L_C(1))-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32L_C(1) << (int)(8*sizeof(ACC_UINT32L_C(1))-1)) > 0)
ACCCHK_ASSERT(ACC_INT32L_C(2147483647) > 0)
ACCCHK_ASSERT(ACC_INT32L_C(-2147483647) -1 < 0)
ACCCHK_ASSERT(ACC_UINT32L_C(4294967295) > 0)
ACCCHK_ASSERT(ACC_UINT32L_C(4294967295) == ACC_0xffffffffL)
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(int))
#if defined(acc_int32e_t)
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32e_t))
#endif
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32l_t))
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_int32f_t) >= sizeof(acc_int32l_t))
ACCCHK_ASSERT(sizeof(acc_int32f_t) == SIZEOF_ACC_INT32F_T)
ACCCHK_ASSERT(sizeof(acc_uint32f_t) >= 4)
ACCCHK_ASSERT(sizeof(acc_uint32f_t) >= sizeof(acc_uint32l_t))
ACCCHK_ASSERT(sizeof(acc_int32f_t) == sizeof(acc_uint32f_t))
ACCCHK_ASSERT_IS_SIGNED_T(acc_int32f_t)
ACCCHK_ASSERT(((( (acc_int32f_t)1 << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT(((( ACC_INT32F_C(1) << 30) + 1) >> 30) == 1)
ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint32f_t)
ACCCHK_ASSERT(((( (acc_uint32f_t)1 << 31) + 1) >> 31) == 1)
ACCCHK_ASSERT(((( ACC_UINT32F_C(1) << 31) + 1) >> 31) == 1)
#if (SIZEOF_ACC_INT32F_T < SIZEOF_INT)
ACCCHK_ASSERT(sizeof(ACC_INT32F_C(0)) == sizeof(int))
ACCCHK_ASSERT(sizeof(ACC_UINT32F_C(0)) == sizeof(int))
#else
ACCCHK_ASSERT(sizeof(ACC_INT32F_C(0)) == SIZEOF_ACC_INT32F_T)
ACCCHK_ASSERT(sizeof(ACC_UINT32F_C(0)) == SIZEOF_ACC_INT32F_T)
#endif
ACCCHK_ASSERT((ACC_INT32F_C(1) << (8*SIZEOF_ACC_INT32F_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32F_C(1) << (8*SIZEOF_ACC_INT32F_T-1)) > 0)
ACCCHK_ASSERT((ACC_INT32F_C(1) << (int)(8*sizeof(ACC_INT32F_C(1))-1)) < 0)
ACCCHK_ASSERT((ACC_UINT32F_C(1) << (int)(8*sizeof(ACC_UINT32F_C(1))-1)) > 0)
ACCCHK_ASSERT(ACC_INT32F_C(2147483647) > 0)
ACCCHK_ASSERT(ACC_INT32F_C(-2147483647) -1 < 0)
ACCCHK_ASSERT(ACC_UINT32F_C(4294967295) > 0)
ACCCHK_ASSERT(ACC_UINT32F_C(4294967295) == ACC_0xffffffffL)
#if defined(acc_int64l_t)
ACCCHK_ASSERT(sizeof(acc_int64l_t) >= 8)
ACCCHK_ASSERT(sizeof(acc_int64l_t) == SIZEOF_ACC_INT64L_T)
ACCCHK_ASSERT(sizeof(acc_uint64l_t) >= 8)
ACCCHK_ASSERT(sizeof(acc_int64l_t) == sizeof(acc_uint64l_t))
ACCCHK_ASSERT_IS_SIGNED_T(acc_int64l_t)
ACCCHK_ASSERT(((( (acc_int64l_t)1 << 62) + 1) >> 62) == 1)
ACCCHK_ASSERT(((( ACC_INT64L_C(1) << 62) + 1) >> 62) == 1)
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530))
/* Borland C is broken */
#else
ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uint64l_t)
ACCCHK_ASSERT(ACC_UINT64L_C(18446744073709551615) > 0)
#endif
ACCCHK_ASSERT(((( (acc_uint64l_t)1 << 63) + 1) >> 63) == 1)
ACCCHK_ASSERT(((( ACC_UINT64L_C(1) << 63) + 1) >> 63) == 1)
#if defined(ACCCHK_CONFIG_PEDANTIC)
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0560))
/* Borland C is broken */
#elif (SIZEOF_ACC_INT64L_T < SIZEOF_INT)
ACCCHK_ASSERT(sizeof(ACC_INT64L_C(0)) == sizeof(int))
ACCCHK_ASSERT(sizeof(ACC_UINT64L_C(0)) == sizeof(int))
#else
ACCCHK_ASSERT(sizeof(ACC_INT64L_C(0)) == SIZEOF_ACC_INT64L_T)
ACCCHK_ASSERT(sizeof(ACC_UINT64L_C(0)) == SIZEOF_ACC_INT64L_T)
#endif
#endif /* ACCCHK_CONFIG_PEDANTIC */
ACCCHK_ASSERT((ACC_INT64L_C(1) << (8*SIZEOF_ACC_INT64L_T-1)) < 0)
ACCCHK_ASSERT((ACC_UINT64L_C(1) << (8*SIZEOF_ACC_INT64L_T-1)) > 0)
#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020600ul))
/* avoid pedantic warning */
ACCCHK_ASSERT(ACC_INT64L_C(9223372036854775807) > ACC_INT64L_C(0))
#else
ACCCHK_ASSERT(ACC_INT64L_C(9223372036854775807) > 0)
#endif
ACCCHK_ASSERT(ACC_INT64L_C(-9223372036854775807) - 1 < 0)
ACCCHK_ASSERT( ACC_INT64L_C(9223372036854775807) % 2147483629l == 721)
ACCCHK_ASSERT( ACC_INT64L_C(9223372036854775807) % 2147483647l == 1)
ACCCHK_ASSERT(ACC_UINT64L_C(9223372036854775807) % 2147483629ul == 721)
ACCCHK_ASSERT(ACC_UINT64L_C(9223372036854775807) % 2147483647ul == 1)
#endif /* acc_int64l_t */
ACCCHK_ASSERT_IS_SIGNED_T(acc_intptr_t)
ACCCHK_ASSERT_IS_UNSIGNED_T(acc_uintptr_t)
ACCCHK_ASSERT(sizeof(acc_intptr_t) >= sizeof(void *))
ACCCHK_ASSERT(sizeof(acc_intptr_t) == SIZEOF_ACC_INTPTR_T)
ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(acc_uintptr_t))
/*************************************************************************
// check memory model ACC_MM
**************************************************************************/
#if (ACC_MM_FLAT)
#if 0
/* this is not a valid assumption -- disabled */
ACCCHK_ASSERT(sizeof(void*) == sizeof(void (*)(void)))
#endif
#endif
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
ACCCHK_ASSERT(sizeof(void*) == 2)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 2)
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
ACCCHK_ASSERT(sizeof(void*) == 4)
#endif
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_COMPACT)
ACCCHK_ASSERT(sizeof(void (*)(void)) == 2)
#elif (ACC_MM_MEDIUM || ACC_MM_LARGE || ACC_MM_HUGE)
ACCCHK_ASSERT(sizeof(void (*)(void)) == 4)
#endif
/*************************************************************************
// check ACC_ARCH and ACC_OS
**************************************************************************/
#if (ACC_ARCH_IA16)
ACCCHK_ASSERT(sizeof(size_t) == 2)
ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *))
#elif (ACC_ARCH_IA32 || ACC_ARCH_M68K)
ACCCHK_ASSERT(sizeof(size_t) == 4)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 4)
ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *))
#elif (ACC_ARCH_AMD64 || ACC_ARCH_IA64)
ACCCHK_ASSERT(sizeof(size_t) == 8)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 8)
ACCCHK_ASSERT(sizeof(acc_intptr_t) == sizeof(void *))
#endif
#if (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_WIN32)
ACCCHK_ASSERT(sizeof(size_t) == 4)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 4)
ACCCHK_ASSERT(sizeof(void (*)(void)) == 4)
#elif (ACC_OS_WIN64)
ACCCHK_ASSERT(sizeof(size_t) == 8)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == 8)
ACCCHK_ASSERT(sizeof(void (*)(void)) == 8)
#endif
/*************************************************************************
// check promotion rules
**************************************************************************/
#if (ACC_CC_NDPC)
/* NDP C is broken */
#else
/* check that the compiler correctly casts signed to unsigned */
ACCCHK_ASSERT( (int) ((unsigned char) ((signed char) -1)) == 255)
#endif
#if (ACC_CC_KEILC)
/* Keil C is broken */
#elif (ACC_CC_NDPC)
/* NDP C is broken */
#elif !defined(ACC_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1)
/* check that the compiler correctly promotes integrals */
ACCCHK_ASSERT( (((unsigned char)128) << (int)(8*sizeof(int)-8)) < 0)
#endif
/*
vi:ts=4:et
*/
-126
View File
@@ -1,126 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*************************************************************************
//
**************************************************************************/
#if !defined(__ACCCHKR_FUNCNAME)
# define __ACCCHKR_FUNCNAME(f) accchkr_ ## f
#endif
#if !defined(ACCCHKR_ASSERT)
#if 0 || defined(ACCCHKR_CONFIG_DEBUG)
#include <stdio.h>
static int __ACCCHKR_FUNCNAME(assert_fail)(const char* s, unsigned l)
{
fprintf(stderr, "ACCCHKR assertion failed in line %u: `%s'\n", l, s);
return 0;
}
#define ACCCHKR_ASSERT(expr) ((expr) ? 1 : __ACCCHKR_FUNCNAME(assert_fail)(#expr,__LINE__))
#else
#define ACCCHKR_ASSERT(expr) ((expr) ? 1 : 0)
#endif
#endif
/* avoid inlining */
static int __ACCCHKR_FUNCNAME(schedule_insns_bug)(void);
static int __ACCCHKR_FUNCNAME(strength_reduce_bug)(int*);
/*************************************************************************
// main entry
**************************************************************************/
static int __ACCCHKR_FUNCNAME(check)(int r)
{
#if defined(ACC_ENDIAN_BIG_ENDIAN)
{
union { long l; unsigned char c[sizeof(long)]; } u;
u.l = 0; u.c[sizeof(long)-1] = 0x80;
r &= ACCCHKR_ASSERT(u.l == 128);
u.l = 0; u.c[0] = 0x80;
r &= ACCCHKR_ASSERT(u.l < 0);
ACC_UNUSED(u);
}
#endif
#if defined(ACC_ENDIAN_LITTLE_ENDIAN)
{
union { long l; unsigned char c[sizeof(long)]; } u;
u.l = 0; u.c[0] = 0x80;
r &= ACCCHKR_ASSERT(u.l == 128);
u.l = 0; u.c[sizeof(long)-1] = 0x80;
r &= ACCCHKR_ASSERT(u.l < 0);
ACC_UNUSED(u);
}
#endif
/* check for the gcc schedule-insns optimization bug */
if (r == 1)
{
r &= ACCCHKR_ASSERT(!__ACCCHKR_FUNCNAME(schedule_insns_bug()));
}
/* check for the gcc strength-reduce optimization bug */
if (r == 1)
{
static int x[3];
static unsigned xn = 3;
register unsigned j;
for (j = 0; j < xn; j++)
x[j] = (int)j - 3;
r &= ACCCHKR_ASSERT(!__ACCCHKR_FUNCNAME(strength_reduce_bug(x)));
}
return r;
}
/*************************************************************************
//
**************************************************************************/
static int __ACCCHKR_FUNCNAME(schedule_insns_bug)(void)
{
const int a[] = {1, 2, 0}; const int* b;
b = a; return (*b) ? 0 : 1;
}
static int __ACCCHKR_FUNCNAME(strength_reduce_bug)(int* x)
{
#if 0 && (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
ACC_UNUSED(x); return 0;
#else
return x[0] != -3 || x[1] != -2 || x[2] != -1;
#endif
}
/*
vi:ts=4:et
*/
-157
View File
@@ -1,157 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#ifndef __ACC_CXX_H_INCLUDED
#define __ACC_CXX_H_INCLUDED 1
#if defined(__cplusplus)
/*************************************************************************
// exception specification
// ACC_CXX_NOTHROW
**************************************************************************/
#if defined(ACC_CXX_NOTHROW)
#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020800ul))
#elif (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0450))
#elif (ACC_CC_HIGHC)
#elif (ACC_CC_MSC && (_MSC_VER < 1100))
#elif (ACC_CC_NDPC)
#elif (ACC_CC_TURBOC)
#elif (ACC_CC_WATCOMC && !defined(_CPPUNWIND))
#elif (ACC_CC_ZORTECHC)
#else
# define ACC_CXX_NOTHROW throw()
#endif
#if !defined(ACC_CXX_NOTHROW)
# define ACC_CXX_NOTHROW
#endif
/*************************************************************************
// disable dynamic allocation of an object - private helpers
// __ACC_CXX_DO_NEW
// __ACC_CXX_DO_DELETE
**************************************************************************/
#if defined(__ACC_CXX_DO_NEW)
#elif (ACC_CC_NDPC || ACC_CC_PGI)
# define __ACC_CXX_DO_NEW { return 0; }
#else
# define __ACC_CXX_DO_NEW ;
#endif
/* need an implementation in case a class has virtual members */
#if defined(__ACC_CXX_DO_DELETE)
#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# define __ACC_CXX_DO_DELETE { }
#else
# define __ACC_CXX_DO_DELETE ACC_CXX_NOTHROW { }
#endif
/*************************************************************************
// disable dynamic allocation of an object
// ACC_CXX_DISABLE_NEW_DELETE
**************************************************************************/
/*
#undef __ACC_CXX_HAVE_ARRAY_NEW
#undef __ACC_CXX_HAVE_PLACEMENT_NEW
#undef __ACC_CXX_HAVE_PLACEMENT_DELETE
*/
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0450))
#elif (ACC_CC_MSC && ACC_MM_HUGE)
# define ACC_CXX_DISABLE_NEW_DELETE private:
#elif (ACC_CC_MSC && (_MSC_VER < 1100))
#elif (ACC_CC_NDPC)
#elif (ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
#elif (ACC_CC_TURBOC)
#elif (ACC_CC_WATCOMC && (__WATCOMC__ < 1100))
#else
# define __ACC_CXX_HAVE_ARRAY_NEW 1
#endif
#if (__ACC_CXX_HAVE_ARRAY_NEW)
# define __ACC_CXX_HAVE_PLACEMENT_NEW 1
#endif
#if (__ACC_CXX_HAVE_PLACEMENT_NEW)
# if (ACC_CC_GNUC >= 0x030000ul)
# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1
# elif (ACC_CC_INTELC)
# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1
# elif (ACC_CC_MSC && (_MSC_VER >= 1200))
# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1
# elif (ACC_CC_PGI)
# define __ACC_CXX_HAVE_PLACEMENT_DELETE 1
# endif
#endif
#if defined(ACC_CXX_DISABLE_NEW_DELETE)
#elif defined(new) || defined(delete)
# define ACC_CXX_DISABLE_NEW_DELETE private:
#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x025b00ul))
# define ACC_CXX_DISABLE_NEW_DELETE private:
#elif (ACC_CC_HIGHC)
# define ACC_CXX_DISABLE_NEW_DELETE private:
#elif !defined(__ACC_CXX_HAVE_ARRAY_NEW)
/* for old compilers use `protected' instead of `private' */
# define ACC_CXX_DISABLE_NEW_DELETE \
protected: static void operator delete(void*) __ACC_CXX_DO_DELETE \
protected: static void* operator new(size_t) __ACC_CXX_DO_NEW \
private:
#else
# define ACC_CXX_DISABLE_NEW_DELETE \
protected: static void operator delete(void*) __ACC_CXX_DO_DELETE \
static void operator delete[](void*) __ACC_CXX_DO_DELETE \
private: static void* operator new(size_t) __ACC_CXX_DO_NEW \
static void* operator new[](size_t) __ACC_CXX_DO_NEW
#endif
/*************************************************************************
// Assist the compiler by defining a unique location for vtables and RTTI.
// Every class which has virtual member functions or derives from a class
// with virtual members should put this macro at the very top of its
// class declaration.
// ACC_CXX_TRIGGER_FUNCTION
**************************************************************************/
#if defined(ACC_CXX_TRIGGER_FUNCTION)
#else
# define ACC_CXX_TRIGGER_FUNCTION \
protected: virtual const void* acc_cxx_trigger_function() const; \
private:
#endif
#if defined(ACC_CXX_TRIGGER_FUNCTION_IMPL)
#else
# define ACC_CXX_TRIGGER_FUNCTION_IMPL(klass) \
const void* klass::acc_cxx_trigger_function() const { return 0; }
#endif
#endif /* __cplusplus */
#endif /* already included */
/*
vi:ts=4:et
*/
-191
View File
@@ -1,191 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/***********************************************************************
// acc_alignof() / acc_inline
************************************************************************/
#if (ACC_CC_CILLY || ACC_CC_GNUC || ACC_CC_PGI)
# define acc_alignof(e) __alignof__(e)
#elif (ACC_CC_INTELC && (__INTEL_COMPILER >= 700))
# define acc_alignof(e) __alignof__(e)
#elif (ACC_CC_MSC && (_MSC_VER >= 1300))
# define acc_alignof(e) __alignof(e)
#endif
#if (ACC_CC_TURBOC && (__TURBOC__ <= 0x0295))
#elif defined(__cplusplus)
# define acc_inline inline
#elif (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
# define acc_inline __inline
#elif (ACC_CC_CILLY || ACC_CC_GNUC || ACC_CC_PGI)
# define acc_inline __inline__
#elif (ACC_CC_DMC)
# define acc_inline __inline
#elif (ACC_CC_INTELC)
# define acc_inline __inline
#elif (ACC_CC_MSC && (_MSC_VER >= 900))
# define acc_inline __inline
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define acc_inline inline
#endif
/***********************************************************************
// ACC_UNUSED / ACC_UNUSED_FUNC
************************************************************************/
#if !defined(ACC_UNUSED)
# if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
# define ACC_UNUSED(var) ((void) &var)
# elif (ACC_CC_BORLANDC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_TURBOC)
# define ACC_UNUSED(var) if (&var) ; else
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED(var) if (&var) ; else
# elif (ACC_CC_GNUC)
# define ACC_UNUSED(var) ((void) var)
# elif (ACC_CC_KEILC)
# define ACC_UNUSED(var)
# else
# define ACC_UNUSED(var) ((void) &var)
# endif
#endif
#if !defined(ACC_UNUSED_FUNC)
# if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
# define ACC_UNUSED_FUNC(func) ((void) func)
# elif (ACC_CC_BORLANDC || ACC_CC_NDPC || ACC_CC_TURBOC)
# define ACC_UNUSED_FUNC(func) if (func) ; else
# elif (ACC_CC_GNUC == 0x030400ul) && defined(__llvm__)
# define ACC_UNUSED_FUNC(func) ((void) &func)
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_UNUSED_FUNC(func) if (func) ; else
# elif (ACC_CC_MSC)
# define ACC_UNUSED_FUNC(func) ((void) &func)
# elif (ACC_CC_KEILC)
# define ACC_UNUSED_FUNC(func)
# else
# define ACC_UNUSED_FUNC(func) ((void) func)
# endif
#endif
/***********************************************************************
// compile-time-assertions
************************************************************************/
/* This can be put into a header file but may get ignored by some compilers. */
#if !defined(ACC_COMPILE_TIME_ASSERT_HEADER)
# if (ACC_CC_AZTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-!(e)];
# elif (ACC_CC_DMC || ACC_CC_SYMANTECC)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1u-2*!(e)];
# elif (ACC_CC_TURBOC && (__TURBOC__ == 0x0295))
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-!(e)];
# else
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-2*!(e)];
# endif
#endif
/* This must appear within a function body. */
#if !defined(ACC_COMPILE_TIME_ASSERT)
# if (ACC_CC_AZTECC)
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-!(e)];}
# elif (ACC_CC_DMC || ACC_CC_PACIFICC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# elif (ACC_CC_MSC && (_MSC_VER < 900))
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# elif (ACC_CC_TURBOC && (__TURBOC__ == 0x0295))
# define ACC_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
# else
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __acc_cta_t[1-2*!(e)];}
# endif
#endif
/***********************************************************************
// macros
************************************************************************/
#if !defined(__ACC_UINT_MAX)
# define __ACC_INT_MAX(b) ((((1l << ((b)-2)) - 1l) * 2l) + 1l)
# define __ACC_UINT_MAX(b) ((((1ul << ((b)-1)) - 1ul) * 2ul) + 1ul)
#endif
/***********************************************************************
// get sizes of builtin integral types from <limits.h>
************************************************************************/
#if !defined(__ACC_SHORT_BIT)
# if (USHRT_MAX == ACC_0xffffL)
# define __ACC_SHORT_BIT 16
# elif (USHRT_MAX == ACC_0xffffffffL)
# define __ACC_SHORT_BIT 32
# elif (USHRT_MAX == __ACC_UINT_MAX(64))
# define __ACC_SHORT_BIT 64
# elif (USHRT_MAX == __ACC_UINT_MAX(128))
# define __ACC_SHORT_BIT 128
# else
# error "check your compiler installation: USHRT_MAX"
# endif
#endif
#if !defined(__ACC_INT_BIT)
# if (UINT_MAX == ACC_0xffffL)
# define __ACC_INT_BIT 16
# elif (UINT_MAX == ACC_0xffffffffL)
# define __ACC_INT_BIT 32
# elif (UINT_MAX == __ACC_UINT_MAX(64))
# define __ACC_INT_BIT 64
# elif (UINT_MAX == __ACC_UINT_MAX(128))
# define __ACC_INT_BIT 128
# else
# error "check your compiler installation: UINT_MAX"
# endif
#endif
#if !defined(__ACC_LONG_BIT)
# if (ULONG_MAX == ACC_0xffffffffL)
# define __ACC_LONG_BIT 32
# elif (ULONG_MAX == __ACC_UINT_MAX(64))
# define __ACC_LONG_BIT 64
# elif (ULONG_MAX == __ACC_UINT_MAX(128))
# define __ACC_LONG_BIT 128
# else
# error "check your compiler installation: ULONG_MAX"
# endif
#endif
/***********************************************************************
// acc_auto.h supplements
************************************************************************/
#if (ACC_OS_CYGWIN || (ACC_OS_EMX && defined(__RSXNT__)) || ACC_OS_WIN32 || ACC_OS_WIN64)
# if (ACC_CC_WATCOMC && (__WATCOMC__ < 1000))
# elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
/* ancient pw32 version */
# elif ((ACC_OS_CYGWIN || defined(__MINGW32__)) && (ACC_CC_GNUC && (ACC_CC_GNUC < 0x025f00ul)))
/* ancient cygwin/mingw version */
# else
# define ACC_HAVE_WINDOWS_H 1
# endif
#endif
/*
vi:ts=4:et
*/
-67
View File
@@ -1,67 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#ifndef __ACC_INCD_H_INCLUDED
#define __ACC_INCD_H_INCLUDED 1
/* default system includes */
/* see Autoconf:
* headers.m4, _AC_INCLUDES_DEFAULT_REQUIREMENTS ac_includes_default
*/
#include <stdio.h>
#if defined(HAVE_TIME_H) && defined(__MSL__) && defined(__cplusplus)
# include <time.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# if HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
#endif
#if HAVE_STRINGS_H
# include <strings.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#endif /* already included */
/*
vi:ts=4:et
*/
-87
View File
@@ -1,87 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#ifndef __ACC_INCE_H_INCLUDED
#define __ACC_INCE_H_INCLUDED 1
/* extra system includes */
#if defined(HAVE_STDARG_H)
# include <stdarg.h>
#endif
#if defined(HAVE_CTYPE_H)
# include <ctype.h>
#endif
#if defined(HAVE_ERRNO_H)
# include <errno.h>
#endif
#if defined(HAVE_MALLOC_H)
# include <malloc.h>
#endif
#if defined(HAVE_ALLOCA_H)
# include <alloca.h>
#endif
#if defined(HAVE_FCNTL_H)
# include <fcntl.h>
#endif
#if defined(HAVE_DIRENT_H)
# include <dirent.h>
#endif
#if defined(HAVE_SETJMP_H)
# include <setjmp.h>
#endif
#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
#if defined(TIME_WITH_SYS_TIME)
# include <sys/time.h>
# include <time.h>
#elif defined(HAVE_TIME_H)
# include <time.h>
#endif
#if defined(HAVE_UTIME_H)
# include <utime.h>
#elif defined(HAVE_SYS_UTIME_H)
# include <sys/utime.h>
#endif
/* DOS, OS/2 & Windows */
#if defined(HAVE_IO_H)
# include <io.h>
#endif
#if defined(HAVE_DOS_H)
# include <dos.h>
#endif
#if defined(HAVE_DIRECT_H)
# include <direct.h>
#endif
#if defined(HAVE_SHARE_H)
# include <share.h>
#endif
#if defined(ACC_CC_NDPC)
# include <os.h>
#endif
/* TOS */
#if defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__))
# include <ext.h>
#endif
#endif /* already included */
/*
vi:ts=4:et
*/
-103
View File
@@ -1,103 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#ifndef __ACC_INCI_H_INCLUDED
#define __ACC_INCI_H_INCLUDED 1
/*************************************************************************
// internal system includes
**************************************************************************/
#if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
# include <tos.h>
#elif (ACC_HAVE_WINDOWS_H)
# if 1 && !defined(WIN32_LEAN_AND_MEAN)
# define WIN32_LEAN_AND_MEAN 1
# endif
# if 1 && !defined(_WIN32_WINNT)
/* Restrict to a subset of Windows NT 4.0 header files */
# define _WIN32_WINNT 0x0400
# endif
# include <windows.h>
# if (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# include <dir.h>
# endif
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16)
# if (ACC_CC_AZTECC)
# include <model.h>
# include <stat.h>
# elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
# include <alloc.h>
# include <dir.h>
# elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
# include <sys/exceptn.h>
# elif (ACC_CC_PACIFICC)
# include <unixio.h>
# include <stat.h>
# include <sys.h>
# elif (ACC_CC_WATCOMC)
# include <i86.h>
# endif
#elif (ACC_OS_OS216)
# if (ACC_CC_WATCOMC)
# include <i86.h>
# endif
#endif
/*************************************************************************
//
**************************************************************************/
#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
# if defined(FP_OFF)
# define ACC_FP_OFF(x) FP_OFF(x)
# elif defined(_FP_OFF)
# define ACC_FP_OFF(x) _FP_OFF(x)
# else
# define ACC_FP_OFF(x) (((const unsigned __far*)&(x))[0])
# endif
# if defined(FP_SEG)
# define ACC_FP_SEG(x) FP_SEG(x)
# elif defined(_FP_SEG)
# define ACC_FP_SEG(x) _FP_SEG(x)
# else
# define ACC_FP_SEG(x) (((const unsigned __far*)&(x))[1])
# endif
# if defined(MK_FP)
# define ACC_MK_FP(s,o) MK_FP(s,o)
# elif defined(_MK_FP)
# define ACC_MK_FP(s,o) _MK_FP(s,o)
# else
# define ACC_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
# endif
# if 0
# undef ACC_FP_OFF
# undef ACC_FP_SEG
# undef ACC_MK_FP
# define ACC_FP_OFF(x) (((const unsigned __far*)&(x))[0])
# define ACC_FP_SEG(x) (((const unsigned __far*)&(x))[1])
# define ACC_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
# endif
#endif
#endif /* already included */
/*
vi:ts=4:et
*/
-237
View File
@@ -1,237 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/***********************************************************************
// preprocessor
************************************************************************/
/* workaround for preprocessor bugs in some compilers */
#if 0
#define ACC_0xffffL 0xfffful
#define ACC_0xffffffffL 0xfffffffful
#else
#define ACC_0xffffL 65535ul
#define ACC_0xffffffffL 4294967295ul
#endif
/* some things we cannot work around */
#if (ACC_0xffffL == ACC_0xffffffffL)
# error "your preprocessor is broken 1"
#endif
#if (16ul * 16384ul != 262144ul)
# error "your preprocessor is broken 2"
#endif
#if 0
#if (32767 >= 4294967295ul)
# error "your preprocessor is broken 3"
#endif
#if (65535u >= 4294967295ul)
# error "your preprocessor is broken 4"
#endif
#endif
/***********************************************************************
// try to detect specific compilers
************************************************************************/
#if (UINT_MAX == ACC_0xffffL)
#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
# if !defined(MSDOS)
# define MSDOS 1
# endif
# if !defined(_MSDOS)
# define _MSDOS 1
# endif
#elif defined(__VERSION) && defined(MB_LEN_MAX)
# if (__VERSION == 520) && (MB_LEN_MAX == 1)
# if !defined(__AZTEC_C__)
# define __AZTEC_C__ __VERSION
# endif
# if !defined(__DOS__)
# define __DOS__ 1
# endif
# endif
#endif
#endif
/***********************************************************************
// fix incorrect and missing stuff
************************************************************************/
/* Microsoft C does not correctly define ptrdiff_t for
* the 16-bit huge memory model.
*/
#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == ACC_0xffffL)
# define ptrdiff_t long
# define _PTRDIFF_T_DEFINED
#endif
/* Fix old compiler versions. */
#if (UINT_MAX == ACC_0xffffL)
# undef __ACC_RENAME_A
# undef __ACC_RENAME_B
# if defined(__AZTEC_C__) && defined(__DOS__)
# define __ACC_RENAME_A 1
# elif defined(_MSC_VER) && defined(MSDOS)
# if (_MSC_VER < 600)
# define __ACC_RENAME_A 1
# elif (_MSC_VER < 700)
# define __ACC_RENAME_B 1
# endif
# elif defined(__TSC__) && defined(__OS2__)
# define __ACC_RENAME_A 1
# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
# define __ACC_RENAME_A 1
# elif defined(__PACIFIC__) && defined(DOS)
# if !defined(__far)
# define __far far
# endif
# if !defined(__near)
# define __near near
# endif
# endif
# if defined(__ACC_RENAME_A)
# if !defined(__cdecl)
# define __cdecl cdecl
# endif
# if !defined(__far)
# define __far far
# endif
# if !defined(__huge)
# define __huge huge
# endif
# if !defined(__near)
# define __near near
# endif
# if !defined(__pascal)
# define __pascal pascal
# endif
# if !defined(__huge)
# define __huge huge
# endif
# elif defined(__ACC_RENAME_B)
# if !defined(__cdecl)
# define __cdecl _cdecl
# endif
# if !defined(__far)
# define __far _far
# endif
# if !defined(__huge)
# define __huge _huge
# endif
# if !defined(__near)
# define __near _near
# endif
# if !defined(__pascal)
# define __pascal _pascal
# endif
# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
# if !defined(__cdecl)
# define __cdecl cdecl
# endif
# if !defined(__pascal)
# define __pascal pascal
# endif
# endif
# undef __ACC_RENAME_A
# undef __ACC_RENAME_B
#endif
#if (UINT_MAX == ACC_0xffffL)
#if defined(__AZTEC_C__) && defined(__DOS__)
# define ACC_BROKEN_CDECL_ALT_SYNTAX 1
#elif defined(_MSC_VER) && defined(MSDOS)
# if (_MSC_VER < 600)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
# endif
# if (_MSC_VER < 700)
# define ACC_BROKEN_INTEGRAL_PROMOTION 1
# define ACC_BROKEN_SIZEOF 1
# endif
#elif defined(__PACIFIC__) && defined(DOS)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
#elif defined(__TURBOC__) && defined(__MSDOS__)
# if (__TURBOC__ < 0x0150)
# define ACC_BROKEN_CDECL_ALT_SYNTAX 1
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
# define ACC_BROKEN_INTEGRAL_PROMOTION 1
# endif
# if (__TURBOC__ < 0x0200)
# define ACC_BROKEN_SIZEOF 1
# endif
# if (__TURBOC__ < 0x0400) && defined(__cplusplus)
# define ACC_BROKEN_CDECL_ALT_SYNTAX 1
# endif
#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
# define ACC_BROKEN_CDECL_ALT_SYNTAX 1
# define ACC_BROKEN_SIZEOF 1
#endif
#endif
#if defined(__WATCOMC__) && (__WATCOMC__ < 900)
# define ACC_BROKEN_INTEGRAL_CONSTANTS 1
#endif
/***********************************************************************
// ANSI C preprocessor macros (cpp)
************************************************************************/
#define ACC_CPP_STRINGIZE(x) #x
#define ACC_CPP_MACRO_EXPAND(x) ACC_CPP_STRINGIZE(x)
/* concatenate */
#define ACC_CPP_CONCAT2(a,b) a ## b
#define ACC_CPP_CONCAT3(a,b,c) a ## b ## c
#define ACC_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
#define ACC_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
/* expand and concatenate (by using one level of indirection) */
#define ACC_CPP_ECONCAT2(a,b) ACC_CPP_CONCAT2(a,b)
#define ACC_CPP_ECONCAT3(a,b,c) ACC_CPP_CONCAT3(a,b,c)
#define ACC_CPP_ECONCAT4(a,b,c,d) ACC_CPP_CONCAT4(a,b,c,d)
#define ACC_CPP_ECONCAT5(a,b,c,d,e) ACC_CPP_CONCAT5(a,b,c,d,e)
/***********************************************************************
// stdc macros
************************************************************************/
#if defined(__cplusplus)
# undef __STDC_CONSTANT_MACROS
# undef __STDC_LIMIT_MACROS
# define __STDC_CONSTANT_MACROS 1
# define __STDC_LIMIT_MACROS 1
#endif
/***********************************************************************
// misc macros
************************************************************************/
#if defined(__cplusplus)
# define ACC_EXTERN_C extern "C"
#else
# define ACC_EXTERN_C extern
#endif
/*
vi:ts=4:et
*/
-61
View File
@@ -1,61 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#if !defined(ACC_VERSION)
# if defined ACC_CONFIG_INCLUDE
# include ACC_CONFIG_INCLUDE("acc.h")
# else
# include "acc.h"
# endif
#endif
#ifndef __ACC_INCD_H_INCLUDED
# include ACC_CONFIG_INCLUDE("acc_incd.h")
#endif
#ifndef __ACC_INCE_H_INCLUDED
# include ACC_CONFIG_INCLUDE("acc_ince.h")
#endif
#ifndef __ACC_INCI_H_INCLUDED
# include ACC_CONFIG_INCLUDE("acc_inci.h")
#endif
#ifndef __ACC_LIB_H_INCLUDED
# include ACC_CONFIG_INCLUDE("acc_lib.h")
#endif
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
#include ACC_CONFIG_INCLUDE("acclib/bele.ch")
#include ACC_CONFIG_INCLUDE("acclib/hmemcpy.ch")
#include ACC_CONFIG_INCLUDE("acclib/hstring.ch")
#include ACC_CONFIG_INCLUDE("acclib/halloc.ch")
#include ACC_CONFIG_INCLUDE("acclib/dosalloc.ch")
#include ACC_CONFIG_INCLUDE("acclib/hfread.ch")
#include ACC_CONFIG_INCLUDE("acclib/hread.ch")
#include ACC_CONFIG_INCLUDE("acclib/opendir.ch")
#include ACC_CONFIG_INCLUDE("acclib/rand.ch")
#include ACC_CONFIG_INCLUDE("acclib/misc.ch")
#if 0
/* modules which use floating point are not included by default */
#include ACC_CONFIG_INCLUDE("acclib/uclock.ch")
#endif
/*
vi:ts=4:et
*/
-526
View File
@@ -1,526 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#ifndef __ACC_LIB_H_INCLUDED
#define __ACC_LIB_H_INCLUDED 1
#if !defined(__ACCLIB_FUNCNAME)
# define __ACCLIB_FUNCNAME(f) f
#endif
#if !defined(ACCLIB_EXTERN)
# define ACCLIB_EXTERN(r,f) extern r __ACCLIB_FUNCNAME(f)
#endif
#if !defined(__ACCLIB_CONST_CAST_RETURN)
#if (ACC_CC_GNUC)
# define __ACCLIB_CONST_CAST_RETURN(type,var) \
{ union { type a; const type b; } u; u.b = (var); return u.a; }
#else
# define __ACCLIB_CONST_CAST_RETURN(type,var) return (type) (var);
#endif
#endif
#if (ACC_OS_WIN64)
# define acclib_handle_t acc_int64l_t
# define acclib_uhandle_t acc_uint64l_t
#elif (ACC_ARCH_IA32 && ACC_CC_MSC && (_MSC_VER >= 1300))
typedef __w64 long acclib_handle_t;
typedef __w64 unsigned long acclib_uhandle_t;
# define acclib_handle_t acclib_handle_t
# define acclib_uhandle_t acclib_uhandle_t
#else
# define acclib_handle_t long
# define acclib_uhandle_t unsigned long
#endif
/*************************************************************************
// wrap <ctype.h>
**************************************************************************/
#if 0
ACCLIB_EXTERN(int, acc_ascii_digit) (int);
ACCLIB_EXTERN(int, acc_ascii_islower) (int);
ACCLIB_EXTERN(int, acc_ascii_isupper) (int);
ACCLIB_EXTERN(int, acc_ascii_tolower) (int);
ACCLIB_EXTERN(int, acc_ascii_toupper) (int);
ACCLIB_EXTERN(int, acc_ascii_utolower) (int);
ACCLIB_EXTERN(int, acc_ascii_utoupper) (int);
#endif
#define acc_ascii_isdigit(c) (((unsigned)(c) - 48) < 10)
#define acc_ascii_islower(c) (((unsigned)(c) - 97) < 26)
#define acc_ascii_isupper(c) (((unsigned)(c) - 65) < 26)
#define acc_ascii_tolower(c) ((int)(c) + (acc_ascii_isupper(c) << 5))
#define acc_ascii_toupper(c) ((int)(c) - (acc_ascii_islower(c) << 5))
#define acc_ascii_utolower(c) acc_ascii_tolower((unsigned char)(c))
#define acc_ascii_utoupper(c) acc_ascii_toupper((unsigned char)(c))
/*************************************************************************
// huge pointer layer
**************************************************************************/
#ifndef acc_hsize_t
#if (ACC_HAVE_MM_HUGE_PTR)
# define acc_hsize_t unsigned long
# define acc_hvoid_p void __huge *
# define acc_hchar_p char __huge *
# define acc_hchar_pp char __huge * __huge *
# define acc_hbyte_p unsigned char __huge *
#else
# define acc_hsize_t size_t
# define acc_hvoid_p void *
# define acc_hchar_p char *
# define acc_hchar_pp char **
# define acc_hbyte_p unsigned char *
#endif
#endif
#ifndef ACC_FILE_P
#define ACC_FILE_P FILE *
#endif
/* halloc */
ACCLIB_EXTERN(acc_hvoid_p, acc_halloc) (acc_hsize_t);
ACCLIB_EXTERN(void, acc_hfree) (acc_hvoid_p);
/* dos_alloc */
#if (ACC_OS_DOS16 || ACC_OS_OS216)
ACCLIB_EXTERN(void __far*, acc_dos_alloc) (unsigned long);
ACCLIB_EXTERN(int, acc_dos_free) (void __far*);
#endif
/* string */
ACCLIB_EXTERN(int, acc_hmemcmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemset) (acc_hvoid_p, int, acc_hsize_t);
/* string */
ACCLIB_EXTERN(acc_hsize_t, acc_hstrlen) (const acc_hchar_p);
ACCLIB_EXTERN(int, acc_hstrcmp) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(int, acc_hstrncmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_ascii_hstricmp) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(int, acc_ascii_hstrnicmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_ascii_hmemicmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrstr) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstristr) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrcpy) (acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrcat) (acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_hstrscpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(int, acc_hstrscat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrccpy) (acc_hchar_p, const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemccpy) (acc_hvoid_p, const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrchr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrrchr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrichr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrrichr) (const acc_hchar_p, int);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemchr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_hmemrchr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemichr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemrichr) (const acc_hvoid_p, int, acc_hsize_t);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrspn) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrrspn) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrcspn) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hsize_t, acc_hstrrcspn) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrpbrk) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrrpbrk) (const acc_hchar_p, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrsep) (acc_hchar_pp, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_hstrrsep) (acc_hchar_pp, const acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrlwr) (acc_hchar_p);
ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrupr) (acc_hchar_p);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemlwr) (acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemupr) (acc_hvoid_p, acc_hsize_t);
/* stdio */
ACCLIB_EXTERN(acc_hsize_t, acc_hfread) (ACC_FILE_P, acc_hvoid_p, acc_hsize_t);
ACCLIB_EXTERN(acc_hsize_t, acc_hfwrite) (ACC_FILE_P, const acc_hvoid_p, acc_hsize_t);
/* io */
#if (ACC_HAVE_MM_HUGE_PTR)
ACCLIB_EXTERN(long, acc_hread) (int, acc_hvoid_p, long);
ACCLIB_EXTERN(long, acc_hwrite) (int, const acc_hvoid_p, long);
#endif
ACCLIB_EXTERN(long, acc_safe_hread) (int, acc_hvoid_p, long);
ACCLIB_EXTERN(long, acc_safe_hwrite) (int, const acc_hvoid_p, long);
/*************************************************************************
// wrap filename limits
**************************************************************************/
/* maximum length of full pathname (excl. '\0') */
#if !defined(ACC_FN_PATH_MAX)
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
# define ACC_FN_PATH_MAX 143
#elif (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN32 || ACC_OS_WIN64)
# define ACC_FN_PATH_MAX 259
#elif (ACC_OS_TOS)
# define ACC_FN_PATH_MAX 259
#endif
#endif
#if !defined(ACC_FN_PATH_MAX)
/* arbitrary limit for acclib implementation */
# define ACC_FN_PATH_MAX 1024
#endif
/* maximum length of a filename (a single path component) (excl. '\0') */
#if !defined(ACC_FN_NAME_MAX)
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
# define ACC_FN_NAME_MAX 12
#elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
# define ACC_FN_NAME_MAX 12
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
#elif (ACC_OS_DOS32)
# define ACC_FN_NAME_MAX 12
#endif
#endif
#if !defined(ACC_FN_NAME_MAX)
# define ACC_FN_NAME_MAX ACC_FN_PATH_MAX
#endif
#define ACC_FNMATCH_NOESCAPE 1
#define ACC_FNMATCH_PATHNAME 2
#define ACC_FNMATCH_PATHSTAR 4
#define ACC_FNMATCH_PERIOD 8
#define ACC_FNMATCH_ASCII_CASEFOLD 16
ACCLIB_EXTERN(int, acc_fnmatch) (const acc_hchar_p, const acc_hchar_p, int);
/*************************************************************************
// wrap <dirent.h>
**************************************************************************/
#undef __ACCLIB_USE_OPENDIR
#if (HAVE_DIRENT_H || ACC_CC_WATCOMC)
# define __ACCLIB_USE_OPENDIR 1
# if (ACC_OS_DOS32 && defined(__BORLANDC__))
# elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
# elif (ACC_OS_OS2 || ACC_OS_OS216)
# elif (ACC_OS_TOS && ACC_CC_GNUC)
# elif (ACC_OS_WIN32 && !defined(ACC_HAVE_WINDOWS_H))
# elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
# undef __ACCLIB_USE_OPENDIR
# endif
#endif
typedef struct
{
#if defined(__ACCLIB_USE_OPENDIR)
void *u_dirp; /* private */
# if (ACC_CC_WATCOMC)
unsigned short f_time;
unsigned short f_date;
unsigned long f_size;
# endif
char f_name[ACC_FN_NAME_MAX+1];
#elif (ACC_OS_WIN32 || ACC_OS_WIN64)
acclib_handle_t u_handle; /* private */
unsigned f_attr;
unsigned f_size_low;
unsigned f_size_high;
char f_name[ACC_FN_NAME_MAX+1];
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_TOS || ACC_OS_WIN16)
char u_dta[21]; /* private */
unsigned char f_attr;
unsigned short f_time;
unsigned short f_date;
unsigned short f_size_low;
unsigned short f_size_high;
char f_name[ACC_FN_NAME_MAX+1];
char u_dirp; /* private */
#else
void *u_dirp; /* private */
char f_name[ACC_FN_NAME_MAX+1];
#endif
} acc_dir_t;
#ifndef acc_dir_p
#define acc_dir_p acc_dir_t *
#endif
ACCLIB_EXTERN(int, acc_opendir) (acc_dir_p, const char*);
ACCLIB_EXTERN(int, acc_readdir) (acc_dir_p);
ACCLIB_EXTERN(int, acc_closedir) (acc_dir_p);
/*************************************************************************
// wrap misc
**************************************************************************/
#if (ACC_CC_GNUC) && (defined(__CYGWIN__) || defined(__MINGW32__))
# define acc_alloca(x) __builtin_alloca((x))
#elif (ACC_CC_BORLANDC) && defined(__linux__)
/* FIXME: alloca does not work */
#elif (HAVE_ALLOCA)
# define acc_alloca(x) alloca((x))
#endif
#if (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
# define acc_stackavail() stackavail()
#elif (ACC_ARCH_IA16 && ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0410))
# define acc_stackavail() stackavail()
#elif (ACC_ARCH_IA16 && ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0400))
# if (ACC_OS_WIN16) && (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
# else
# define acc_stackavail() stackavail()
# endif
#elif ((ACC_ARCH_IA16 || ACC_ARCH_IA32) && (ACC_CC_DMC || ACC_CC_SYMANTECC))
# define acc_stackavail() stackavail()
#elif ((ACC_ARCH_IA16) && ACC_CC_MSC && (_MSC_VER >= 700))
# define acc_stackavail() _stackavail()
#elif ((ACC_ARCH_IA16) && ACC_CC_MSC)
# define acc_stackavail() stackavail()
#elif ((ACC_ARCH_IA16 || ACC_ARCH_IA32) && ACC_CC_TURBOC && (__TURBOC__ >= 0x0450))
# define acc_stackavail() stackavail()
#elif (ACC_ARCH_IA16 && ACC_CC_TURBOC && (__TURBOC__ >= 0x0400))
ACC_EXTERN_C size_t __cdecl stackavail(void);
# define acc_stackavail() stackavail()
#elif ((ACC_ARCH_IA16 || ACC_ARCH_IA32) && (ACC_CC_WATCOMC))
# define acc_stackavail() stackavail()
#elif (ACC_ARCH_IA16 && ACC_CC_ZORTECHC)
# define acc_stackavail() _chkstack()
#endif
ACCLIB_EXTERN(acclib_handle_t, acc_get_osfhandle) (int);
ACCLIB_EXTERN(int, acc_isatty) (int);
ACCLIB_EXTERN(int, acc_mkdir) (const char*, unsigned);
ACCLIB_EXTERN(int, acc_response) (int*, char***);
ACCLIB_EXTERN(int, acc_set_binmode) (int, int);
ACCLIB_EXTERN(acc_int32l_t, acc_muldiv32) (acc_int32l_t, acc_int32l_t, acc_int32l_t);
ACCLIB_EXTERN(acc_uint32l_t, acc_umuldiv32) (acc_uint32l_t, acc_uint32l_t, acc_uint32l_t);
ACCLIB_EXTERN(void, acc_wildargv) (int*, char***);
/*************************************************************************
// uclock (real, i.e. "wall" clock)
**************************************************************************/
#if defined(acc_int32e_t)
ACCLIB_EXTERN(int, acc_tsc_read) (acc_uint32e_t*);
ACCLIB_EXTERN(int, acc_tsc_read_add) (acc_uint32e_t*);
#endif
typedef struct { /* all private */
acclib_handle_t h;
int mode;
#if (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
double qpf;
#endif
} acc_uclock_handle_t;
typedef struct { /* all private */
union {
acc_uint32l_t t32;
#if !(ACC_OS_DOS16 || ACC_OS_WIN16)
double td;
# if defined(acc_int64l_t)
acc_int64l_t t64;
# endif
#endif
} ticks;
#if (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
acc_int64l_t qpc;
#endif
} acc_uclock_t;
#ifndef acc_uclock_handle_p
#define acc_uclock_handle_p acc_uclock_handle_t *
#endif
#ifndef acc_uclock_p
#define acc_uclock_p acc_uclock_t *
#endif
ACCLIB_EXTERN(int, acc_uclock_open) (acc_uclock_handle_p);
ACCLIB_EXTERN(int, acc_uclock_close) (acc_uclock_handle_p);
ACCLIB_EXTERN(void, acc_uclock_read) (acc_uclock_handle_p, acc_uclock_p);
ACCLIB_EXTERN(double, acc_uclock_get_elapsed) (acc_uclock_handle_p, const acc_uclock_p, const acc_uclock_p);
/*************************************************************************
// performance counters (virtual clock)
**************************************************************************/
#if defined(acc_int64l_t)
typedef struct { /* all private */
void* h;
unsigned cpu_type, cpu_features, cpu_khz, cpu_nrctrs;
const char* cpu_name;
} acc_perfctr_handle_t;
typedef struct {
acc_uint64l_t tsc;
#if (ACC_OS_POSIX_LINUX)
acc_uint64l_t pmc[18];
#else
acc_uint64l_t pmc[1];
#endif
} acc_perfctr_clock_t;
#ifndef acc_perfctr_handle_p
#define acc_perfctr_handle_p acc_perfctr_handle_t *
#endif
#ifndef acc_perfctr_clock_p
#define acc_perfctr_clock_p acc_perfctr_clock_t *
#endif
ACCLIB_EXTERN(int, acc_perfctr_open) (acc_perfctr_handle_p);
ACCLIB_EXTERN(int, acc_perfctr_close) (acc_perfctr_handle_p);
ACCLIB_EXTERN(void, acc_perfctr_read) (acc_perfctr_handle_p, acc_perfctr_clock_p);
ACCLIB_EXTERN(double, acc_perfctr_get_elapsed) (acc_perfctr_handle_p, const acc_perfctr_clock_p, const acc_perfctr_clock_p);
ACCLIB_EXTERN(double, acc_perfctr_get_elapsed_tsc) (acc_perfctr_handle_p, acc_uint64l_t);
#endif
/*************************************************************************
// Big Endian / Little Endian
**************************************************************************/
ACCLIB_EXTERN(unsigned, acc_get_be16) (const acc_hvoid_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_get_be24) (const acc_hvoid_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_get_be32) (const acc_hvoid_p);
ACCLIB_EXTERN(void, acc_set_be16) (acc_hvoid_p, unsigned);
ACCLIB_EXTERN(void, acc_set_be24) (acc_hvoid_p, acc_uint32l_t);
ACCLIB_EXTERN(void, acc_set_be32) (acc_hvoid_p, acc_uint32l_t);
ACCLIB_EXTERN(unsigned, acc_get_le16) (const acc_hvoid_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_get_le24) (const acc_hvoid_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_get_le32) (const acc_hvoid_p);
ACCLIB_EXTERN(void, acc_set_le16) (acc_hvoid_p, unsigned);
ACCLIB_EXTERN(void, acc_set_le24) (acc_hvoid_p, acc_uint32l_t);
ACCLIB_EXTERN(void, acc_set_le32) (acc_hvoid_p, acc_uint32l_t);
#if defined(acc_uint64l_t)
ACCLIB_EXTERN(acc_uint64l_t, acc_get_be64) (const acc_hvoid_p);
ACCLIB_EXTERN(void, acc_set_be64) (acc_hvoid_p, acc_uint64l_t);
ACCLIB_EXTERN(acc_uint64l_t, acc_get_le64) (const acc_hvoid_p);
ACCLIB_EXTERN(void, acc_set_le64) (acc_hvoid_p, acc_uint64l_t);
#endif
/* inline versions */
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
# define ACC_GET_LE16(p) (* (const unsigned short *) (p))
# define ACC_GET_LE32(p) (* (const acc_uint32e_t *) (p))
# define ACC_SET_LE16(p,v) (* (unsigned short *) (p) = (unsigned short) (v))
# define ACC_SET_LE32(p,v) (* (acc_uint32e_t *) (p) = (acc_uint32e_t) (v))
#endif
#if (ACC_ARCH_AMD64)
# define ACC_GET_LE64(p) (* (const acc_uint64l_t *) (p))
# define ACC_SET_LE64(p,v) (* (acc_uint64l_t *) (p) = (acc_uint64l_t) (v))
#endif
/*************************************************************************
// getopt
**************************************************************************/
typedef struct {
const char* name;
int has_arg;
int* flag;
int val;
} acc_getopt_longopt_t;
#ifndef acc_getopt_longopt_p
#define acc_getopt_longopt_p acc_getopt_longopt_t *
#endif
typedef struct {
int go_argc;
char** go_argv;
const char* go_shortopts;
const acc_getopt_longopt_p longopts;
#if (ACC_BROKEN_CDECL_ALT_SYNTAX)
int __acc_cdecl_va (*go_error)(const char *, ...);
#else
int (__acc_cdecl_va *go_error)(const char *, ...);
#endif
} acc_getopt_t;
#ifndef acc_getopt_p
#define acc_getopt_p acc_getopt_t *
#endif
ACCLIB_EXTERN(void, acc_getopt_init) (acc_getopt_p);
ACCLIB_EXTERN(int, acc_getopt) (acc_getopt_p);
ACCLIB_EXTERN(void, acc_getopt_close)(acc_getopt_p);
/*************************************************************************
// rand
**************************************************************************/
typedef struct { /* all private */
acc_uint32l_t seed;
} acc_rand31_t;
#ifndef acc_rand31_p
#define acc_rand31_p acc_rand31_t *
#endif
ACCLIB_EXTERN(void, acc_srand31) (acc_rand31_p, acc_uint32l_t);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand31) (acc_rand31_p);
#if defined(acc_uint64l_t)
typedef struct { /* all private */
acc_uint64l_t seed;
} acc_rand48_t;
#ifndef acc_rand48_p
#define acc_rand48_p acc_rand48_t *
#endif
ACCLIB_EXTERN(void, acc_srand48) (acc_rand48_p, acc_uint32l_t);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand48) (acc_rand48_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p);
#endif
#if defined(acc_uint64l_t)
typedef struct { /* all private */
acc_uint64l_t seed;
} acc_rand64_t;
#ifndef acc_rand64_p
#define acc_rand64_p acc_rand64_t *
#endif
ACCLIB_EXTERN(void, acc_srand64) (acc_rand64_p, acc_uint64l_t);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand64) (acc_rand64_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p);
#endif
typedef struct { /* all private */
unsigned n;
acc_uint32l_t s[624];
} acc_randmt_t;
#ifndef acc_randmt_p
#define acc_randmt_p acc_randmt_t *
#endif
ACCLIB_EXTERN(void, acc_srandmt) (acc_randmt_p, acc_uint32l_t);
ACCLIB_EXTERN(acc_uint32l_t, acc_randmt) (acc_randmt_p);
ACCLIB_EXTERN(acc_uint32l_t, acc_randmt_r32) (acc_randmt_p);
#endif /* already included */
/*
vi:ts=4:et
*/
-199
View File
@@ -1,199 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*
* Memory Model - exactly one of:
*
* ACC_MM_FLAT [default]
* ACC_MM_TINY
* ACC_MM_SMALL
* ACC_MM_MEDIUM
* ACC_MM_COMPACT
* ACC_MM_LARGE
* ACC_MM_HUGE
*/
#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
#if (UINT_MAX != ACC_0xffffL)
# error "this should not happen"
#endif
#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
# define ACC_MM_TINY 1
#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
# define ACC_MM_HUGE 1
#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
# define ACC_MM_SMALL 1
#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
# define ACC_MM_MEDIUM 1
#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
# define ACC_MM_COMPACT 1
#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
# define ACC_MM_LARGE 1
#elif (ACC_CC_AZTECC)
# if defined(_LARGE_CODE) && defined(_LARGE_DATA)
# define ACC_MM_LARGE 1
# elif defined(_LARGE_CODE)
# define ACC_MM_MEDIUM 1
# elif defined(_LARGE_DATA)
# define ACC_MM_COMPACT 1
# else
# define ACC_MM_SMALL 1
# endif
#elif (ACC_CC_ZORTECHC && defined(__VCM__))
# define ACC_MM_LARGE 1
#else
# error "unknown memory model"
#endif
/* ACC_HAVE_MM_HUGE_PTR ... working __huge pointers
* ACC_HAVE_MM_HUGE_ARRAY ... char __huge x[256*1024L] works */
#define ACC_HAVE_MM_HUGE_PTR 1
#define ACC_HAVE_MM_HUGE_ARRAY 1
#if (ACC_MM_TINY)
# undef ACC_HAVE_MM_HUGE_ARRAY
#endif
#if (ACC_CC_AZTECC || ACC_CC_PACIFICC || ACC_CC_ZORTECHC)
# undef ACC_HAVE_MM_HUGE_PTR
# undef ACC_HAVE_MM_HUGE_ARRAY
#elif (ACC_CC_DMC || ACC_CC_SYMANTECC)
# undef ACC_HAVE_MM_HUGE_ARRAY
#elif (ACC_CC_MSC && defined(_QC))
# undef ACC_HAVE_MM_HUGE_ARRAY
# if (_MSC_VER < 600)
# undef ACC_HAVE_MM_HUGE_PTR
# endif
#elif (ACC_CC_TURBOC && (__TURBOC__ < 0x0295))
# undef ACC_HAVE_MM_HUGE_ARRAY
#elif (ACC_CC_WATCOMC && (__WATCOMC__ >= 1200))
/* pointer arithmetics with __huge arrays seems broken in OpenWatcom 1.x */
# undef ACC_HAVE_MM_HUGE_ARRAY
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if (ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (ACC_CC_MSC || ACC_CC_TOPSPEEDC)
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (ACC_CC_TURBOC && (__TURBOC__ >= 0x0295))
extern void __near __cdecl _AHSHIFT(void);
# define ACC_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif ((ACC_CC_AZTECC || ACC_CC_PACIFICC || ACC_CC_TURBOC) && ACC_OS_DOS16)
# define ACC_MM_AHSHIFT 12
#elif (ACC_CC_WATCOMC)
extern unsigned char _HShift;
# define ACC_MM_AHSHIFT ((unsigned) _HShift)
#else
# error "FIXME - implement ACC_MM_AHSHIFT"
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#elif (ACC_ARCH_C166)
#if !defined(__MODEL__)
# error "FIXME - C166 __MODEL__"
#elif ((__MODEL__) == 0)
# define ACC_MM_SMALL 1
#elif ((__MODEL__) == 1)
# define ACC_MM_SMALL 1
#elif ((__MODEL__) == 2)
# define ACC_MM_LARGE 1
#elif ((__MODEL__) == 3)
# define ACC_MM_TINY 1
#elif ((__MODEL__) == 4)
# define ACC_MM_XTINY 1
#elif ((__MODEL__) == 5)
# define ACC_MM_XSMALL 1
#else
# error "FIXME - C166 __MODEL__"
#endif
#elif (ACC_ARCH_MCS251)
#if !defined(__MODEL__)
# error "FIXME - MCS251 __MODEL__"
#elif ((__MODEL__) == 0)
# define ACC_MM_SMALL 1
#elif ((__MODEL__) == 2)
# define ACC_MM_LARGE 1
#elif ((__MODEL__) == 3)
# define ACC_MM_TINY 1
#elif ((__MODEL__) == 4)
# define ACC_MM_XTINY 1
#elif ((__MODEL__) == 5)
# define ACC_MM_XSMALL 1
#else
# error "FIXME - MCS251 __MODEL__"
#endif
#elif (ACC_ARCH_MCS51)
#if !defined(__MODEL__)
# error "FIXME - MCS51 __MODEL__"
#elif ((__MODEL__) == 1)
# define ACC_MM_SMALL 1
#elif ((__MODEL__) == 2)
# define ACC_MM_LARGE 1
#elif ((__MODEL__) == 3)
# define ACC_MM_TINY 1
#elif ((__MODEL__) == 4)
# define ACC_MM_XTINY 1
#elif ((__MODEL__) == 5)
# define ACC_MM_XSMALL 1
#else
# error "FIXME - MCS51 __MODEL__"
#endif
#else
# define ACC_MM_FLAT 1
#endif
#if (ACC_MM_FLAT)
# define ACC_INFO_MM "flat"
#elif (ACC_MM_TINY)
# define ACC_INFO_MM "tiny"
#elif (ACC_MM_SMALL)
# define ACC_INFO_MM "small"
#elif (ACC_MM_MEDIUM)
# define ACC_INFO_MM "medium"
#elif (ACC_MM_COMPACT)
# define ACC_INFO_MM "compact"
#elif (ACC_MM_LARGE)
# define ACC_INFO_MM "large"
#elif (ACC_MM_HUGE)
# define ACC_INFO_MM "huge"
#else
# error "unknown memory model"
#endif
/*
vi:ts=4:et
*/
-203
View File
@@ -1,203 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/*
* Operating System - exactly one of:
*
* ACC_OS_POSIX [default]
* ACC_OS_AMIGAOS
* ACC_OS_BEOS
* ACC_OS_CYGWIN hybrid WIN32 and POSIX
* ACC_OS_DOS16 16-bit DOS (segmented memory model)
* ACC_OS_DOS32
* ACC_OS_EMX hybrid OS/2, DOS32, WIN32 (with RSX) and POSIX
* ACC_OS_MACCLASSIC Macintosh Classic
* ACC_OS_PALMOS
* ACC_OS_OS2 OS/2
* ACC_OS_OS216 16-bit OS/2 1.x (segmented memory model)
* ACC_OS_QNX
* ACC_OS_RISCOS
* ACC_OS_TOS Atari TOS / MiNT
* ACC_OS_VMS
* ACC_OS_WIN16 16-bit Windows 3.x (segmented memory model)
* ACC_OS_WIN32
* ACC_OS_WIN64 64-bit Windows (LLP64 programming model)
*/
#if defined(__CYGWIN__) && defined(__GNUC__)
# define ACC_OS_CYGWIN 1
# define ACC_INFO_OS "cygwin"
#elif defined(__EMX__) && defined(__GNUC__)
# define ACC_OS_EMX 1
# define ACC_INFO_OS "emx"
#elif defined(__BEOS__)
# define ACC_OS_BEOS 1
# define ACC_INFO_OS "beos"
#elif defined(__QNX__)
# define ACC_OS_QNX 1
# define ACC_INFO_OS "qnx"
#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
# define ACC_OS_DOS32 1
# define ACC_INFO_OS "dos32"
#elif defined(__BORLANDC__) && defined(__DPMI16__)
# define ACC_OS_DOS16 1
# define ACC_INFO_OS "dos16"
#elif defined(__ZTC__) && defined(DOS386)
# define ACC_OS_DOS32 1
# define ACC_INFO_OS "dos32"
#elif defined(__OS2__) || defined(__OS2V2__)
# if (UINT_MAX == ACC_0xffffL)
# define ACC_OS_OS216 1
# define ACC_INFO_OS "os216"
# elif (UINT_MAX == ACC_0xffffffffL)
# define ACC_OS_OS2 1
# define ACC_INFO_OS "os2"
# else
# error "check your limits.h header"
# endif
#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
# define ACC_OS_WIN64 1
# define ACC_INFO_OS "win64"
#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
# define ACC_OS_WIN32 1
# define ACC_INFO_OS "win32"
#elif defined(__MWERKS__) && defined(__INTEL__)
# define ACC_OS_WIN32 1
# define ACC_INFO_OS "win32"
#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
# if (UINT_MAX == ACC_0xffffL)
# define ACC_OS_WIN16 1
# define ACC_INFO_OS "win16"
# elif (UINT_MAX == ACC_0xffffffffL)
# define ACC_OS_WIN32 1
# define ACC_INFO_OS "win32"
# else
# error "check your limits.h header"
# endif
#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
# if (UINT_MAX == ACC_0xffffL)
# define ACC_OS_DOS16 1
# define ACC_INFO_OS "dos16"
# elif (UINT_MAX == ACC_0xffffffffL)
# define ACC_OS_DOS32 1
# define ACC_INFO_OS "dos32"
# else
# error "check your limits.h header"
# endif
#elif defined(__WATCOMC__)
# if defined(__NT__) && (UINT_MAX == ACC_0xffffL)
/* wcl: NT host defaults to DOS target */
# define ACC_OS_DOS16 1
# define ACC_INFO_OS "dos16"
# elif defined(__NT__) && (__WATCOMC__ < 1100)
/* wcl386: Watcom C 11 defines _WIN32 */
# define ACC_OS_WIN32 1
# define ACC_INFO_OS "win32"
# else
# error "please specify a target using the -bt compiler option"
# endif
#elif defined(__palmos__)
# if (UINT_MAX == ACC_0xffffL)
# define ACC_OS_PALMOS 1
# define ACC_INFO_OS "palmos"
# else
# error "check your limits.h header"
# endif
#elif defined(__TOS__) || defined(__atarist__)
# define ACC_OS_TOS 1
# define ACC_INFO_OS "tos"
#elif defined(macintosh) && !defined(__ppc__)
# define ACC_OS_MACCLASSIC 1
# define ACC_INFO_OS "macclassic"
#elif defined(__VMS)
# define ACC_OS_VMS 1
# define ACC_INFO_OS "vms"
#else
# define ACC_OS_POSIX 1
# define ACC_INFO_OS "posix"
#endif
#if (ACC_OS_POSIX)
# if defined(_AIX) || defined(__AIX__) || defined(__aix__)
# define ACC_OS_POSIX_AIX 1
# define ACC_INFO_OS_POSIX "aix"
# elif defined(__FreeBSD__)
# define ACC_OS_POSIX_FREEBSD 1
# define ACC_INFO_OS_POSIX "freebsd"
# elif defined(__hpux__) || defined(__hpux)
# define ACC_OS_POSIX_HPUX 1
# define ACC_INFO_OS_POSIX "hpux"
# elif defined(__INTERIX)
# define ACC_OS_POSIX_INTERIX 1
# define ACC_INFO_OS_POSIX "interix"
# elif defined(__IRIX__) || defined(__irix__)
# define ACC_OS_POSIX_IRIX 1
# define ACC_INFO_OS_POSIX "irix"
# elif defined(__linux__) || defined(__linux)
# define ACC_OS_POSIX_LINUX 1
# define ACC_INFO_OS_POSIX "linux"
# elif defined(__APPLE__) || defined(__MACOS__)
# define ACC_OS_POSIX_MACOSX 1
# define ACC_INFO_OS_POSIX "macosx"
# elif defined(__NetBSD__)
# define ACC_OS_POSIX_NETBSD 1
# define ACC_INFO_OS_POSIX "netbsd"
# elif defined(__OpenBSD__)
# define ACC_OS_POSIX_OPENBSD 1
# define ACC_INFO_OS_POSIX "openbsd"
# elif defined(__osf__)
# define ACC_OS_POSIX_OSF 1
# define ACC_INFO_OS_POSIX "osf"
# elif defined(__solaris__) || defined(__sun)
# if defined(__SVR4) || defined(__svr4__)
# define ACC_OS_POSIX_SOLARIS 1
# define ACC_INFO_OS_POSIX "solaris"
# else
# define ACC_OS_POSIX_SUNOS 1
# define ACC_INFO_OS_POSIX "sunos"
# endif
# elif defined(__ultrix__) || defined(__ultrix)
# define ACC_OS_POSIX_ULTRIX 1
# define ACC_INFO_OS_POSIX "ultrix"
# else
# define ACC_OS_POSIX_UNKNOWN 1
# define ACC_INFO_OS_POSIX "unknown"
# endif
#endif
#if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
# if (UINT_MAX != ACC_0xffffL)
# error "this should not happen"
# endif
# if (ULONG_MAX != ACC_0xffffffffL)
# error "this should not happen"
# endif
#endif
#if (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_WIN32 || ACC_OS_WIN64)
# if (UINT_MAX != ACC_0xffffffffL)
# error "this should not happen"
# endif
# if (ULONG_MAX != ACC_0xffffffffL)
# error "this should not happen"
# endif
#endif
/*
vi:ts=4:et
*/
-321
View File
@@ -1,321 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
/***********************************************************************
//
************************************************************************/
#if (ACC_CC_GNUC >= 0x020800ul) /* 2.8.0 */
# define __acc_gnuc_extension__ __extension__
#else
# define __acc_gnuc_extension__
#endif
#if (SIZEOF_LONG_LONG > 0)
__acc_gnuc_extension__ typedef long long acc_llong_t;
#endif
#if (SIZEOF_UNSIGNED_LONG_LONG > 0)
__acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
#endif
#if (!(SIZEOF_SHORT > 0 && SIZEOF_INT > 0 && SIZEOF_LONG > 0))
# error "missing defines for sizes"
#endif
#if (!(SIZEOF_PTRDIFF_T > 0 && SIZEOF_SIZE_T > 0 && SIZEOF_VOID_P > 0 && SIZEOF_CHAR_P > 0))
# error "missing defines for sizes"
#endif
/***********************************************************************
// some <stdint.h> types:
// required: least & fast: acc_int32l_t, acc_int32f_t
// optional: exact32 acc_int32e_t
// optional: least64 acc_int64l_t
************************************************************************/
/* acc_int32e_t is int32_t in <stdint.h> terminology */
#if !defined(acc_int32e_t)
#if (SIZEOF_INT == 4)
# define acc_int32e_t int
# define acc_uint32e_t unsigned int
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) c##U
#elif (SIZEOF_LONG == 4)
# define acc_int32e_t long int
# define acc_uint32e_t unsigned long int
# define ACC_INT32E_C(c) c##L
# define ACC_UINT32E_C(c) c##UL
#elif (SIZEOF_SHORT == 4)
# define acc_int32e_t short int
# define acc_uint32e_t unsigned short int
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) c##U
#elif (SIZEOF_LONG_LONG == 4 && SIZEOF_UNSIGNED_LONG_LONG == 4)
# define acc_int32e_t acc_llong_t
# define acc_uint32e_t acc_ullong_t
# define ACC_INT32E_C(c) c##LL
# define ACC_UINT32E_C(c) c##ULL
#elif (SIZEOF___INT32 == 4 && SIZEOF_UNSIGNED___INT32 == 4)
# define acc_int32e_t __int32
# define acc_uint32e_t unsigned __int32
# if (SIZEOF_INT > 4)
# define ACC_INT32E_C(c) c
# define ACC_UINT32E_C(c) c##U
# elif (SIZEOF_LONG > 4)
# define ACC_INT32E_C(c) c##L
# define ACC_UINT32E_C(c) c##UL
# else
# define ACC_INT32E_C(c) c##i32
# define ACC_UINT32E_C(c) c##ui32
# endif
#else
/* no exact 32-bit integral type on this machine */
#endif
#endif
#if defined(acc_int32e_t)
# define SIZEOF_ACC_INT32E_T 4
#endif
/* acc_int32l_t is int_least32_t in <stdint.h> terminology */
#if !defined(acc_int32l_t)
#if defined(acc_int32e_t)
# define acc_int32l_t acc_int32e_t
# define acc_uint32l_t acc_uint32e_t
# define ACC_INT32L_C(c) ACC_INT32E_C(c)
# define ACC_UINT32L_C(c) ACC_UINT32E_C(c)
# define SIZEOF_ACC_INT32L_T SIZEOF_ACC_INT32E_T
#elif (SIZEOF_INT > 4)
# define acc_int32l_t int
# define acc_uint32l_t unsigned int
# define ACC_INT32L_C(c) c
# define ACC_UINT32L_C(c) c##U
# define SIZEOF_ACC_INT32L_T SIZEOF_INT
#elif (SIZEOF_LONG > 4)
# define acc_int32l_t long int
# define acc_uint32l_t unsigned long int
# define ACC_INT32L_C(c) c##L
# define ACC_UINT32L_C(c) c##UL
# define SIZEOF_ACC_INT32L_T SIZEOF_LONG
#else
# error "acc_int32l_t"
#endif
#endif
/* acc_int32f_t is int_fast32_t in <stdint.h> terminology */
#if !defined(acc_int32f_t)
#if (SIZEOF_INT >= 4)
# define acc_int32f_t int
# define acc_uint32f_t unsigned int
# define ACC_INT32F_C(c) c
# define ACC_UINT32F_C(c) c##U
# define SIZEOF_ACC_INT32F_T SIZEOF_INT
#elif (SIZEOF_LONG >= 4)
# define acc_int32f_t long int
# define acc_uint32f_t unsigned long int
# define ACC_INT32F_C(c) c##L
# define ACC_UINT32F_C(c) c##UL
# define SIZEOF_ACC_INT32F_T SIZEOF_LONG
#elif defined(acc_int32e_t)
# define acc_int32f_t acc_int32e_t
# define acc_uint32f_t acc_uint32e_t
# define ACC_INT32F_C(c) ACC_INT32E_C(c)
# define ACC_UINT32F_C(c) ACC_UINT32E_C(c)
# define SIZEOF_ACC_INT32F_T SIZEOF_ACC_INT32E_T
#else
# error "acc_int32f_t"
#endif
#endif
/* acc_int64l_t is int_least64_t in <stdint.h> terminology */
#if !defined(acc_int64l_t)
#if (SIZEOF___INT64 >= 8 && SIZEOF_UNSIGNED___INT64 >= 8)
# if (ACC_CC_BORLANDC) && !defined(ACC_CONFIG_PREFER___INT64)
# define ACC_CONFIG_PREFER___INT64 1
# endif
#endif
#if (SIZEOF_INT >= 8)
# define acc_int64l_t int
# define acc_uint64l_t unsigned int
# define ACC_INT64L_C(c) c
# define ACC_UINT64L_C(c) c##U
# define SIZEOF_ACC_INT64L_T SIZEOF_INT
#elif (SIZEOF_LONG >= 8)
# define acc_int64l_t long int
# define acc_uint64l_t unsigned long int
# define ACC_INT64L_C(c) c##L
# define ACC_UINT64L_C(c) c##UL
# define SIZEOF_ACC_INT64L_T SIZEOF_LONG
#elif (SIZEOF_LONG_LONG >= 8 && SIZEOF_UNSIGNED_LONG_LONG >= 8) && !defined(ACC_CONFIG_PREFER___INT64)
# define acc_int64l_t acc_llong_t
# define acc_uint64l_t acc_ullong_t
# if (ACC_CC_BORLANDC)
# define ACC_INT64L_C(c) ((c) + 0ll)
# define ACC_UINT64L_C(c) ((c) + 0ull)
# else
# define ACC_INT64L_C(c) c##LL
# define ACC_UINT64L_C(c) c##ULL
# endif
# define SIZEOF_ACC_INT64L_T SIZEOF_LONG_LONG
#elif (SIZEOF___INT64 >= 8 && SIZEOF_UNSIGNED___INT64 >= 8)
# define acc_int64l_t __int64
# define acc_uint64l_t unsigned __int64
# if (ACC_CC_BORLANDC)
# define ACC_INT64L_C(c) ((c) + 0i64)
# define ACC_UINT64L_C(c) ((c) + 0ui64)
# else
# define ACC_INT64L_C(c) c##i64
# define ACC_UINT64L_C(c) c##ui64
# endif
# define SIZEOF_ACC_INT64L_T SIZEOF___INT64
#else
/* no least 64-bit integral type on this machine */
#endif
#endif
#if !defined(acc_intptr_t)
#if (ACC_ARCH_IA32 && ACC_CC_MSC && (_MSC_VER >= 1300))
typedef __w64 int acc_intptr_t;
typedef __w64 unsigned int acc_uintptr_t;
# define acc_intptr_t acc_intptr_t
# define acc_uintptr_t acc_uintptr_t
# define SIZEOF_ACC_INTPTR_T SIZEOF_INT
#elif (SIZEOF_INT >= SIZEOF_VOID_P)
# define acc_intptr_t int
# define acc_uintptr_t unsigned int
# define SIZEOF_ACC_INTPTR_T SIZEOF_INT
#elif (SIZEOF_LONG >= SIZEOF_VOID_P)
# define acc_intptr_t long
# define acc_uintptr_t unsigned long
# define SIZEOF_ACC_INTPTR_T SIZEOF_LONG
#elif (SIZEOF_ACC_INT64L_T >= SIZEOF_VOID_P)
# define acc_intptr_t acc_int64l_t
# define acc_uintptr_t acc_uint64l_t
# define SIZEOF_ACC_INTPTR_T SIZEOF_ACC_INT64L_T
#else
# error "acc_intptr_t"
#endif
#endif
/* workaround for broken compilers */
#if (ACC_BROKEN_INTEGRAL_CONSTANTS)
# undef ACC_INT32E_C
# undef ACC_UINT32E_C
# undef ACC_INT32L_C
# undef ACC_UINT32L_C
# undef ACC_INT32F_C
# undef ACC_UINT32F_C
# if (SIZEOF_INT == 4)
# define ACC_INT32E_C(c) ((c) + 0)
# define ACC_UINT32E_C(c) ((c) + 0U)
# define ACC_INT32L_C(c) ((c) + 0)
# define ACC_UINT32L_C(c) ((c) + 0U)
# define ACC_INT32F_C(c) ((c) + 0)
# define ACC_UINT32F_C(c) ((c) + 0U)
# elif (SIZEOF_LONG == 4)
# define ACC_INT32E_C(c) ((c) + 0L)
# define ACC_UINT32E_C(c) ((c) + 0UL)
# define ACC_INT32L_C(c) ((c) + 0L)
# define ACC_UINT32L_C(c) ((c) + 0UL)
# define ACC_INT32F_C(c) ((c) + 0L)
# define ACC_UINT32F_C(c) ((c) + 0UL)
# else
# error "integral constants"
# endif
#endif
/***********************************************************************
// calling conventions
************************************************************************/
#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
# if (ACC_CC_GNUC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PACIFICC)
# elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
# define __acc_cdecl __cdecl
# define __acc_cdecl_atexit
# define __acc_cdecl_main __cdecl
# if (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC))
# define __acc_cdecl_qsort __pascal
# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC))
# define __acc_cdecl_qsort _stdcall
# else
# define __acc_cdecl_qsort __cdecl
# endif
# elif (ACC_CC_WATCOMC)
# define __acc_cdecl __cdecl
# else
# define __acc_cdecl __cdecl
# define __acc_cdecl_atexit __cdecl
# define __acc_cdecl_main __cdecl
# define __acc_cdecl_qsort __cdecl
# endif
# if (ACC_CC_GNUC || ACC_CC_HIGHC || ACC_CC_NDPC || ACC_CC_PACIFICC || ACC_CC_WATCOMC)
# elif (ACC_OS_OS2 && (ACC_CC_DMC || ACC_CC_SYMANTECC))
# define __acc_cdecl_sighandler __pascal
# elif (ACC_OS_OS2 && (ACC_CC_ZORTECHC))
# define __acc_cdecl_sighandler _stdcall
# elif (ACC_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
# define __acc_cdecl_sighandler __clrcall
# elif (ACC_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
# if defined(_DLL)
# define __acc_cdecl_sighandler _far _cdecl _loadds
# elif defined(_MT)
# define __acc_cdecl_sighandler _far _cdecl
# else
# define __acc_cdecl_sighandler _cdecl
# endif
# else
# define __acc_cdecl_sighandler __cdecl
# endif
#elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
# define __acc_cdecl cdecl
#endif
#if !defined(__acc_cdecl)
# define __acc_cdecl
#endif
#if !defined(__acc_cdecl_atexit)
# define __acc_cdecl_atexit
#endif
#if !defined(__acc_cdecl_main)
# define __acc_cdecl_main
#endif
#if !defined(__acc_cdecl_qsort)
# define __acc_cdecl_qsort
#endif
#if !defined(__acc_cdecl_sighandler)
# define __acc_cdecl_sighandler
#endif
#if !defined(__acc_cdecl_va)
# define __acc_cdecl_va __acc_cdecl
#endif
#if (ACC_BROKEN_CDECL_ALT_SYNTAX)
typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(int);
#elif defined(RETSIGTYPE)
typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(int);
#else
typedef void (__acc_cdecl_sighandler *acc_sighandler_t)(int);
#endif
/*
vi:ts=4:et
*/
-3
View File
@@ -1,3 +0,0 @@
fnmatch.ch
getopt.ch
perfctr.ch
-250
View File
@@ -1,250 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_BELE_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/*************************************************************************
// be16 / be24 / be32
**************************************************************************/
ACCLIB_PUBLIC(unsigned, acc_get_be16) (const acc_hvoid_p p)
{
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((unsigned)b[1]) | ((unsigned)b[0] << 8);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_get_be24) (const acc_hvoid_p p)
{
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((acc_uint32l_t)b[2]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[0] << 16);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_get_be32) (const acc_hvoid_p p)
{
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((acc_uint32l_t)b[3]) | ((acc_uint32l_t)b[2] << 8) | ((acc_uint32l_t)b[1] << 16) | ((acc_uint32l_t)b[0] << 24);
}
ACCLIB_PUBLIC(void, acc_set_be16) (acc_hvoid_p p, unsigned v)
{
acc_hbyte_p b = (acc_hbyte_p) p;
b[1] = (unsigned char) ((v >> 0) & 0xff);
b[0] = (unsigned char) ((v >> 8) & 0xff);
}
ACCLIB_PUBLIC(void, acc_set_be24) (acc_hvoid_p p, acc_uint32l_t v)
{
acc_hbyte_p b = (acc_hbyte_p) p;
b[2] = (unsigned char) ((v >> 0) & 0xff);
b[1] = (unsigned char) ((v >> 8) & 0xff);
b[0] = (unsigned char) ((v >> 16) & 0xff);
}
ACCLIB_PUBLIC(void, acc_set_be32) (acc_hvoid_p p, acc_uint32l_t v)
{
acc_hbyte_p b = (acc_hbyte_p) p;
b[3] = (unsigned char) ((v >> 0) & 0xff);
b[2] = (unsigned char) ((v >> 8) & 0xff);
b[1] = (unsigned char) ((v >> 16) & 0xff);
b[0] = (unsigned char) ((v >> 24) & 0xff);
}
ACCLIB_PUBLIC(unsigned, acc_get_le16) (const acc_hvoid_p p)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
return (* (const unsigned short *) (p));
#else
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((unsigned)b[0]) | ((unsigned)b[1] << 8);
#endif
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_get_le24) (const acc_hvoid_p p)
{
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_get_le32) (const acc_hvoid_p p)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
return (* (const acc_uint32e_t *) (p));
#else
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16) | ((acc_uint32l_t)b[3] << 24);
#endif
}
/*************************************************************************
// le16 / le24 / le32
**************************************************************************/
ACCLIB_PUBLIC(void, acc_set_le16) (acc_hvoid_p p, unsigned v)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
(* (unsigned short *) (p) = (unsigned short) (v));
#else
acc_hbyte_p b = (acc_hbyte_p) p;
b[0] = (unsigned char) ((v >> 0) & 0xff);
b[1] = (unsigned char) ((v >> 8) & 0xff);
#endif
}
ACCLIB_PUBLIC(void, acc_set_le24) (acc_hvoid_p p, acc_uint32l_t v)
{
acc_hbyte_p b = (acc_hbyte_p) p;
b[0] = (unsigned char) ((v >> 0) & 0xff);
b[1] = (unsigned char) ((v >> 8) & 0xff);
b[2] = (unsigned char) ((v >> 16) & 0xff);
}
ACCLIB_PUBLIC(void, acc_set_le32) (acc_hvoid_p p, acc_uint32l_t v)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
(* (acc_uint32e_t *) (p) = (acc_uint32e_t) (v));
#else
acc_hbyte_p b = (acc_hbyte_p) p;
b[0] = (unsigned char) ((v >> 0) & 0xff);
b[1] = (unsigned char) ((v >> 8) & 0xff);
b[2] = (unsigned char) ((v >> 16) & 0xff);
b[3] = (unsigned char) ((v >> 24) & 0xff);
#endif
}
/*************************************************************************
// be64
**************************************************************************/
#if defined(acc_uint64l_t)
ACCLIB_PUBLIC(acc_uint64l_t, acc_get_be64) (const acc_hvoid_p p)
{
const acc_hbyte_p b = (const acc_hbyte_p) p;
#if (SIZEOF_LONG >= 8) || (SIZEOF_SIZE_T >= 8)
return ((acc_uint64l_t)b[7]) | ((acc_uint64l_t)b[6] << 8) | ((acc_uint64l_t)b[5] << 16) | ((acc_uint64l_t)b[4] << 24) | ((acc_uint64l_t)b[3] << 32) | ((acc_uint64l_t)b[2] << 40) | ((acc_uint64l_t)b[1] << 48) | ((acc_uint64l_t)b[0] << 56);
#else
acc_uint32l_t v0, v1;
v1 = ((acc_uint32l_t)b[3]) | ((acc_uint32l_t)b[2] << 8) | ((acc_uint32l_t)b[1] << 16) | ((acc_uint32l_t)b[0] << 24);
b += 4;
v0 = ((acc_uint32l_t)b[3]) | ((acc_uint32l_t)b[2] << 8) | ((acc_uint32l_t)b[1] << 16) | ((acc_uint32l_t)b[0] << 24);
return ((acc_uint64l_t)v0) | ((acc_uint64l_t)v1 << 32);
#endif
}
ACCLIB_PUBLIC(void, acc_set_be64) (acc_hvoid_p p, acc_uint64l_t v)
{
acc_hbyte_p b = (acc_hbyte_p) p;
#if (SIZEOF_LONG >= 8) || (SIZEOF_SIZE_T >= 8)
b[7] = (unsigned char) ((v >> 0) & 0xff);
b[6] = (unsigned char) ((v >> 8) & 0xff);
b[5] = (unsigned char) ((v >> 16) & 0xff);
b[4] = (unsigned char) ((v >> 24) & 0xff);
b[3] = (unsigned char) ((v >> 32) & 0xff);
b[2] = (unsigned char) ((v >> 40) & 0xff);
b[1] = (unsigned char) ((v >> 48) & 0xff);
b[0] = (unsigned char) ((v >> 56) & 0xff);
#else
acc_uint32l_t x;
x = (acc_uint32l_t) (v >> 0);
b[7] = (unsigned char) ((x >> 0) & 0xff);
b[6] = (unsigned char) ((x >> 8) & 0xff);
b[5] = (unsigned char) ((x >> 16) & 0xff);
b[4] = (unsigned char) ((x >> 24) & 0xff);
x = (acc_uint32l_t) (v >> 32);
b[3] = (unsigned char) ((x >> 0) & 0xff);
b[2] = (unsigned char) ((x >> 8) & 0xff);
b[1] = (unsigned char) ((x >> 16) & 0xff);
b[0] = (unsigned char) ((x >> 24) & 0xff);
#endif
}
#endif /* acc_uint64l_t */
/*************************************************************************
// le64
**************************************************************************/
#if defined(acc_uint64l_t)
ACCLIB_PUBLIC(acc_uint64l_t, acc_get_le64) (const acc_hvoid_p p)
{
#if (ACC_ARCH_AMD64)
return (* (const acc_uint64l_t *) (p));
#elif (ACC_ARCH_IA32)
const acc_uint32e_t* b = (const acc_uint32e_t*) p;
return ((acc_uint64l_t)b[0]) | ((acc_uint64l_t)b[1] << 32);
#elif (SIZEOF_LONG >= 8) || (SIZEOF_SIZE_T >= 8)
const acc_hbyte_p b = (const acc_hbyte_p) p;
return ((acc_uint64l_t)b[0]) | ((acc_uint64l_t)b[1] << 8) | ((acc_uint64l_t)b[2] << 16) | ((acc_uint64l_t)b[3] << 24) | ((acc_uint64l_t)b[4] << 32) | ((acc_uint64l_t)b[5] << 40) | ((acc_uint64l_t)b[6] << 48) | ((acc_uint64l_t)b[7] << 56);
#else
const acc_hbyte_p b = (const acc_hbyte_p) p;
acc_uint32l_t v0, v1;
v0 = ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16) | ((acc_uint32l_t)b[3] << 24);
b += 4;
v1 = ((acc_uint32l_t)b[0]) | ((acc_uint32l_t)b[1] << 8) | ((acc_uint32l_t)b[2] << 16) | ((acc_uint32l_t)b[3] << 24);
return ((acc_uint64l_t)v0) | ((acc_uint64l_t)v1 << 32);
#endif
}
ACCLIB_PUBLIC(void, acc_set_le64) (acc_hvoid_p p, acc_uint64l_t v)
{
#if (ACC_ARCH_AMD64)
(* (acc_uint64l_t *) (p)) = v;
#elif (ACC_ARCH_IA32)
(((acc_uint32e_t *)(p))[0] = (acc_uint32e_t) (v >> 0));
(((acc_uint32e_t *)(p))[1] = (acc_uint32e_t) (v >> 32));
#elif (SIZEOF_LONG >= 8) || (SIZEOF_SIZE_T >= 8)
acc_hbyte_p b = (acc_hbyte_p) p;
b[0] = (unsigned char) ((v >> 0) & 0xff);
b[1] = (unsigned char) ((v >> 8) & 0xff);
b[2] = (unsigned char) ((v >> 16) & 0xff);
b[3] = (unsigned char) ((v >> 24) & 0xff);
b[4] = (unsigned char) ((v >> 32) & 0xff);
b[5] = (unsigned char) ((v >> 40) & 0xff);
b[6] = (unsigned char) ((v >> 48) & 0xff);
b[7] = (unsigned char) ((v >> 56) & 0xff);
#else
acc_hbyte_p b = (acc_hbyte_p) p;
acc_uint32l_t x;
x = (acc_uint32l_t) (v >> 0);
b[0] = (unsigned char) ((x >> 0) & 0xff);
b[1] = (unsigned char) ((x >> 8) & 0xff);
b[2] = (unsigned char) ((x >> 16) & 0xff);
b[3] = (unsigned char) ((x >> 24) & 0xff);
x = (acc_uint32l_t) (v >> 32);
b[4] = (unsigned char) ((x >> 0) & 0xff);
b[5] = (unsigned char) ((x >> 8) & 0xff);
b[6] = (unsigned char) ((x >> 16) & 0xff);
b[7] = (unsigned char) ((x >> 24) & 0xff);
#endif
}
#endif /* acc_uint64l_t */
/*
vi:ts=4:et
*/
-106
View File
@@ -1,106 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_DOSALLOC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
#if (ACC_OS_OS216)
ACC_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
ACC_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short);
#endif
/***********************************************************************
// dos_alloc
************************************************************************/
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
#if !defined(ACC_CC_AZTECC)
ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
{
void __far* p = 0;
union REGS ri, ro;
if ((long)size <= 0)
return p;
size = (size + 15) >> 4;
if (size > 0xffffu)
return p;
ri.x.ax = 0x4800;
ri.x.bx = (unsigned short) size;
int86(0x21, &ri, &ro);
if ((ro.x.cflag & 1) == 0) /* if carry flag not set */
p = (void __far*) ACC_MK_FP(ro.x.ax, 0);
return p;
}
ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
{
union REGS ri, ro;
struct SREGS rs;
if (!p)
return 0;
if (ACC_FP_OFF(p) != 0)
return -1;
segread(&rs);
ri.x.ax = 0x4900;
rs.es = ACC_FP_SEG(p);
int86x(0x21, &ri, &ro, &rs);
if (ro.x.cflag & 1) /* if carry flag set */
return -1;
return 0;
}
#endif
#endif
#if (ACC_OS_OS216)
ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
{
void __far* p = 0;
unsigned short sel = 0;
if ((long)size <= 0)
return p;
if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0)
p = (void __far*) ACC_MK_FP(sel, 0);
return p;
}
ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
{
if (!p)
return 0;
if (ACC_FP_OFF(p) != 0)
return -1;
if (DosFreeSeg(ACC_FP_SEG(p)) != 0)
return -1;
return 0;
}
#endif
/*
vi:ts=4:et
*/
-157
View File
@@ -1,157 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_HALLOC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
#if (ACC_HAVE_MM_HUGE_PTR)
#if 1 && (ACC_OS_DOS16 && defined(BLX286))
# define __ACCLIB_HALLOC_USE_DAH 1
#elif 1 && (ACC_OS_DOS16 && defined(DOSX286))
# define __ACCLIB_HALLOC_USE_DAH 1
#elif 1 && (ACC_OS_OS216)
# define __ACCLIB_HALLOC_USE_DAH 1
#elif 1 && (ACC_OS_WIN16)
# define __ACCLIB_HALLOC_USE_GA 1
#elif 1 && (ACC_OS_DOS16) && (ACC_CC_BORLANDC) && defined(__DPMI16__)
# define __ACCLIB_HALLOC_USE_GA 1
#endif
#endif
#if (__ACCLIB_HALLOC_USE_DAH)
#if 0 && (ACC_OS_OS216)
#include <os2.h>
#else
ACC_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
ACC_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short);
#endif
#endif
#if (__ACCLIB_HALLOC_USE_GA)
#if 0
#define STRICT 1
#include <windows.h>
#else
ACC_EXTERN_C const void __near* __far __pascal GlobalAlloc(unsigned, unsigned long);
ACC_EXTERN_C const void __near* __far __pascal GlobalFree(const void __near*);
ACC_EXTERN_C unsigned long __far __pascal GlobalHandle(unsigned);
ACC_EXTERN_C void __far* __far __pascal GlobalLock(const void __near*);
ACC_EXTERN_C int __far __pascal GlobalUnlock(const void __near*);
#endif
#endif
/***********************************************************************
// halloc
************************************************************************/
ACCLIB_PUBLIC(acc_hvoid_p, acc_halloc) (acc_hsize_t size)
{
acc_hvoid_p p = 0;
if (size <= 0)
return p;
#if 0 && defined(__palmos__)
p = MemPtrNew(size);
#elif !defined(ACC_HAVE_MM_HUGE_PTR)
if (size < (size_t) -1)
p = malloc((size_t) size);
#else
if ((long)size <= 0)
return p;
{
#if (__ACCLIB_HALLOC_USE_DAH)
unsigned short sel = 0;
if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0)
p = (acc_hvoid_p) ACC_MK_FP(sel, 0);
#elif (__ACCLIB_HALLOC_USE_GA)
const void __near* h = GlobalAlloc(2, size);
if (h) {
p = GlobalLock(h);
if (p && ACC_FP_OFF(p) != 0) {
GlobalUnlock(h);
p = 0;
}
if (!p)
GlobalFree(h);
}
#elif (ACC_CC_MSC && (_MSC_VER >= 700))
p = _halloc(size, 1);
#elif (ACC_CC_MSC || ACC_CC_WATCOMC)
p = halloc(size, 1);
#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
p = farmalloc(size);
#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
p = farmalloc(size);
#elif defined(ACC_CC_AZTECC)
p = lmalloc(size);
#else
if (size < (size_t) -1)
p = malloc((size_t) size);
#endif
}
#endif
return p;
}
ACCLIB_PUBLIC(void, acc_hfree) (acc_hvoid_p p)
{
if (!p)
return;
#if 0 && defined(__palmos__)
MemPtrFree(p);
#elif !defined(ACC_HAVE_MM_HUGE_PTR)
free(p);
#else
#if (__ACCLIB_HALLOC_USE_DAH)
if (ACC_FP_OFF(p) == 0)
DosFreeSeg((unsigned short) ACC_FP_SEG(p));
#elif (__ACCLIB_HALLOC_USE_GA)
if (ACC_FP_OFF(p) == 0) {
const void __near* h = (const void __near*) (unsigned) GlobalHandle(ACC_FP_SEG(p));
if (h) {
GlobalUnlock(h);
GlobalFree(h);
}
}
#elif (ACC_CC_MSC && (_MSC_VER >= 700))
_hfree(p);
#elif (ACC_CC_MSC || ACC_CC_WATCOMC)
hfree(p);
#elif (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
farfree((void __far*) p);
#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
farfree((void __far*) p);
#elif defined(ACC_CC_AZTECC)
lfree(p);
#else
free(p);
#endif
#endif
}
/*
vi:ts=4:et
*/
-114
View File
@@ -1,114 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_HFREAD_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/***********************************************************************
// huge pointer layer - stdio.h
************************************************************************/
ACCLIB_PUBLIC(acc_hsize_t, acc_hfread) (ACC_FILE_P fp, acc_hvoid_p buf, acc_hsize_t size)
{
#if (ACC_HAVE_MM_HUGE_PTR)
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
#define __ACCLIB_REQUIRE_HMEMCPY_CH 1
unsigned char tmp[512];
acc_hsize_t l = 0;
while (l < size)
{
size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
n = fread(tmp, 1, n, fp);
if (n == 0)
break;
__ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n);
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
acc_hbyte_p b = (acc_hbyte_p) buf;
acc_hsize_t l = 0;
while (l < size)
{
size_t n;
n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n);
if ((acc_hsize_t) n > size - l)
n = (size_t) (size - l);
n = fread((void __far*)b, 1, n, fp);
if (n == 0)
break;
b += n; l += n;
}
return l;
#else
# error "unknown memory model"
#endif
#else
return fread(buf, 1, size, fp);
#endif
}
ACCLIB_PUBLIC(acc_hsize_t, acc_hfwrite) (ACC_FILE_P fp, const acc_hvoid_p buf, acc_hsize_t size)
{
#if (ACC_HAVE_MM_HUGE_PTR)
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
#define __ACCLIB_REQUIRE_HMEMCPY_CH 1
unsigned char tmp[512];
acc_hsize_t l = 0;
while (l < size)
{
size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
__ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n);
n = fwrite(tmp, 1, n, fp);
if (n == 0)
break;
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
const acc_hbyte_p b = (const acc_hbyte_p) buf;
acc_hsize_t l = 0;
while (l < size)
{
size_t n;
n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n);
if ((acc_hsize_t) n > size - l)
n = (size_t) (size - l);
n = fwrite((void __far*)b, 1, n, fp);
if (n == 0)
break;
b += n; l += n;
}
return l;
#else
# error "unknown memory model"
#endif
#else
return fwrite(buf, 1, size, fp);
#endif
}
/*
vi:ts=4:et
*/
-111
View File
@@ -1,111 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_HMEMCPY_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/***********************************************************************
// memcmp, memcpy, memmove, memset
************************************************************************/
ACCLIB_PUBLIC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP)
const acc_hbyte_p p1 = (const acc_hbyte_p) s1;
const acc_hbyte_p p2 = (const acc_hbyte_p) s2;
if (len > 0) do
{
int d = *p1 - *p2;
if (d != 0)
return d;
p1++; p2++;
} while (--len > 0);
return 0;
#else
return memcmp(s1, s2, len);
#endif
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCPY)
acc_hbyte_p p1 = (acc_hbyte_p) dest;
const acc_hbyte_p p2 = (const acc_hbyte_p) src;
if (len <= 0 || p1 == p2)
return dest;
do
*p1++ = *p2++;
while (--len > 0);
return dest;
#else
return memcpy(dest, src, len);
#endif
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMMOVE)
acc_hbyte_p p1 = (acc_hbyte_p) dest;
const acc_hbyte_p p2 = (const acc_hbyte_p) src;
if (len <= 0 || p1 == p2)
return dest;
if (p1 < p2)
{
do
*p1++ = *p2++;
while (--len > 0);
}
else
{
p1 += len;
p2 += len;
do
*--p1 = *--p2;
while (--len > 0);
}
return dest;
#else
return memmove(dest, src, len);
#endif
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len)
{
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMSET)
acc_hbyte_p p = (acc_hbyte_p) s;
if (len > 0) do
*p++ = (unsigned char) c;
while (--len > 0);
return s;
#else
return memset(s, c, len);
#endif
}
/*
vi:ts=4:et
*/
-118
View File
@@ -1,118 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_HREAD_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/***********************************************************************
// huge pointer layer - read/write
************************************************************************/
#if (ACC_HAVE_MM_HUGE_PTR)
ACCLIB_PUBLIC(long, acc_hread) (int fd, acc_hvoid_p buf, long size)
{
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
#define __ACCLIB_REQUIRE_HMEMCPY_CH 1
unsigned char tmp[512];
long l = 0;
while (l < size)
{
int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l);
n = read(fd, tmp, n);
if (n == 0)
break;
if (n < 0)
return -1;
__ACCLIB_FUNCNAME(acc_hmemcpy)((acc_hbyte_p)buf + l, tmp, (acc_hsize_t)n);
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
acc_hbyte_p b = (acc_hbyte_p) buf;
long l = 0;
while (l < size)
{
unsigned n;
n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n);
if ((long) n > size - l)
n = (unsigned) (size - l);
n = read(fd, (void __far*)b, n);
if (n == 0)
break;
if (n == (unsigned)-1)
return -1;
b += n; l += n;
}
return l;
#else
# error "unknown memory model"
#endif
}
ACCLIB_PUBLIC(long, acc_hwrite) (int fd, const acc_hvoid_p buf, long size)
{
#if (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
#define __ACCLIB_REQUIRE_HMEMCPY_CH 1
unsigned char tmp[512];
long l = 0;
while (l < size)
{
int n = size - l > (long)sizeof(tmp) ? (int) sizeof(tmp) : (int) (size - l);
__ACCLIB_FUNCNAME(acc_hmemcpy)(tmp, (const acc_hbyte_p)buf + l, (acc_hsize_t)n);
n = write(fd, tmp, n);
if (n == 0)
break;
if (n < 0)
return -1;
l += n;
}
return l;
#elif (ACC_MM_COMPACT || ACC_MM_LARGE || ACC_MM_HUGE)
const acc_hbyte_p b = (const acc_hbyte_p) buf;
long l = 0;
while (l < size)
{
unsigned n;
n = ACC_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n);
if ((long) n > size - l)
n = (unsigned) (size - l);
n = write(fd, (void __far*)b, n);
if (n == 0)
break;
if (n == (unsigned)-1)
return -1;
b += n; l += n;
}
return l;
#else
# error "unknown memory model"
#endif
}
#endif /* #if (ACC_HAVE_MM_HUGE_PTR) */
/*
vi:ts=4:et
*/
-97
View File
@@ -1,97 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_HSREAD_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/***********************************************************************
// huge pointer layer - safe read/write
// handles partial pipe writes and interrupted system calls
************************************************************************/
ACCLIB_PUBLIC(long, acc_safe_hread) (int fd, acc_hvoid_p buf, long size)
{
acc_hbyte_p b = (acc_hbyte_p) buf;
long l = 0;
int saved_errno;
saved_errno = errno;
while (l < size)
{
long n = size - l;
#if (ACC_HAVE_MM_HUGE_PTR)
# define __ACCLIB_REQUIRE_HREAD_CH 1
errno = 0; n = acc_hread(fd, b, n);
#elif (ACC_OS_DOS32) && defined(__DJGPP__)
errno = 0; n = _read(fd, b, n);
#else
errno = 0; n = read(fd, b, n);
#endif
if (n == 0)
break;
if (n < 0) {
#if defined(EINTR)
if (errno == (EINTR)) continue;
#endif
if (errno == 0) errno = 1;
return l;
}
b += n; l += n;
}
errno = saved_errno;
return l;
}
ACCLIB_PUBLIC(long, acc_safe_hwrite) (int fd, const acc_hvoid_p buf, long size)
{
const acc_hbyte_p b = (const acc_hbyte_p) buf;
long l = 0;
int saved_errno;
saved_errno = errno;
while (l < size)
{
long n = size - l;
#if (ACC_HAVE_MM_HUGE_PTR)
# define __ACCLIB_REQUIRE_HREAD_CH 1
errno = 0; n = acc_hwrite(fd, b, n);
#elif (ACC_OS_DOS32) && defined(__DJGPP__)
errno = 0; n = _write(fd, b, n);
#else
errno = 0; n = write(fd, b, n);
#endif
if (n == 0)
break;
if (n < 0) {
#if defined(EINTR)
if (errno == (EINTR)) continue;
#endif
if (errno == 0) errno = 1;
return l;
}
b += n; l += n;
}
errno = saved_errno;
return l;
}
/*
vi:ts=4:et
*/
-566
View File
@@ -1,566 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_HSTRING_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/***********************************************************************
// strlen
************************************************************************/
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrlen) (const acc_hchar_p s)
{
/* TODO: which one is the fastest generic version? */
#if 1
const acc_hchar_p start = s; while (*s) ++s;
return (acc_hsize_t) (s - start);
#elif 1
acc_hsize_t n = 0; while (*s) ++s, ++n; return n;
#elif 1
acc_hsize_t n = 0; while (s[n]) ++n; return n;
#endif
}
/***********************************************************************
// strcmp, strncmp, ascii_stricmp, ascii_strnicmp, ascii_memicmp
************************************************************************/
ACCLIB_PUBLIC(int, acc_hstrcmp) (const acc_hchar_p p, const acc_hchar_p s)
{
for ( ; *p; ++p, ++s) {
if (*p != *s)
break;
}
return (unsigned char)*p - (unsigned char)*s;
}
ACCLIB_PUBLIC(int, acc_hstrncmp) (const acc_hchar_p p, const acc_hchar_p s, acc_hsize_t n)
{
for ( ; *p && n > 0; ++p, ++s, --n) {
if (*p != *s)
break;
}
return (unsigned char)*p - (unsigned char)*s;
}
ACCLIB_PUBLIC(int, acc_ascii_hstricmp) (const acc_hchar_p p, const acc_hchar_p s)
{
for ( ; *p; ++p, ++s) {
if (*p != *s) {
int d = acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
if (d != 0)
return d;
}
}
return acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
}
ACCLIB_PUBLIC(int, acc_ascii_hstrnicmp) (const acc_hchar_p p, const acc_hchar_p s, acc_hsize_t n)
{
for ( ; *p && n > 0; ++p, ++s, --n) {
if (*p != *s) {
int d = acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
if (d != 0)
return d;
}
}
return acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
}
ACCLIB_PUBLIC(int, acc_ascii_hmemicmp) (const acc_hvoid_p pp, const acc_hvoid_p ss, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) pp;
const acc_hbyte_p s = (const acc_hbyte_p) ss;
for ( ; n > 0; ++p, ++s, --n) {
if (*p != *s) {
int d = acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
if (d != 0)
return d;
}
}
return acc_ascii_utolower(*p) - acc_ascii_utolower(*s);
}
/***********************************************************************
// strstr, ascii_stristr, memmem, ascii_memimem
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrstr) (const acc_hchar_p p, const acc_hchar_p s)
{
acc_hsize_t pn = __ACCLIB_FUNCNAME(acc_hstrlen)(p);
acc_hsize_t sn = __ACCLIB_FUNCNAME(acc_hstrlen)(s);
return (acc_hchar_p) __ACCLIB_FUNCNAME(acc_hmemmem)(p, pn, s, sn);
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstristr) (const acc_hchar_p p, const acc_hchar_p s)
{
acc_hsize_t pn = __ACCLIB_FUNCNAME(acc_hstrlen)(p);
acc_hsize_t sn = __ACCLIB_FUNCNAME(acc_hstrlen)(s);
return (acc_hchar_p) __ACCLIB_FUNCNAME(acc_ascii_hmemimem)(p, pn, s, sn);
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmem) (const acc_hvoid_p p, acc_hsize_t pn, const acc_hvoid_p s, acc_hsize_t sn)
{
#define __ACCLIB_REQUIRE_HMEMCPY_CH 1
if (sn == 0) __ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
for ( ; pn >= sn; --pn) {
if (__ACCLIB_FUNCNAME(acc_hmemcmp)(p, s, sn) == 0)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
p = (const acc_hbyte_p)p + 1;
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p p, acc_hsize_t pn, const acc_hvoid_p s, acc_hsize_t sn)
{
if (sn == 0) __ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
for ( ; pn >= sn; --pn) {
if (__ACCLIB_FUNCNAME(acc_ascii_hmemicmp)(p, s, sn) == 0)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
p = (const acc_hbyte_p)p + 1;
}
return (acc_hvoid_p) 0;
}
/***********************************************************************
// strcpy, strcat
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrcpy) (acc_hchar_p d, const acc_hchar_p s)
{
acc_hchar_p dest = d;
while ((*d = *s) != 0) {
++d; ++s;
}
return dest;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrcat) (acc_hchar_p d, const acc_hchar_p s)
{
acc_hchar_p dest = d;
while (*d) ++d;
while ((*d = *s) != 0) {
++d; ++s;
}
return dest;
}
/***********************************************************************
// strlcpy, strlcat
************************************************************************/
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrlcpy) (acc_hchar_p d, const acc_hchar_p s, acc_hsize_t size)
{
acc_hsize_t n = 0;
if (n != size) {
do {
if ((*d = *s) == 0) return n;
++d; ++s; ++n;
} while (n != size);
d[-1] = 0;
}
while (*s) ++s, ++n;
return n;
}
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrlcat) (acc_hchar_p d, const acc_hchar_p s, acc_hsize_t size)
{
acc_hsize_t n = 0;
while (*d && n != size) ++d, ++n;
if (n != size) {
do {
if ((*d = *s) == 0) return n;
++d; ++s; ++n;
} while (n != size);
d[-1] = 0;
}
while (*s) ++s, ++n;
return n;
}
/***********************************************************************
// strscpy, strscat
// (same as strlcpy/strlcat, but just return -1 in case of failure)
************************************************************************/
ACCLIB_PUBLIC(int, acc_hstrscpy) (acc_hchar_p d, const acc_hchar_p s, acc_hsize_t size)
{
acc_hsize_t n = 0;
if (n != size) {
do {
if ((*d = *s) == 0) return 0;
++d; ++s; ++n;
} while (n != size);
d[-1] = 0;
}
return -1;
}
ACCLIB_PUBLIC(int, acc_hstrscat) (acc_hchar_p d, const acc_hchar_p s, acc_hsize_t size)
{
acc_hsize_t n = 0;
while (*d && n != size) ++d, ++n;
if (n != size) {
do {
if ((*d = *s) == 0) return 0;
++d; ++s; ++n;
} while (n != size);
d[-1] = 0;
}
return -1;
}
/***********************************************************************
// strccpy, memccpy
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrccpy) (acc_hchar_p d, const acc_hchar_p s, int c)
{
for (;;) {
if ((*d = *s) == 0) break;
if (*d++ == (char) c) return d;
++s;
}
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemccpy) (acc_hvoid_p d, const acc_hvoid_p s, int c, acc_hsize_t n)
{
acc_hbyte_p a = (acc_hbyte_p) d;
const acc_hbyte_p p = (const acc_hbyte_p) s;
const acc_hbyte_p e = (const acc_hbyte_p) s + n;
while (p != e) {
if ((*a++ = *p++) == (unsigned char) c)
return a;
}
return (acc_hvoid_p) 0;
}
/***********************************************************************
// strchr, strrchr, ascii_strichr, ascii_strrichr
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrchr) (const acc_hchar_p s, int c)
{
for ( ; *s; ++s) {
if (*s == (char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
if ((char) c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrrchr) (const acc_hchar_p s, int c)
{
const acc_hchar_p start = s;
while (*s) ++s;
if ((char) c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
for (;;) {
if (s == start) break; --s;
if (*s == (char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrichr) (const acc_hchar_p s, int c)
{
c = acc_ascii_utolower(c);
for ( ; *s; ++s) {
if (acc_ascii_utolower(*s) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
if (c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrrichr) (const acc_hchar_p s, int c)
{
const acc_hchar_p start = s;
c = acc_ascii_utolower(c);
while (*s) ++s;
if (c == 0) __ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
for (;;) {
if (s == start) break; --s;
if (acc_ascii_utolower(*s) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
return (acc_hchar_p) 0;
}
/***********************************************************************
// memchr, memrchr, ascii_memichr, ascii_memrichr
************************************************************************/
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemchr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s;
const acc_hbyte_p e = (const acc_hbyte_p) s + n;
while (p != e) {
if (*p == (unsigned char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
++p;
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemrchr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s + n;
const acc_hbyte_p e = (const acc_hbyte_p) s;
while (p != e) {
--p;
if (*p == (unsigned char) c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemichr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s;
const acc_hbyte_p e = (const acc_hbyte_p) s + n;
c = acc_ascii_utolower(c);
while (p != e) {
if (acc_ascii_utolower(*p) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
++p;
}
return (acc_hvoid_p) 0;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemrichr) (const acc_hvoid_p s, int c, acc_hsize_t n)
{
const acc_hbyte_p p = (const acc_hbyte_p) s + n;
const acc_hbyte_p e = (const acc_hbyte_p) s;
c = acc_ascii_utolower(c);
while (p != e) {
--p;
if (acc_ascii_utolower(*p) == c)
__ACCLIB_CONST_CAST_RETURN(acc_hvoid_p, p)
}
return (acc_hvoid_p) 0;
}
/***********************************************************************
// strspn, strrspn
************************************************************************/
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrspn) (const acc_hchar_p s, const acc_hchar_p accept)
{
acc_hsize_t n = 0;
for ( ; *s; ++s) {
const acc_hchar_p a;
for (a = accept; *a; ++a)
if (*s == *a)
goto acc_label_next;
break;
acc_label_next:
++n;
}
return n;
}
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrrspn) (const acc_hchar_p s, const acc_hchar_p accept)
{
acc_hsize_t n = 0;
const acc_hchar_p start = s;
while (*s) ++s;
for (;;) {
const acc_hchar_p a;
if (s == start) break; --s;
for (a = accept; *a; ++a)
if (*s == *a)
goto acc_label_next;
break;
acc_label_next:
++n;
}
return n;
}
/***********************************************************************
// strcspn, strrcspn
************************************************************************/
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrcspn) (const acc_hchar_p s, const acc_hchar_p reject)
{
acc_hsize_t n = 0;
for ( ; *s; ++s, ++n) {
const acc_hchar_p r;
for (r = reject; *r; ++r)
if (*s == *r)
return n;
}
return n;
}
ACCLIB_PUBLIC(acc_hsize_t, acc_hstrrcspn) (const acc_hchar_p s, const acc_hchar_p reject)
{
acc_hsize_t n = 0;
const acc_hchar_p start = s;
while (*s) ++s;
for ( ; ; ++n) {
const acc_hchar_p r;
if (s == start) break; --s;
for (r = reject; *r; ++r)
if (*s == *r)
return n;
}
return n;
}
/***********************************************************************
// strpbrk, strrpbrk
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrpbrk) (const acc_hchar_p s, const acc_hchar_p accept)
{
for ( ; *s; ++s) {
const acc_hchar_p a;
for (a = accept; *a; ++a) {
if (*s == *a)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
}
return (acc_hchar_p) 0;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrrpbrk) (const acc_hchar_p s, const acc_hchar_p accept)
{
const acc_hchar_p start = s;
while (*s) ++s;
for (;;) {
const acc_hchar_p a;
if (s == start) break; --s;
for (a = accept; *a; ++a) {
if (*s == *a)
__ACCLIB_CONST_CAST_RETURN(acc_hchar_p, s)
}
}
return (acc_hchar_p) 0;
}
/***********************************************************************
// strsep, strrsep
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrsep) (acc_hchar_pp ss, const acc_hchar_p delim)
{
acc_hchar_p s = *ss;
if (s) {
acc_hchar_p p = __ACCLIB_FUNCNAME(acc_hstrpbrk)(s, delim);
if (p) *p++ = 0;
*ss = p;
}
return s;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_hstrrsep) (acc_hchar_pp ss, const acc_hchar_p delim)
{
acc_hchar_p s = *ss;
if (s) {
acc_hchar_p p = __ACCLIB_FUNCNAME(acc_hstrrpbrk)(s, delim);
if (p) {
*p++ = 0;
return p;
}
*ss = (acc_hchar_p) 0;
}
return s;
}
/***********************************************************************
// ascii_strlwr, ascii_strupr, ascii_memlwr, ascii_memupr
************************************************************************/
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrlwr) (acc_hchar_p s)
{
acc_hbyte_p p = (acc_hbyte_p) s;
for ( ; *p; ++p)
*p = (unsigned char) acc_ascii_utolower(*p);
return s;
}
ACCLIB_PUBLIC(acc_hchar_p, acc_ascii_hstrupr) (acc_hchar_p s)
{
acc_hbyte_p p = (acc_hbyte_p) s;
for ( ; *p; ++p)
*p = (unsigned char) acc_ascii_utoupper(*p);
return s;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemlwr) (acc_hvoid_p s, acc_hsize_t n)
{
acc_hbyte_p p = (acc_hbyte_p) s;
acc_hbyte_p e = (acc_hbyte_p) s + n;
for ( ; p != e; ++p)
*p = (unsigned char) acc_ascii_utolower(*p);
return s;
}
ACCLIB_PUBLIC(acc_hvoid_p, acc_ascii_hmemupr) (acc_hvoid_p s, acc_hsize_t n)
{
acc_hbyte_p p = (acc_hbyte_p) s;
acc_hbyte_p e = (acc_hbyte_p) s + n;
for ( ; p != e; ++p)
*p = (unsigned char) acc_ascii_utoupper(*p);
return s;
}
/*
vi:ts=4:et
*/
-199
View File
@@ -1,199 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_MISC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/*************************************************************************
// wrap misc
**************************************************************************/
ACCLIB_PUBLIC(acclib_handle_t, acc_get_osfhandle) (int fd)
{
if (fd < 0)
return -1;
#if (ACC_OS_CYGWIN)
return get_osfhandle(fd);
#elif (ACC_OS_EMX && defined(__RSXNT__))
return -1; /* FIXME */
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
return -1; /* FIXME */
#elif (ACC_OS_WIN32 || ACC_OS_WIN64)
# if (ACC_CC_PELLESC && (__POCC__ < 280))
return -1; /* FIXME */
# elif (ACC_CC_WATCOMC && (__WATCOMC__ < 1000))
return -1; /* FIXME */
# elif (ACC_CC_WATCOMC && (__WATCOMC__ < 1100))
return _os_handle(fd);
# else
return _get_osfhandle(fd);
# endif
#else
return fd;
#endif
}
ACCLIB_PUBLIC(int, acc_set_binmode) (int fd, int binary)
{
#if (ACC_OS_TOS && defined(__MINT__))
FILE* fp; int old_binary;
if (fd == STDIN_FILENO) fp = stdin;
else if (fd == STDOUT_FILENO) fp = stdout;
else if (fd == STDERR_FILENO) fp = stderr;
else return -1;
old_binary = fp->__mode.__binary;
__set_binmode(fp, binary ? 1 : 0);
return old_binary ? 1 : 0;
#elif (ACC_OS_TOS)
ACC_UNUSED(fd); ACC_UNUSED(binary);
return -1; /* FIXME */
#elif (ACC_OS_DOS16 && (ACC_CC_AZTECC || ACC_CC_PACIFICC))
ACC_UNUSED(fd); ACC_UNUSED(binary);
return -1; /* FIXME */
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
int r; unsigned old_flags = __djgpp_hwint_flags;
ACC_COMPILE_TIME_ASSERT(O_BINARY > 0)
ACC_COMPILE_TIME_ASSERT(O_TEXT > 0)
if (fd < 0) return -1;
r = setmode(fd, binary ? O_BINARY : O_TEXT);
if ((old_flags & 1u) != (__djgpp_hwint_flags & 1u))
__djgpp_set_ctrl_c(!(old_flags & 1));
if (r == -1) return -1;
return (r & O_TEXT) ? 0 : 1;
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
if (fd < 0) return -1;
ACC_UNUSED(binary);
return 1;
#elif (ACC_OS_DOS32 && ACC_CC_HIGHC)
FILE* fp; int r;
if (fd == fileno(stdin)) fp = stdin;
else if (fd == fileno(stdout)) fp = stdout;
else if (fd == fileno(stderr)) fp = stderr;
else return -1;
r = _setmode(fp, binary ? _BINARY : _TEXT);
if (r == -1) return -1;
return (r & _BINARY) ? 1 : 0;
#elif (ACC_OS_WIN32 && ACC_CC_MWERKS) && defined(__MSL__)
ACC_UNUSED(fd); ACC_UNUSED(binary);
return -1; /* FIXME */
#elif (ACC_OS_CYGWIN && (ACC_CC_GNUC < 0x025a00ul))
ACC_UNUSED(fd); ACC_UNUSED(binary);
return -1; /* FIXME */
#elif (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
int r;
#if !defined(ACC_CC_ZORTECHC)
ACC_COMPILE_TIME_ASSERT(O_BINARY > 0)
#endif
ACC_COMPILE_TIME_ASSERT(O_TEXT > 0)
if (fd < 0) return -1;
r = setmode(fd, binary ? O_BINARY : O_TEXT);
if (r == -1) return -1;
return (r & O_TEXT) ? 0 : 1;
#else
if (fd < 0) return -1;
ACC_UNUSED(binary);
return 1;
#endif
}
ACCLIB_PUBLIC(int, acc_isatty) (int fd)
{
/* work around library implementations that think that
* any character device like `nul' is a tty */
if (fd < 0)
return 0;
#if (ACC_OS_DOS16 && !defined(ACC_CC_AZTECC))
{
union REGS ri, ro;
ri.x.ax = 0x4400; ri.x.bx = fd;
int86(0x21, &ri, &ro);
if ((ro.x.cflag & 1) == 0) /* if carry flag not set */
if ((ro.x.ax & 0x83) != 0x83)
return 0;
}
#elif (ACC_OS_DOS32 && ACC_CC_WATCOMC)
{
union REGS ri, ro;
ri.w.ax = 0x4400; ri.w.bx = (unsigned short) fd;
int386(0x21, &ri, &ro);
if ((ro.w.cflag & 1) == 0) /* if carry flag not set */
if ((ro.w.ax & 0x83) != 0x83)
return 0;
}
#elif (ACC_HAVE_WINDOWS_H)
{
acclib_handle_t h = __ACCLIB_FUNCNAME(acc_get_osfhandle)(fd);
if ((HANDLE)h != INVALID_HANDLE_VALUE)
{
DWORD d = 0;
if (GetConsoleMode((HANDLE)h, &d) == 0)
return 0; /* GetConsoleMode failed -> not a tty */
}
}
#endif
return (isatty(fd)) ? 1 : 0;
}
ACCLIB_PUBLIC(int, acc_mkdir) (const char* name, unsigned mode)
{
#if (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
ACC_UNUSED(mode);
return Dcreate(name);
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
return mkdir(name, mode);
#elif (ACC_OS_WIN32 && ACC_CC_GNUC) && defined(__PW32__)
return mkdir(name, mode);
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
ACC_UNUSED(mode);
# if (ACC_CC_HIGHC || ACC_CC_PACIFICC)
return mkdir((char*) name);
# else
return mkdir(name);
# endif
#else
return mkdir(name, mode);
#endif
}
ACCLIB_PUBLIC(acc_int32l_t, acc_muldiv32) (acc_int32l_t a, acc_int32l_t b, acc_int32l_t x)
{
acc_int32l_t r = 0;
if (x == 0) return x;
/* FIXME */
ACC_UNUSED(a); ACC_UNUSED(b);
return r;
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_umuldiv32) (acc_uint32l_t a, acc_uint32l_t b, acc_uint32l_t x)
{
acc_uint32l_t r = 0;
if (x == 0) return x;
/* FIXME */
ACC_UNUSED(a); ACC_UNUSED(b);
return r;
}
/*
vi:ts=4:et
*/
-255
View File
@@ -1,255 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_OPENDIR_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/*************************************************************************
// wrap <dirent.h>
**************************************************************************/
#if !defined(__ACCLIB_USE_OPENDIR)
#if (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
static int __ACCLIB_FUNCNAME(acc_opendir_init)(acc_dir_p f, const char* path, char* buf, size_t bufsize)
{
size_t l; char* p;
f->f_name[0] = 0; buf[0] = 0;
l = strlen(path);
if (l == 0 || bufsize <= 4 || l >= bufsize - 4)
return -1;
strcpy(buf, path); p = buf + l;
if (p[-1] == ':' || p[-1] == '\\' || p[-1] == '/')
strcpy(p, "*.*");
else
strcpy(p, "\\*.*");
return 0;
}
#endif
#endif
#if defined(__ACCLIB_USE_OPENDIR)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_p f, const char* path)
{
f->u_dirp = opendir(path);
if (!f->u_dirp)
return -2;
return __ACCLIB_FUNCNAME(acc_readdir)(f);
}
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_p f)
{
const struct dirent* dp;
f->f_name[0] = 0;
if (!f->u_dirp)
return -1;
dp = (const struct dirent*) readdir((DIR*) f->u_dirp);
if (!dp)
return -1;
if (!dp->d_name[0] || strlen(dp->d_name) >= sizeof(f->f_name))
return -1;
strcpy(f->f_name, dp->d_name);
#if (ACC_CC_WATCOMC)
ACC_COMPILE_TIME_ASSERT(sizeof(f->f_name) >= sizeof(dp->d_name))
f->f_time = dp->d_time;
f->f_date = dp->d_date;
f->f_size = dp->d_size;
#endif
return 0;
}
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_p f)
{
int r = -1;
if (f->u_dirp)
r = closedir((DIR*) f->u_dirp);
f->u_dirp = 0;
return r;
}
#elif (ACC_OS_WIN32 || ACC_OS_WIN64)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_p f, const char* path)
{
WIN32_FIND_DATAA d;
HANDLE h;
if (__ACCLIB_FUNCNAME(acc_opendir_init)(f, path, f->f_name, sizeof(f->f_name)) != 0)
return -1;
h = FindFirstFileA(f->f_name, &d);
f->f_name[0] = 0;
if ((f->u_handle = (acclib_handle_t) h) == -1)
return -1;
if (!d.cFileName[0] || strlen(d.cFileName) >= sizeof(f->f_name))
return -1;
strcpy(f->f_name, d.cFileName);
f->f_attr = d.dwFileAttributes;
f->f_size_high = d.nFileSizeHigh;
f->f_size_low = d.nFileSizeLow;
return 0;
}
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_p f)
{
WIN32_FIND_DATAA d;
f->f_name[0] = 0;
if (f->u_handle == -1 || FindNextFileA((HANDLE) f->u_handle, &d) == 0)
return -1;
if (!d.cFileName[0] || strlen(d.cFileName) >= sizeof(f->f_name))
return -1;
strcpy(f->f_name, d.cFileName);
f->f_attr = d.dwFileAttributes;
f->f_size_high = d.nFileSizeHigh;
f->f_size_low = d.nFileSizeLow;
return 0;
}
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_p f)
{
int r = -1;
if (f->u_handle != -1)
r = FindClose((HANDLE) f->u_handle);
f->u_handle = -1;
return r;
}
#elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_WIN16)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_p f, const char* path)
{
char tmp[ACC_FN_PATH_MAX+1];
int r;
f->u_dirp = 0;
if (__ACCLIB_FUNCNAME(acc_opendir_init)(f, path, tmp, sizeof(tmp)) != 0)
return -1;
#if (ACC_CC_AZTECC || ACC_CC_PACIFICC)
r = -1;
#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
r = findfirst(tmp, (struct ffblk*) f->u_dta, FA_HIDDEN|FA_SYSTEM|FA_RDONLY|FA_DIREC);
#else
r = _dos_findfirst(tmp, _A_HIDDEN|_A_SYSTEM|_A_RDONLY|_A_SUBDIR, (struct find_t*) f->u_dta);
#endif
if (r != 0) f->f_name[0] = 0;
if (!f->f_name[0]) return -1;
f->u_dirp = 1;
return 0;
}
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_p f)
{
int r;
f->f_name[0] = 0;
if (!f->u_dirp)
return -1;
#if (ACC_CC_AZTECC || ACC_CC_PACIFICC)
r = -1;
#elif (ACC_CC_BORLANDC || ACC_CC_TURBOC)
r = findnext((struct ffblk*) f->u_dta);
#else
r = _dos_findnext((struct find_t*) f->u_dta);
#endif
if (r != 0) f->f_name[0] = 0;
if (!f->f_name[0]) return -1;
return 0;
}
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_p f)
{
ACC_COMPILE_TIME_ASSERT(sizeof(*f) == 44);
f->f_name[0] = 0;
f->u_dirp = 0;
return 0;
}
#elif (ACC_OS_TOS)
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_p f, const char* path)
{
char tmp[ACC_FN_PATH_MAX+1];
int r;
DTA* olddta;
f->u_dirp = 0;
if (__ACCLIB_FUNCNAME(acc_opendir_init)(f, path, tmp, sizeof(tmp)) != 0)
return -1;
olddta = Fgetdta();
Fsetdta((DTA*) f->u_dta);
r = Fsfirst(tmp, FA_HIDDEN|FA_SYSTEM|FA_READONLY|FA_SUBDIR);
Fsetdta(olddta);
if (r != 0) f->f_name[0] = 0;
if (!f->f_name[0]) return -1;
f->u_dirp = 1;
return 0;
}
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_p f)
{
int r;
DTA* olddta;
f->f_name[0] = 0;
if (!f->u_dirp)
return -1;
olddta = Fgetdta();
Fsetdta((DTA*) f->u_dta);
r = Fsnext();
Fsetdta(olddta);
if (r != 0) f->f_name[0] = 0;
if (!f->f_name[0]) return -1;
return 0;
}
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_p f)
{
ACC_COMPILE_TIME_ASSERT(sizeof(*f) == 44);
f->f_name[0] = 0;
f->u_dirp = 0;
return 0;
}
#else
ACCLIB_PUBLIC(int, acc_opendir) (acc_dir_p f, const char* path)
{
ACC_UNUSED(path);
f->f_name[0] = 0;
return -3;
}
ACCLIB_PUBLIC(int, acc_readdir) (acc_dir_p f)
{
f->f_name[0] = 0;
return -1;
}
ACCLIB_PUBLIC(int, acc_closedir) (acc_dir_p f)
{
f->u_dirp = 0;
return -1;
}
#endif
/*
vi:ts=4:et
*/
-135
View File
@@ -1,135 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_RAND_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/*************************************************************************
// some linear congruential pseudo random number generators (PRNG)
**************************************************************************/
ACCLIB_PUBLIC(void, acc_srand31) (acc_rand31_p r, acc_uint32l_t seed)
{
r->seed = seed & ACC_UINT32L_C(0xffffffff);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand31) (acc_rand31_p r)
{
r->seed = r->seed * ACC_UINT32L_C(1103515245) + 12345;
r->seed &= ACC_UINT32L_C(0x7fffffff);
return r->seed;
}
#if defined(acc_uint64l_t)
ACCLIB_PUBLIC(void, acc_srand48) (acc_rand48_p r, acc_uint32l_t seed)
{
r->seed = seed & ACC_UINT32L_C(0xffffffff);
r->seed <<= 16; r->seed |= 0x330e;
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand48) (acc_rand48_p r)
{
r->seed = r->seed * ACC_UINT64L_C(25214903917) + 11;
r->seed &= ACC_UINT64L_C(0xffffffffffff);
return (acc_uint32l_t) (r->seed >> 17);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p r)
{
r->seed = r->seed * ACC_UINT64L_C(25214903917) + 11;
r->seed &= ACC_UINT64L_C(0xffffffffffff);
return (acc_uint32l_t) (r->seed >> 16);
}
#endif /* acc_uint64l_t */
#if defined(acc_uint64l_t)
ACCLIB_PUBLIC(void, acc_srand64) (acc_rand64_p r, acc_uint64l_t seed)
{
r->seed = seed & ACC_UINT64L_C(0xffffffffffffffff);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand64) (acc_rand64_p r)
{
r->seed = r->seed * ACC_UINT64L_C(6364136223846793005) + 1;
#if (SIZEOF_ACC_INT64L_T > 8)
r->seed &= ACC_UINT64L_C(0xffffffffffffffff);
#endif
return (acc_uint32l_t) (r->seed >> 33);
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p r)
{
r->seed = r->seed * ACC_UINT64L_C(6364136223846793005) + 1;
#if (SIZEOF_ACC_INT64L_T > 8)
r->seed &= ACC_UINT64L_C(0xffffffffffffffff);
#endif
return (acc_uint32l_t) (r->seed >> 32);
}
#endif /* acc_uint64l_t */
/*************************************************************************
// mersenne twister PRNG
**************************************************************************/
ACCLIB_PUBLIC(void, acc_srandmt) (acc_randmt_p r, acc_uint32l_t seed)
{
unsigned i = 0;
do {
r->s[i++] = (seed &= ACC_UINT32L_C(0xffffffff));
seed ^= seed >> 30;
seed = seed * ACC_UINT32L_C(0x6c078965) + i;
} while (i != 624);
r->n = i;
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_randmt) (acc_randmt_p r)
{
return (__ACCLIB_FUNCNAME(acc_randmt_r32)(r)) >> 1;
}
ACCLIB_PUBLIC(acc_uint32l_t, acc_randmt_r32) (acc_randmt_p r)
{
acc_uint32l_t v;
if (r->n == 624) {
int i = 0, j;
r->n = 0;
do {
j = i - 623; if (j < 0) j += 624;
v = (r->s[i] & ACC_UINT32L_C(0x80000000)) ^ (r->s[j] & ACC_UINT32L_C(0x7fffffff));
j = i - 227; if (j < 0) j += 624;
r->s[i] = r->s[j] ^ (v >> 1);
if (v & 1) r->s[i] ^= ACC_UINT32L_C(0x9908b0df);
} while (++i != 624);
}
v = r->s[r->n++];
v ^= v >> 11; v ^= (v & ACC_UINT32L_C(0x013a58ad)) << 7;
v ^= (v & ACC_UINT32L_C(0x0001df8c)) << 15; v ^= v >> 18;
return v;
}
/*
vi:ts=4:et
*/
-116
View File
@@ -1,116 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_RDTSC_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
#if defined(acc_int32e_t)
#if ((ACC_ARCH_AMD64 || ACC_ARCH_IA32) && ACC_CC_GNUC)
# if (ACC_CC_GNUC >= 0x020000ul)
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "cc", "memory", "eax", "edx"
# else
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "ax", "dx"
# endif
#elif (ACC_ARCH_IA32 && ACC_CC_INTELC) && defined(__linux__)
# define __ACCLIB_RDTSC_REGS : : "r" (t) : "memory", "eax", "edx"
#endif
/*************************************************************************
// read TSC
**************************************************************************/
ACCLIB_PUBLIC(int, acc_tsc_read) (acc_uint32e_t* t)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32) && defined(__ACCLIB_RDTSC_REGS)
__asm__ __volatile__(
"clc \n" ".byte 0x0f, 0x31\n"
"movl %%eax,(%0)\n" "movl %%edx,4(%0)\n"
__ACCLIB_RDTSC_REGS
);
return 0;
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
ACC_UNUSED(t);
__asm {
mov ecx, t
clc
# if (ACC_CC_MSC && (_MSC_VER < 1200))
_emit 0x0f
_emit 0x31
# else
rdtsc
# endif
mov [ecx], eax
mov [ecx+4], edx
}
return 0;
#else
t[0] = t[1] = 0;
return -1;
#endif
}
/*************************************************************************
// read and add TSC
**************************************************************************/
ACCLIB_PUBLIC(int, acc_tsc_read_add) (acc_uint32e_t* t)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32) && defined(__ACCLIB_RDTSC_REGS)
__asm__ __volatile__(
"clc \n" ".byte 0x0f, 0x31\n"
"addl %%eax,(%0)\n" "adcl $0,%%edx\n" "addl %%edx,4(%0)\n"
__ACCLIB_RDTSC_REGS
);
return 0;
#elif (ACC_ARCH_IA32 && (ACC_OS_DOS32 || ACC_OS_WIN32) && (ACC_CC_DMC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC))
ACC_UNUSED(t);
__asm {
mov ecx, t
clc
# if (ACC_CC_MSC && (_MSC_VER < 1200))
_emit 0x0f
_emit 0x31
# else
rdtsc
# endif
add [ecx], eax
adc edx, 0
add [ecx+4], edx
}
return 0;
#else
acc_uint32e_t v[2];
int r;
r = acc_tsc_read(v);
t[0] += v[0];
if (t[0] < v[0]) t[1] += 1;
t[1] += v[1];
return r;
#endif
}
#endif /* defined(acc_int32e_t) */
/*
vi:ts=4:et
*/
-230
View File
@@ -1,230 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_UCLOCK_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
#elif (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64) && (ACC_HAVE_WINDOWS_H)
# if defined(acc_int64l_t)
/* See also: KB Q274323: PRB: Performance Counter Value May
* Unexpectedly Leap Forward */
# define __ACCLIB_UCLOCK_USE_QPC 1
# endif
/* fallbacks */
# if ((ACC_CC_DMC && (__DMC__ < 0x838)) || ACC_CC_LCC)
/* winmm.lib is missing */
# define __ACCLIB_UCLOCK_USE_CLOCK 1
# else
# define __ACCLIB_UCLOCK_USE_WINMM 1
# if (ACC_CC_MSC && (_MSC_VER >= 900))
/* avoid `-W4' warnings in <mmsystem.h> */
# pragma warning(disable: 4201)
# elif (ACC_CC_MWERKS)
/* avoid duplicate typedef in <mmsystem.h> */
# define LPUINT __ACC_MMSYSTEM_H_LPUINT
# endif
# if 1
# include <mmsystem.h>
# else
# if (ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC)
ACC_EXTERN_C __declspec(dllimport) unsigned long __stdcall timeGetTime(void);
# else
ACC_EXTERN_C unsigned long __stdcall timeGetTime(void);
# endif
# endif
# if (ACC_CC_DMC)
# pragma DMC includelib "winmm.lib"
# elif (ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_PELLESC)
# pragma comment(lib, "winmm.lib")
# elif (ACC_CC_MWERKS && (__MWERKS__ >= 0x3000))
# pragma comment(lib, "winmm.lib")
# elif (ACC_CC_SYMANTECC)
# pragma SC includelib "winmm.lib"
# elif (ACC_CC_WATCOMC && (__WATCOMC__ >= 1050))
# pragma library("winmm.lib")
# endif
# endif
#elif (ACC_OS_EMX) && (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
# define __ACCLIB_UCLOCK_USE_QPC 1
#elif (ACC_OS_CYGWIN || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN32 || ACC_OS_WIN64)
# define __ACCLIB_UCLOCK_USE_CLOCK 1
#endif
#if (__ACCLIB_UCLOCK_USE_CLOCK) && !defined(CLOCKS_PER_SEC)
# if defined(CLK_TCK)
# define CLOCKS_PER_SEC CLK_TCK
# else
# undef __ACCLIB_UCLOCK_USE_CLOCK
# endif
#endif
/*************************************************************************
//
**************************************************************************/
ACCLIB_PUBLIC(int, acc_uclock_open) (acc_uclock_handle_p h)
{
acc_uclock_t c;
int i;
#if (__ACCLIB_UCLOCK_USE_QPC)
LARGE_INTEGER li;
h->qpf = 0.0;
if (QueryPerformanceFrequency(&li) != 0) {
h->qpf = (double) li.QuadPart;
if (h->qpf <= 0.0 || QueryPerformanceCounter(&li) == 0) {
h->qpf = 0.0;
}
}
#elif (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
h->qpf = 0.0;
#endif
h->h = 1;
h->mode = 0;
/* warm up */
i = 100;
do {
acc_uclock_read(h, &c);
#if (__ACCLIB_UCLOCK_USE_QPC)
if (h->qpf > 0.0 && c.qpc == 0) { h->qpf = 0.0; i = 100; }
#endif
} while (--i > 0);
return 0;
}
ACCLIB_PUBLIC(int, acc_uclock_close) (acc_uclock_handle_p h)
{
h->h = 0;
h->mode = -1;
return 0;
}
/*************************************************************************
//
**************************************************************************/
ACCLIB_PUBLIC(void, acc_uclock_read) (acc_uclock_handle_p h, acc_uclock_p c)
{
#if (__ACCLIB_UCLOCK_USE_QPC)
if (h->qpf > 0.0) {
LARGE_INTEGER li;
if (QueryPerformanceCounter(&li) != 0) {
c->qpc = (acc_int64l_t) li.QuadPart;
if (c->qpc > 0)
return;
}
c->qpc = 0; /* failed */
}
#elif (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
/* c->qpc = 0; */
#endif
{
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
# if (ACC_CC_AZTECC)
c->ticks.t32 = 0;
# else
union REGS ri, ro;
ri.x.ax = 0x2c00; int86(0x21, &ri, &ro);
c->ticks.t32 = ro.h.ch*60UL*60UL*100UL + ro.h.cl*60UL*100UL + ro.h.dh*100UL + ro.h.dl;
# endif
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
c->ticks.t64 = uclock();
#elif (__ACCLIB_UCLOCK_USE_CLOCK) && defined(acc_int64l_t)
c->ticks.t64 = clock();
#elif (__ACCLIB_UCLOCK_USE_CLOCK)
c->ticks.t32 = clock();
#elif (__ACCLIB_UCLOCK_USE_WINMM)
c->ticks.t32 = timeGetTime();
#elif (__ACCLIB_UCLOCK_USE_GETRUSAGE)
struct rusage ru;
if (getrusage(RUSAGE_SELF, &ru) != 0) c->ticks.rd = 0;
else c->ticks.td = ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1000000.0;
#elif (HAVE_GETTIMEOFDAY)
struct timeval tv;
if (gettimeofday(&tv, 0) != 0) c->ticks.td = 0;
else c->ticks.td = tv.tv_sec + tv.tv_usec / 1000000.0;
#else
ACC_UNUSED(c);
#endif
}
ACC_UNUSED(h);
}
/*************************************************************************
//
**************************************************************************/
ACCLIB_PUBLIC(double, acc_uclock_get_elapsed) (acc_uclock_handle_p h, const acc_uclock_p start, const acc_uclock_p stop)
{
double d;
if (!h->h) {
h->mode = -1;
return 0.0;
}
#if (__ACCLIB_UCLOCK_USE_QPC)
if (h->qpf > 0.0) {
h->mode = 1;
if (start->qpc == 0 || stop->qpc == 0) return 0.0;
return (double) (stop->qpc - start->qpc) / h->qpf;
}
#endif
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
h->mode = 2;
d = (double) (stop->ticks.t32 - start->ticks.t32) / 100.0;
if (d < 0.0) d += 86400.0; /* midnight passed */
#elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
h->mode = 3;
d = (double) (stop->ticks.t64 - start->ticks.t64) / (UCLOCKS_PER_SEC);
#elif (__ACCLIB_UCLOCK_USE_CLOCK) && defined(acc_int64l_t)
h->mode = 4;
d = (double) (stop->ticks.t64 - start->ticks.t64) / (CLOCKS_PER_SEC);
#elif (__ACCLIB_UCLOCK_USE_CLOCK)
h->mode = 5;
d = (double) (stop->ticks.t32 - start->ticks.t32) / (CLOCKS_PER_SEC);
#elif (__ACCLIB_UCLOCK_USE_WINMM)
h->mode = 6;
d = (double) (stop->ticks.t32 - start->ticks.t32) / 1000.0;
#elif (__ACCLIB_UCLOCK_USE_GETRUSAGE)
h->mode = 7;
d = stop->ticks.td - start->ticks.td;
#elif (HAVE_GETTIMEOFDAY)
h->mode = 8;
d = stop->ticks.td - start->ticks.td;
#else
h->mode = 0;
d = 0.0;
#endif
return d;
}
/*
vi:ts=4:et
*/
-72
View File
@@ -1,72 +0,0 @@
/* ACC -- Automatic Compiler Configuration
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
This software is a copyrighted work licensed under the terms of
the GNU General Public License. Please consult the file "ACC_LICENSE"
for details.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/
*/
#define __ACCLIB_WILDARGV_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
/*************************************************************************
//
**************************************************************************/
#if (ACC_OS_DOS16 || ACC_OS216 || ACC_OS_WIN16)
#if 0 && (ACC_CC_MSC)
/* FIXME */
ACC_EXTERN_C int __acc_cdecl __setargv(void);
ACC_EXTERN_C int __acc_cdecl _setargv(void);
ACC_EXTERN_C int __acc_cdecl _setargv(void) { return __setargv(); }
#endif
#endif
#if (ACC_OS_WIN32 || ACC_OS_WIN64)
#if (ACC_CC_INTELC || ACC_CC_MSC)
ACC_EXTERN_C int __acc_cdecl __setargv(void);
ACC_EXTERN_C int __acc_cdecl _setargv(void);
ACC_EXTERN_C int __acc_cdecl _setargv(void) { return __setargv(); }
#endif
#endif
#if (ACC_OS_EMX)
#define __ACCLIB_HAVE_ACC_WILDARGV 1
ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv)
{
_response(argc, argv);
_wildcard(argc, argv);
}
#endif
#if !defined(__ACCLIB_HAVE_ACC_WILDARGV)
#define __ACCLIB_HAVE_ACC_WILDARGV 1
ACCLIB_PUBLIC(void, acc_wildargv) (int* argc, char*** argv)
{
ACC_UNUSED(argc); ACC_UNUSED(argv);
}
#endif
/*
vi:ts=4:et
*/
+281 -212
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2005 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -34,132 +34,147 @@
// core // core
**************************************************************************/ **************************************************************************/
inline unsigned get_be16(const void *bb) inline unsigned get_be16(const void *p)
{ {
const unsigned char* b = (const unsigned char*) bb; #if defined(ACC_UA_GET_BE16)
unsigned v; return ACC_UA_GET_BE16(p);
v = (unsigned) b[1] << 0;
v |= (unsigned) b[0] << 8;
return v;
}
inline void set_be16(void *bb, unsigned v)
{
unsigned char* b = (unsigned char*) bb;
b[1] = (unsigned char) (v >> 0);
b[0] = (unsigned char) (v >> 8);
}
inline unsigned get_be24(const void *bb)
{
const unsigned char* b = (const unsigned char*) bb;
unsigned v;
v = (unsigned) b[2] << 0;
v |= (unsigned) b[1] << 8;
v |= (unsigned) b[0] << 16;
return v;
}
inline void set_be24(void *bb, unsigned v)
{
unsigned char* b = (unsigned char*) bb;
b[2] = (unsigned char) (v >> 0);
b[1] = (unsigned char) (v >> 8);
b[0] = (unsigned char) (v >> 16);
}
inline unsigned get_be32(const void *bb)
{
const unsigned char* b = (const unsigned char*) bb;
unsigned v;
v = (unsigned) b[3] << 0;
v |= (unsigned) b[2] << 8;
v |= (unsigned) b[1] << 16;
v |= (unsigned) b[0] << 24;
return v;
}
inline void set_be32(void *bb, unsigned v)
{
unsigned char* b = (unsigned char*) bb;
b[3] = (unsigned char) (v >> 0);
b[2] = (unsigned char) (v >> 8);
b[1] = (unsigned char) (v >> 16);
b[0] = (unsigned char) (v >> 24);
}
inline unsigned get_le16(const void *bb)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
return * (const unsigned short *) bb;
#else #else
const unsigned char* b = (const unsigned char*) bb; return acc_ua_get_be16(p);
unsigned v;
v = (unsigned) b[0] << 0;
v |= (unsigned) b[1] << 8;
return v;
#endif #endif
} }
inline void set_le16(void *bb, unsigned v) inline void set_be16(void *p, unsigned v)
{ {
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32) #if defined(ACC_UA_SET_BE16)
(* (unsigned short *) bb) = (unsigned short) (v & 0xffff); ACC_UA_SET_BE16(p, v);
#else #else
unsigned char* b = (unsigned char*) bb; acc_ua_set_be16(p, v);
b[0] = (unsigned char) (v >> 0);
b[1] = (unsigned char) (v >> 8);
#endif #endif
} }
inline unsigned get_be24(const void *p)
inline unsigned get_le24(const void *bb)
{ {
const unsigned char* b = (const unsigned char*) bb; #if defined(ACC_UA_GET_BE24)
unsigned v; return ACC_UA_GET_BE24(p);
v = (unsigned) b[0] << 0;
v |= (unsigned) b[1] << 8;
v |= (unsigned) b[2] << 16;
return v;
}
inline void set_le24(void *bb, unsigned v)
{
unsigned char* b = (unsigned char*) bb;
b[0] = (unsigned char) (v >> 0);
b[1] = (unsigned char) (v >> 8);
b[2] = (unsigned char) (v >> 16);
}
inline unsigned get_le32(const void *bb)
{
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
return * (const acc_uint32e_t *) bb;
#else #else
const unsigned char* b = (const unsigned char*) bb; return acc_ua_get_be24(p);
unsigned v;
v = (unsigned) b[0] << 0;
v |= (unsigned) b[1] << 8;
v |= (unsigned) b[2] << 16;
v |= (unsigned) b[3] << 24;
return v;
#endif #endif
} }
inline void set_le32(void *bb, unsigned v) inline void set_be24(void *p, unsigned v)
{ {
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32) #if defined(ACC_UA_SET_BE24)
(* (acc_uint32e_t *) bb) = v; ACC_UA_SET_BE24(p, v);
#else #else
unsigned char* b = (unsigned char*) bb; acc_ua_set_be24(p, v);
b[0] = (unsigned char) (v >> 0); #endif
b[1] = (unsigned char) (v >> 8); }
b[2] = (unsigned char) (v >> 16);
b[3] = (unsigned char) (v >> 24); inline unsigned get_be32(const void *p)
{
#if defined(ACC_UA_GET_BE32)
return ACC_UA_GET_BE32(p);
#else
return acc_ua_get_be32(p);
#endif
}
inline void set_be32(void *p, unsigned v)
{
#if defined(ACC_UA_SET_BE32)
ACC_UA_SET_BE32(p, v);
#else
acc_ua_set_be32(p, v);
#endif
}
inline acc_uint64l_t get_be64(const void *p)
{
#if defined(ACC_UA_GET_BE64)
return ACC_UA_GET_BE64(p);
#else
return acc_ua_get_be64(p);
#endif
}
inline void set_be64(void *p, acc_uint64l_t v)
{
#if defined(ACC_UA_SET_BE64)
ACC_UA_SET_BE64(p, v);
#else
acc_ua_set_be64(p, v);
#endif
}
inline unsigned get_le16(const void *p)
{
#if defined(ACC_UA_GET_LE16)
return ACC_UA_GET_LE16(p);
#else
return acc_ua_get_le16(p);
#endif
}
inline void set_le16(void *p, unsigned v)
{
#if defined(ACC_UA_SET_LE16)
ACC_UA_SET_LE16(p, v);
#else
acc_ua_set_le16(p, v);
#endif
}
inline unsigned get_le24(const void *p)
{
#if defined(ACC_UA_GET_LE24)
return ACC_UA_GET_LE24(p);
#else
return acc_ua_get_le24(p);
#endif
}
inline void set_le24(void *p, unsigned v)
{
#if defined(ACC_UA_SET_LE24)
ACC_UA_SET_LE24(p, v);
#else
acc_ua_set_le24(p, v);
#endif
}
inline unsigned get_le32(const void *p)
{
#if defined(ACC_UA_GET_LE32)
return ACC_UA_GET_LE32(p);
#else
return acc_ua_get_le32(p);
#endif
}
inline void set_le32(void *p, unsigned v)
{
#if defined(ACC_UA_SET_LE32)
ACC_UA_SET_LE32(p, v);
#else
acc_ua_set_le32(p, v);
#endif
}
inline acc_uint64l_t get_le64(const void *p)
{
#if defined(ACC_UA_GET_LE64)
return ACC_UA_GET_LE64(p);
#else
return acc_ua_get_le64(p);
#endif
}
inline void set_le64(void *p, acc_uint64l_t v)
{
#if defined(ACC_UA_SET_LE64)
ACC_UA_SET_LE64(p, v);
#else
acc_ua_set_le64(p, v);
#endif #endif
} }
@@ -170,241 +185,295 @@ inline void set_le32(void *bb, unsigned v)
inline int sign_extend(int v, int bits) inline int sign_extend(int v, int bits)
{ {
const int sign_bit = 1 << (bits - 1); const unsigned sign_bit = 1u << (bits - 1);
v |= -(v & sign_bit); v |= 0u - (v & sign_bit);
return v; return v;
} }
inline int get_be16_signed(const void *bb) inline acc_int64l_t sign_extend(acc_int64l_t v, int bits)
{ {
int v = get_be16(bb); const acc_uint64l_t sign_bit = ACC_UINT64_C(1) << (bits - 1);
v |= ACC_UINT64_C(0) - (v & sign_bit);
return v;
}
inline int get_be16_signed(const void *p)
{
int v = get_be16(p);
return sign_extend(v, 16); return sign_extend(v, 16);
} }
inline int get_be24_signed(const void *bb) inline int get_be24_signed(const void *p)
{ {
int v = get_be24(bb); int v = get_be24(p);
return sign_extend(v, 24); return sign_extend(v, 24);
} }
inline int get_be32_signed(const void *bb) inline int get_be32_signed(const void *p)
{ {
int v = get_be32(bb); int v = get_be32(p);
return sign_extend(v, 32); return sign_extend(v, 32);
} }
inline int get_le16_signed(const void *bb) inline acc_int64l_t get_be64_signed(const void *p)
{ {
int v = get_le16(bb); acc_int64l_t v = get_be64(p);
return sign_extend(v, 64);
}
inline int get_le16_signed(const void *p)
{
int v = get_le16(p);
return sign_extend(v, 16); return sign_extend(v, 16);
} }
inline int get_le24_signed(const void *bb) inline int get_le24_signed(const void *p)
{ {
int v = get_le24(bb); int v = get_le24(p);
return sign_extend(v, 24); return sign_extend(v, 24);
} }
inline int get_le32_signed(const void *bb) inline int get_le32_signed(const void *p)
{ {
int v = get_le32(bb); int v = get_le32(p);
return sign_extend(v, 32); return sign_extend(v, 32);
} }
inline int get_le64_signed(const void *p)
{
acc_int64l_t v = get_le64(p);
return sign_extend(v, 64);
}
/************************************************************************* /*************************************************************************
// classes for portable unaligned access // classes for portable unaligned access
//
// Important: these classes must be PODs (Plain Old Data), i.e. no
// constructor, no destructor, no virtual functions and no default
// assignment operator, and all fields must be public(!).
**************************************************************************/ **************************************************************************/
class BE16 struct BE16
{ {
unsigned char d[2]; unsigned char d[2];
public:
BE16() { }
BE16& operator = (const BE16 &v) {
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
* (acc_uint32e_t *) d = * (const acc_uint32e_t *) v.d;
#else
memcpy(d, v.d, sizeof(d));
#endif
return *this;
}
BE16& operator = (unsigned v) { set_be16(d, v); return *this; } BE16& operator = (unsigned v) { set_be16(d, v); return *this; }
BE16& operator += (unsigned v) { set_be16(d, get_be16(d) + v); return *this; } BE16& operator += (unsigned v) { set_be16(d, get_be16(d) + v); return *this; }
BE16& operator -= (unsigned v) { set_be16(d, get_be16(d) - v); return *this; } BE16& operator -= (unsigned v) { set_be16(d, get_be16(d) - v); return *this; }
BE16& operator *= (unsigned v) { set_be16(d, get_be16(d) * v); return *this; }
BE16& operator /= (unsigned v) { set_be16(d, get_be16(d) / v); return *this; }
BE16& operator &= (unsigned v) { set_be16(d, get_be16(d) & v); return *this; } BE16& operator &= (unsigned v) { set_be16(d, get_be16(d) & v); return *this; }
BE16& operator |= (unsigned v) { set_be16(d, get_be16(d) | v); return *this; } BE16& operator |= (unsigned v) { set_be16(d, get_be16(d) | v); return *this; }
BE16& operator ^= (unsigned v) { set_be16(d, get_be16(d) ^ v); return *this; }
BE16& operator <<= (unsigned v) { set_be16(d, get_be16(d) << v); return *this; }
BE16& operator >>= (unsigned v) { set_be16(d, get_be16(d) >> v); return *this; }
operator unsigned () const { return get_be16(d); } operator unsigned () const { return get_be16(d); }
} }
__attribute_packed; __attribute_packed;
class BE32 struct BE32
{ {
unsigned char d[4]; unsigned char d[4];
public:
BE32() { }
BE32& operator = (const BE32 &v) {
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
* (unsigned int *) d = * (const unsigned int *) v.d;
#else
memcpy(d, v.d, sizeof(d));
#endif
return *this;
}
BE32& operator = (unsigned v) { set_be32(d, v); return *this; } BE32& operator = (unsigned v) { set_be32(d, v); return *this; }
BE32& operator += (unsigned v) { set_be32(d, get_be32(d) + v); return *this; } BE32& operator += (unsigned v) { set_be32(d, get_be32(d) + v); return *this; }
BE32& operator -= (unsigned v) { set_be32(d, get_be32(d) - v); return *this; } BE32& operator -= (unsigned v) { set_be32(d, get_be32(d) - v); return *this; }
BE32& operator *= (unsigned v) { set_be32(d, get_be32(d) * v); return *this; }
BE32& operator /= (unsigned v) { set_be32(d, get_be32(d) / v); return *this; }
BE32& operator &= (unsigned v) { set_be32(d, get_be32(d) & v); return *this; } BE32& operator &= (unsigned v) { set_be32(d, get_be32(d) & v); return *this; }
BE32& operator |= (unsigned v) { set_be32(d, get_be32(d) | v); return *this; } BE32& operator |= (unsigned v) { set_be32(d, get_be32(d) | v); return *this; }
BE32& operator ^= (unsigned v) { set_be32(d, get_be32(d) ^ v); return *this; }
BE32& operator <<= (unsigned v) { set_be32(d, get_be32(d) << v); return *this; }
BE32& operator >>= (unsigned v) { set_be32(d, get_be32(d) >> v); return *this; }
operator unsigned () const { return get_be32(d); } operator unsigned () const { return get_be32(d); }
} }
__attribute_packed; __attribute_packed;
class LE16 struct BE64
{
unsigned char d[8];
BE64& operator = (acc_uint64l_t v) { set_be64(d, v); return *this; }
BE64& operator += (acc_uint64l_t v) { set_be64(d, get_be64(d) + v); return *this; }
BE64& operator -= (acc_uint64l_t v) { set_be64(d, get_be64(d) - v); return *this; }
BE64& operator *= (acc_uint64l_t v) { set_be64(d, get_be64(d) * v); return *this; }
BE64& operator /= (acc_uint64l_t v) { set_be64(d, get_be64(d) / v); return *this; }
BE64& operator &= (acc_uint64l_t v) { set_be64(d, get_be64(d) & v); return *this; }
BE64& operator |= (acc_uint64l_t v) { set_be64(d, get_be64(d) | v); return *this; }
BE64& operator ^= (acc_uint64l_t v) { set_be64(d, get_be64(d) ^ v); return *this; }
BE64& operator <<= (unsigned v) { set_be64(d, get_be64(d) << v); return *this; }
BE64& operator >>= (unsigned v) { set_be64(d, get_be64(d) >> v); return *this; }
operator acc_uint64l_t () const { return get_be64(d); }
}
__attribute_packed;
struct LE16
{ {
unsigned char d[2]; unsigned char d[2];
public:
LE16() { }
LE16& operator = (const LE16 &v) {
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
* (unsigned short *) d = * (const unsigned short *) v.d;
#else
memcpy(d, v.d, sizeof(d));
#endif
return *this;
}
LE16& operator = (unsigned v) { set_le16(d, v); return *this; } LE16& operator = (unsigned v) { set_le16(d, v); return *this; }
LE16& operator += (unsigned v) { set_le16(d, get_le16(d) + v); return *this; } LE16& operator += (unsigned v) { set_le16(d, get_le16(d) + v); return *this; }
LE16& operator -= (unsigned v) { set_le16(d, get_le16(d) - v); return *this; } LE16& operator -= (unsigned v) { set_le16(d, get_le16(d) - v); return *this; }
LE16& operator *= (unsigned v) { set_le16(d, get_le16(d) * v); return *this; }
LE16& operator /= (unsigned v) { set_le16(d, get_le16(d) / v); return *this; }
LE16& operator &= (unsigned v) { set_le16(d, get_le16(d) & v); return *this; } LE16& operator &= (unsigned v) { set_le16(d, get_le16(d) & v); return *this; }
LE16& operator |= (unsigned v) { set_le16(d, get_le16(d) | v); return *this; } LE16& operator |= (unsigned v) { set_le16(d, get_le16(d) | v); return *this; }
LE16& operator ^= (unsigned v) { set_le16(d, get_le16(d) ^ v); return *this; }
LE16& operator <<= (unsigned v) { set_le16(d, get_le16(d) << v); return *this; }
LE16& operator >>= (unsigned v) { set_le16(d, get_le16(d) >> v); return *this; }
operator unsigned () const { return get_le16(d); } operator unsigned () const { return get_le16(d); }
} }
__attribute_packed; __attribute_packed;
class LE32 struct LE32
{ {
unsigned char d[4]; unsigned char d[4];
public:
LE32() { }
LE32& operator = (const LE32 &v) {
#if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
* (acc_uint32e_t *) d = * (const acc_uint32e_t *) v.d;
#else
memcpy(d, v.d, sizeof(d));
#endif
return *this;
}
LE32& operator = (unsigned v) { set_le32(d, v); return *this; } LE32& operator = (unsigned v) { set_le32(d, v); return *this; }
LE32& operator += (unsigned v) { set_le32(d, get_le32(d) + v); return *this; } LE32& operator += (unsigned v) { set_le32(d, get_le32(d) + v); return *this; }
LE32& operator -= (unsigned v) { set_le32(d, get_le32(d) - v); return *this; } LE32& operator -= (unsigned v) { set_le32(d, get_le32(d) - v); return *this; }
LE32& operator *= (unsigned v) { set_le32(d, get_le32(d) * v); return *this; }
LE32& operator /= (unsigned v) { set_le32(d, get_le32(d) / v); return *this; }
LE32& operator &= (unsigned v) { set_le32(d, get_le32(d) & v); return *this; } LE32& operator &= (unsigned v) { set_le32(d, get_le32(d) & v); return *this; }
LE32& operator |= (unsigned v) { set_le32(d, get_le32(d) | v); return *this; } LE32& operator |= (unsigned v) { set_le32(d, get_le32(d) | v); return *this; }
LE32& operator ^= (unsigned v) { set_le32(d, get_le32(d) ^ v); return *this; }
LE32& operator <<= (unsigned v) { set_le32(d, get_le32(d) << v); return *this; }
LE32& operator >>= (unsigned v) { set_le32(d, get_le32(d) >> v); return *this; }
operator unsigned () const { return get_le32(d); } operator unsigned () const { return get_le32(d); }
} }
__attribute_packed; __attribute_packed;
struct LE64
{
unsigned char d[8];
LE64& operator = (acc_uint64l_t v) { set_le64(d, v); return *this; }
LE64& operator += (acc_uint64l_t v) { set_le64(d, get_le64(d) + v); return *this; }
LE64& operator -= (acc_uint64l_t v) { set_le64(d, get_le64(d) - v); return *this; }
LE64& operator *= (acc_uint64l_t v) { set_le64(d, get_le64(d) * v); return *this; }
LE64& operator /= (acc_uint64l_t v) { set_le64(d, get_le64(d) / v); return *this; }
LE64& operator &= (acc_uint64l_t v) { set_le64(d, get_le64(d) & v); return *this; }
LE64& operator |= (acc_uint64l_t v) { set_le64(d, get_le64(d) | v); return *this; }
LE64& operator ^= (acc_uint64l_t v) { set_le64(d, get_le64(d) ^ v); return *this; }
LE64& operator <<= (unsigned v) { set_le64(d, get_le64(d) << v); return *this; }
LE64& operator >>= (unsigned v) { set_le64(d, get_le64(d) >> v); return *this; }
operator acc_uint64l_t () const { return get_le64(d); }
}
__attribute_packed;
/************************************************************************* /*************************************************************************
// global operators // global operators
**************************************************************************/ **************************************************************************/
inline bool operator < (const BE16& v1, const BE16& v2)
{
return (unsigned)v1 < (unsigned)v2;
}
inline bool operator < (const BE32& v1, const BE32& v2)
{
return (unsigned)v1 < (unsigned)v2;
}
inline bool operator < (const LE16& v1, const LE16& v2)
{
return (unsigned)v1 < (unsigned)v2;
}
inline bool operator < (const LE32& v1, const LE32& v2)
{
return (unsigned)v1 < (unsigned)v2;
}
template <class T> template <class T>
inline T* operator + (T* ptr, const BE16& v) { return ptr + (unsigned) v; } inline T* operator + (T* ptr, const BE16& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator + (const BE16& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const BE16& v) { return ptr - (unsigned) v; } inline T* operator - (T* ptr, const BE16& v) { return ptr - (unsigned) v; }
template <class T> template <class T>
inline T* operator + (T* ptr, const BE32& v) { return ptr + (unsigned) v; } inline T* operator + (T* ptr, const BE32& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator + (const BE32& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const BE32& v) { return ptr - (unsigned) v; } inline T* operator - (T* ptr, const BE32& v) { return ptr - (unsigned) v; }
// these are not implemented on purpose and will cause link-time errors
template <class T> T* operator + (T* ptr, const BE64& v);
template <class T> T* operator + (const BE64& v, T* ptr);
template <class T> T* operator - (T* ptr, const BE64& v);
template <class T> template <class T>
inline T* operator + (T* ptr, const LE16& v) { return ptr + (unsigned) v; } inline T* operator + (T* ptr, const LE16& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator + (const LE16& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const LE16& v) { return ptr - (unsigned) v; } inline T* operator - (T* ptr, const LE16& v) { return ptr - (unsigned) v; }
template <class T> template <class T>
inline T* operator + (T* ptr, const LE32& v) { return ptr + (unsigned) v; } inline T* operator + (T* ptr, const LE32& v) { return ptr + (unsigned) v; }
template <class T> template <class T>
inline T* operator + (const LE32& v, T* ptr) { return ptr + (unsigned) v; }
template <class T>
inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; } inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; }
// these are not implemented on purpose and will cause link-time errors
template <class T> T* operator + (T* ptr, const LE64& v);
template <class T> T* operator + (const LE64& v, T* ptr);
template <class T> T* operator - (T* ptr, const LE64& v);
/************************************************************************* /*************************************************************************
// misc // misc
**************************************************************************/ **************************************************************************/
// for use with qsort() // for use with qsort()
int __acc_cdecl_qsort be16_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be16_compare(const void *, const void *);
int __acc_cdecl_qsort be24_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be24_compare(const void *, const void *);
int __acc_cdecl_qsort be32_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be32_compare(const void *, const void *);
int __acc_cdecl_qsort le16_compare(const void *e1, const void *e2); int __acc_cdecl_qsort be64_compare(const void *, const void *);
int __acc_cdecl_qsort le24_compare(const void *e1, const void *e2); int __acc_cdecl_qsort le16_compare(const void *, const void *);
int __acc_cdecl_qsort le32_compare(const void *e1, const void *e2); int __acc_cdecl_qsort le24_compare(const void *, const void *);
int __acc_cdecl_qsort be16_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort le32_compare(const void *, const void *);
int __acc_cdecl_qsort be24_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort le64_compare(const void *, const void *);
int __acc_cdecl_qsort be32_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be16_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le16_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be24_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le24_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be32_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le32_compare_signed(const void *e1, const void *e2); int __acc_cdecl_qsort be64_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le16_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le24_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le32_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
// just for testing... // just for testing...
#if 1 && (ACC_ARCH_AMD64 || ACC_ARCH_IA32) && (ACC_CC_GNUC >= 0x030200) #if !defined(ACC_CFG_NO_UNALIGNED)
typedef unsigned short LE16_unaligned __attribute__((__aligned__(1))); #if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x030200)
typedef acc_uint16e_t LE16_unaligned __attribute__((__aligned__(1)));
typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1))); typedef acc_uint32e_t LE32_unaligned __attribute__((__aligned__(1)));
# ifndef LE16
# define LE16 LE16_unaligned # define LE16 LE16_unaligned
# endif
# ifndef LE32
# define LE32 LE32_unaligned # define LE32 LE32_unaligned
# endif # endif
#if 0 && (ACC_ARCH_IA32) && (ACC_CC_INTELC) #endif
typedef __declspec(align(1)) unsigned short LE16_unaligned; #if 0 && (ACC_ARCH_I386) && (ACC_CC_INTELC)
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned; typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
# ifndef LE16
# define LE16 LE16_unaligned # define LE16 LE16_unaligned
# endif
# ifndef LE32
# define LE32 LE32_unaligned # define LE32 LE32_unaligned
# endif # endif
#if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_IA32) && (ACC_CC_MSC) && (_MSC_VER >= 1200) #endif
typedef __declspec(align(1)) unsigned short LE16_unaligned; #if 0 && (ACC_ARCH_AMD64 || ACC_ARCH_I386) && (ACC_CC_MSC) && (_MSC_VER >= 1200)
typedef __declspec(align(1)) acc_uint16e_t LE16_unaligned;
typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned; typedef __declspec(align(1)) acc_uint32e_t LE32_unaligned;
# ifndef LE16
# define LE16 LE16_unaligned # define LE16 LE16_unaligned
# endif
# ifndef LE32
# define LE32 LE32_unaligned # define LE32 LE32_unaligned
# endif
# pragma warning(disable: 4244) // Wx: conversion, possible loss of data # pragma warning(disable: 4244) // Wx: conversion, possible loss of data
#endif #endif
#endif
#endif /* already included */ #endif /* already included */
+44 -8
View File
@@ -26,6 +26,20 @@
*/ */
#if 1 && defined(UCL_USE_ASM)
# include <ucl/ucl_asm.h>
# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8
# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16
# define ucl_nrv2b_decompress_safe_le32 ucl_nrv2b_decompress_asm_safe_le32
# define ucl_nrv2d_decompress_safe_8 ucl_nrv2d_decompress_asm_safe_8
# define ucl_nrv2d_decompress_safe_le16 ucl_nrv2d_decompress_asm_safe_le16
# define ucl_nrv2d_decompress_safe_le32 ucl_nrv2d_decompress_asm_safe_le32
# define ucl_nrv2e_decompress_safe_8 ucl_nrv2e_decompress_asm_safe_8
# define ucl_nrv2e_decompress_safe_le16 ucl_nrv2e_decompress_asm_safe_le16
# define ucl_nrv2e_decompress_safe_le32 ucl_nrv2e_decompress_asm_safe_le32
#endif
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
@@ -89,15 +103,10 @@ int upx_compress ( const upx_bytep src, upx_uint src_len,
// prepare bit-buffer settings // prepare bit-buffer settings
conf.bb_endian = 0; conf.bb_endian = 0;
conf.bb_size = 0; conf.bb_size = 0;
if (method >= M_NRV2B_LE32 && method <= M_NRV2E_LE16) if (method >= M_NRV2B_LE32 && method <= M_CL1B_LE16)
{ {
int n = (method - M_NRV2B_LE32) % 3; static const unsigned char sizes[3]={32,8,16};
if (n == 0) conf.bb_size = sizes[(method - M_NRV2B_LE32) % 3];
conf.bb_size = 32;
else if (n == 1)
conf.bb_size = 8;
else
conf.bb_size = 16;
} }
else else
throwInternalError("unknown compression method"); throwInternalError("unknown compression method");
@@ -119,6 +128,11 @@ int upx_compress ( const upx_bytep src, upx_uint src_len,
r = ucl_nrv2e_99_compress(src, src_len, dst, dst_len, r = ucl_nrv2e_99_compress(src, src_len, dst, dst_len,
cb, level, &conf, result); cb, level, &conf, result);
#endif #endif
#if 0 /*{*/
else if M_IS_CL1B(method)
r = cl1b_compress(src, src_len, dst, dst_len,
cb, level, &conf, result);
#endif /*}*/
else else
throwInternalError("unknown compression method"); throwInternalError("unknown compression method");
@@ -171,6 +185,17 @@ int upx_decompress ( const upx_bytep src, upx_uint src_len,
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL); r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
break; break;
#endif #endif
#if 0 /*{*/
case M_CL1B_8:
r = cl1b_decompress_safe_8(src,src_len,dst,dst_len,NULL);
break;
case M_CL1B_LE16:
r = cl1b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
break;
case M_CL1B_LE32:
r = cl1b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
break;
#endif /*}*/
default: default:
throwInternalError("unknown decompression method"); throwInternalError("unknown decompression method");
break; break;
@@ -225,6 +250,17 @@ int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL); r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
break; break;
#endif #endif
#if 0 /*{*/
case M_CL1B_8:
r = cl1b_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
break;
case M_CL1B_LE16:
r = cl1b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
break;
case M_CL1B_LE32:
r = cl1b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
break;
#endif /*}*/
default: default:
throwInternalError("unknown decompression method"); throwInternalError("unknown decompression method");
break; break;
+1 -3
View File
@@ -32,14 +32,12 @@
#if defined(WITH_NRV) #if defined(WITH_NRV)
# include "compress_nrv.ch" # include "compress_nrv.ch"
#elif defined(WITH_UCL) #elif defined(WITH_UCL)
# define ALG_NRV2E
# define upx_adler32 upx_adler32 # define upx_adler32 upx_adler32
//# define upx_crc32 upx_crc32 //# define upx_crc32 upx_crc32
# define upx_compress upx_compress # define upx_compress upx_compress
# define upx_decompress upx_decompress # define upx_decompress upx_decompress
# if (UPX_VERSION_HEX >= 0x019000)
# define ALG_NRV2E
# define upx_test_overlap upx_test_overlap # define upx_test_overlap upx_test_overlap
# endif
# include "compress.ch" # include "compress.ch"
#else #else
# error # error
+37 -19
View File
@@ -36,7 +36,7 @@
// ACC // ACC
**************************************************************************/ **************************************************************************/
#include "acc/acc.h" #include "miniacc.h"
#if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__) #if ((ACC_OS_WIN32 || ACC_OS_WIN64) && ACC_CC_MWERKS) && defined(__MSL__)
# undef HAVE_UTIME_H /* this pulls in <windows.h> */ # undef HAVE_UTIME_H /* this pulls in <windows.h> */
#endif #endif
@@ -106,9 +106,11 @@
#endif #endif
#include "acc/acc_incd.h" #define ACC_WANT_ACC_INCD_H 1
#include "acc/acc_ince.h" #define ACC_WANT_ACC_INCE_H 1
#include "acc/acc_lib.h" #define ACC_WANT_ACC_LIB_H 1
#define ACC_WANT_ACC_CXX_H 1
#include "miniacc.h"
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) #if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
# if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR) # if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
# error "something pulled in <windows.h>" # error "something pulled in <windows.h>"
@@ -144,7 +146,7 @@
#if !defined(WITH_UCL) #if !defined(WITH_UCL)
# error "please set UCLDIR in the Makefile" # define WITH_UCL 1
#endif #endif
#if defined(WITH_UCL) #if defined(WITH_UCL)
# include <ucl/uclconf.h> # include <ucl/uclconf.h>
@@ -285,14 +287,18 @@
// avoid warnings about shadowing global functions // avoid warnings about shadowing global functions
#undef index
#define basename upx_basename #define basename upx_basename
#define index upx_index #define index upx_index
#define outp upx_outp #define outp upx_outp
#undef PAGE_MASK
#undef PAGE_SIZE
#undef __attribute_packed #undef __attribute_packed
#if (ACC_CC_GNUC || ACC_CC_INTELC) #if (ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_PATHSCALE)
# if (1 && (ACC_ARCH_IA32)) # if (1 && (ACC_ARCH_I386))
# define __attribute_packed # define __attribute_packed
# else # else
# define __attribute_packed __attribute__((__packed__,__aligned__(1))) # define __attribute_packed __attribute__((__packed__,__aligned__(1)))
@@ -320,20 +326,20 @@
#if 1 #if 1
# define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \ # define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \ typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
struct acc_tmp_t { acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z[7]; }; \ struct acc_tmp_t { acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z[7]; } __attribute_packed; \
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 8*sizeof(b)+sizeof(a)) \ COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 8*sizeof(b)+sizeof(a)) \
} }
#else #else
# define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \ # define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
struct acc_tmp_t { b x; a y; b z[7]; }; \ struct acc_tmp_t { b x; a y; b z[7]; } __attribute_packed; \
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 8*sizeof(b)+sizeof(a)) \ COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 8*sizeof(b)+sizeof(a)) \
} }
#endif #endif
#if defined(acc_alignof) #if defined(__acc_alignof)
# define COMPILE_TIME_ASSERT_ALIGNOF(a,b) \ # define COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) \ __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) \
COMPILE_TIME_ASSERT(acc_alignof(a) == sizeof(b)) COMPILE_TIME_ASSERT(__acc_alignof(a) == sizeof(b))
#else #else
# define COMPILE_TIME_ASSERT_ALIGNOF(a,b) \ # define COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b)
@@ -420,10 +426,14 @@ inline void operator delete[](void *p)
#define M_NRV2E_LE32 8 #define M_NRV2E_LE32 8
#define M_NRV2E_8 9 #define M_NRV2E_8 9
#define M_NRV2E_LE16 10 #define M_NRV2E_LE16 10
#define M_CL1B_LE32 11
#define M_CL1B_8 12
#define M_CL1B_LE16 13
#define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16) #define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16)
#define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16) #define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16)
#define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16) #define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16)
#define M_IS_CL1B(x) ((x) >= M_CL1B_LE32 && (x) <= M_CL1B_LE16)
// Executable formats. Note: big endian types are >= 128. // Executable formats. Note: big endian types are >= 128.
@@ -446,8 +456,16 @@ inline void operator delete[](void *p)
#define UPX_F_ELKS_8086 17 #define UPX_F_ELKS_8086 17
#define UPX_F_PS1_EXE 18 #define UPX_F_PS1_EXE 18
#define UPX_F_VMLINUX_i386 19 #define UPX_F_VMLINUX_i386 19
#define UPX_F_LINUX_ELFI_i386 20
#define UPX_F_WINCE_ARM_PE 21
#define UPX_F_LINUX_ELF64_AMD 22
#define UPX_F_PLAIN_TEXT 127
#define UPX_F_ATARI_TOS 129 #define UPX_F_ATARI_TOS 129
#define UPX_F_SOLARIS_SPARC 130 #define UPX_F_SOLARIS_SPARC 130
#define UPX_F_MACH_PPC32 131
#define UPX_F_LINUX_ELFPPC32 132
#define UPX_MAGIC_LE32 0x21585055 /* "UPX!" */ #define UPX_MAGIC_LE32 0x21585055 /* "UPX!" */
@@ -474,7 +492,7 @@ inline void operator delete[](void *p)
extern const char *progname; extern const char *progname;
void init_options(struct options_t *o); void init_options(struct options_t *o);
bool set_ec(int ec); bool set_ec(int ec);
#if defined(__GNUC__) #if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void e_exit(int ec) __attribute__((__noreturn__)); void e_exit(int ec) __attribute__((__noreturn__));
#else #else
void e_exit(int ec); void e_exit(int ec);
@@ -486,23 +504,23 @@ void printSetNl(int need_nl);
void printClearLine(FILE *f = NULL); void printClearLine(FILE *f = NULL);
void printErr(const char *iname, const Throwable *e); void printErr(const char *iname, const Throwable *e);
void printUnhandledException(const char *iname, const std::exception *e); void printUnhandledException(const char *iname, const std::exception *e);
#if defined(__GNUC__) #if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void __acc_cdecl_va printErr(const char *iname, const char *format, ...) void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
__attribute__((__format__(printf,2,3))); __attribute__((__format__(__printf__,2,3)));
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...) void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
__attribute__((__format__(printf,2,3))); __attribute__((__format__(__printf__,2,3)));
#else #else
void __acc_cdecl_va printErr(const char *iname, const char *format, ...); void __acc_cdecl_va printErr(const char *iname, const char *format, ...);
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...); void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
#endif #endif
#if defined(__GNUC__) #if (ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void __acc_cdecl_va infoWarning(const char *format, ...) void __acc_cdecl_va infoWarning(const char *format, ...)
__attribute__((__format__(printf,1,2))); __attribute__((__format__(__printf__,1,2)));
void __acc_cdecl_va infoHeader(const char *format, ...) void __acc_cdecl_va infoHeader(const char *format, ...)
__attribute__((__format__(printf,1,2))); __attribute__((__format__(__printf__,1,2)));
void __acc_cdecl_va info(const char *format, ...) void __acc_cdecl_va info(const char *format, ...)
__attribute__((__format__(printf,1,2))); __attribute__((__format__(__printf__,1,2)));
#else #else
void __acc_cdecl_va infoWarning(const char *format, ...); void __acc_cdecl_va infoWarning(const char *format, ...);
void __acc_cdecl_va infoHeader(const char *format, ...); void __acc_cdecl_va infoHeader(const char *format, ...);
+2
View File
@@ -40,6 +40,8 @@ void File::chmod(const char *name, int mode)
#if defined(HAVE_CHMOD) #if defined(HAVE_CHMOD)
if (::chmod(name,mode) != 0) if (::chmod(name,mode) != 0)
throwIOException(name,errno); throwIOException(name,errno);
#else
UNUSED(name); UNUSED(mode);
#endif #endif
} }
-2
View File
@@ -131,7 +131,6 @@ public:
off_t getBytesWritten() const { return bytes_written; } off_t getBytesWritten() const { return bytes_written; }
#if (UPX_VERSION_HEX >= 0x019000)
// FIXME - these won't work when using the `--stdout' option // FIXME - these won't work when using the `--stdout' option
virtual void seek(off_t off, int whence) virtual void seek(off_t off, int whence)
{ {
@@ -144,7 +143,6 @@ public:
write(buf, len); write(buf, len);
bytes_written -= len; // restore bytes_written -= len; // restore
} }
#endif
// util // util
static void dump(const char *name, const void *buf, int len, int flags=-1); static void dump(const char *name, const void *buf, int len, int flags=-1);
+40
View File
@@ -383,6 +383,46 @@ static int s_ct32_e8e9_bswap_be(Filter *f)
#undef CT32 #undef CT32
/*************************************************************************
// 24-bit ARM calltrick ("naive")
**************************************************************************/
#define CT24ARM(f, cond, addvalue, get, set) \
upx_byte *b = f->buf; \
upx_byte *b_end = b + f->buf_len - 4; \
do { \
if (cond) \
{ \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b) + (addvalue)); \
f->calls++; \
} \
b += 4; \
} while (b < b_end); \
if (f->lastcall) f->lastcall += 4; \
return 0;
#define ARMCT_COND (((b[3] & 0x0f) == 0x0b))
static int f_ct24arm_le(Filter *f)
{
CT24ARM(f, ARMCT_COND, a / 4 + f->addvalue, get_le24, set_le24)
}
static int u_ct24arm_le(Filter *f)
{
CT24ARM(f, ARMCT_COND, 0 - a / 4 - f->addvalue, get_le24, set_le24)
}
static int s_ct24arm_le(Filter *f)
{
CT24ARM(f, ARMCT_COND, a + f->addvalue, get_le24, set_dummy)
}
#undef CT24ARM
#undef ARMCT_COND
/* /*
vi:ts=4:et:nowrap vi:ts=4:et:nowrap
+8 -1
View File
@@ -36,11 +36,11 @@ static int F(Filter *f)
#ifdef U #ifdef U
// filter // filter
upx_byte *b = f->buf; upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else #else
// scan // scan
const upx_byte *b = f->buf; const upx_byte *b = f->buf;
#endif #endif
const unsigned addvalue = f->addvalue;
const unsigned size = f->buf_len; const unsigned size = f->buf_len;
unsigned ic, jc, kc; unsigned ic, jc, kc;
@@ -52,6 +52,11 @@ static int F(Filter *f)
unsigned char buf[256]; unsigned char buf[256];
memset(buf,0,256); memset(buf,0,256);
// A call to a destination that is inside the buffer
// will be rewritten and marked with cto8 as first byte.
// So, a call to a destination that is outside the buffer
// must not conflict with the mark.
// Note that unsigned comparison checks both edges of buffer.
for (ic = 0; ic < size - 5; ic++) for (ic = 0; ic < size - 5; ic++)
if (COND(b,ic) && get_le32(b+ic+1)+ic+1 >= size) if (COND(b,ic) && get_le32(b+ic+1)+ic+1 >= size)
{ {
@@ -74,6 +79,8 @@ static int F(Filter *f)
// try to detect 'real' calls only // try to detect 'real' calls only
if (jc < size) if (jc < size)
{ {
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
return 1; // fail - buffer not restored
#ifdef U #ifdef U
set_be32(b+ic+1,jc+addvalue+cto); set_be32(b+ic+1,jc+addvalue+cto);
#endif #endif
+3 -1
View File
@@ -40,11 +40,11 @@ static int F(Filter *f)
#ifdef U #ifdef U
// filter // filter
upx_byte *b = f->buf; upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else #else
// scan // scan
const upx_byte *b = f->buf; const upx_byte *b = f->buf;
#endif #endif
const unsigned addvalue = f->addvalue;
const unsigned size = f->buf_len; const unsigned size = f->buf_len;
unsigned ic, jc, kc; unsigned ic, jc, kc;
@@ -78,6 +78,8 @@ static int F(Filter *f)
// try to detect 'real' calls only // try to detect 'real' calls only
if (jc < size) if (jc < size)
{ {
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
return 1; // fail - buffer not restored
#ifdef U #ifdef U
set_be32(b+ic+1,jc+addvalue+cto); set_be32(b+ic+1,jc+addvalue+cto);
#endif #endif
+3 -1
View File
@@ -40,11 +40,11 @@ static int F(Filter *f)
#ifdef U #ifdef U
// filter // filter
upx_byte *b = f->buf; upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else #else
// scan // scan
const upx_byte *b = f->buf; const upx_byte *b = f->buf;
#endif #endif
const unsigned addvalue = f->addvalue;
const unsigned size = f->buf_len; const unsigned size = f->buf_len;
unsigned const id = f->id; unsigned const id = f->id;
@@ -79,6 +79,8 @@ static int F(Filter *f)
// try to detect 'real' calls only // try to detect 'real' calls only
if (jc < size) if (jc < size)
{ {
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
return 1; // fail - buffer not restored
#ifdef U #ifdef U
set_be32(b+ic+1,jc+addvalue+cto); set_be32(b+ic+1,jc+addvalue+cto);
#endif #endif
+155
View File
@@ -0,0 +1,155 @@
/* ppcbxx.h -- PowerPC Branch trick
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2004-2005 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
/*************************************************************************
// filter / scan
**************************************************************************/
#define W_CTO 4 /* width of cto; must match stub/ppc_bxx.S */
static int F(Filter *f)
{
#ifdef U
// filter
upx_byte *b = f->buf;
const unsigned addvalue = f->addvalue;
#else
// scan
const upx_byte *b = f->buf;
#endif
const unsigned size = umin(f->buf_len, -(~0u<<(32 - (6+ W_CTO))));
const unsigned size4 = size -4;
unsigned ic;
unsigned calls = 0, noncalls = 0;
unsigned lastnoncall = size, lastcall = 0;
// find 26-2-W_CTO bits of displacements that contain no targets
{
unsigned char buf[256];
unsigned short wbuf[256];
const size_t WW = (size_t)0 - (~(size_t)0) << W_CTO; // ???
memset(wbuf, 0, sizeof(wbuf));
memset(buf , 0, WW);
memset(buf + WW, 1, 256 - WW);
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const off = (int)(get_be32(b+ic)<<6) >>6;
if (size <= (off & (~0u<<2))+ic) {
buf[(~(~0u<<W_CTO)) & (off>>(26 - W_CTO))] |= 1;
++wbuf[0xff&(off>>18)];
}
}
if (getcto(f, buf) < 0) {
if (0!=W_CTO) // FIXME: what is this ???
return -1;
f->cto = 0;
}
}
const unsigned char cto8 = f->cto;
#ifdef U
const unsigned cto = (unsigned)f->cto << (24+2 - W_CTO);
#endif
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const word = get_be32(b+ic);
unsigned const off = (int)(word<<6) >>6;
unsigned const jc = (off & (~0u<<2))+ic;
// try to detect 'real' calls only
if (jc < size) {
#ifdef U
set_be32(b+ic,(0xfc000003&word) | (jc+addvalue+cto));
#endif
calls++;
lastcall = ic;
}
else {
assert(0==W_CTO // FIXME: what is this ???
|| (~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) != cto8); // this should not happen
lastnoncall = ic;
noncalls++;
}
}
f->calls = calls;
f->noncalls = noncalls;
f->lastcall = lastcall;
#if 0
printf("\ncalls=%d noncalls=%d text_size=%x calltrickoffset=%x\n",
calls,noncalls,size,cto8);
#endif
return 0;
}
/*************************************************************************
// unfilter
**************************************************************************/
#ifdef U
static int U(Filter *f)
{
upx_byte *b = f->buf;
const unsigned size4 = umin(f->buf_len - 4, -(~0u<<(32 - (6+ W_CTO))));
const unsigned addvalue = f->addvalue;
unsigned ic;
for (ic = 0; ic<=size4; ic+=4) if (COND(b,ic)) {
unsigned const word = get_be32(b+ic);
if ((~(~0u<<W_CTO) & (word>>(24+2 - W_CTO))) == f->cto) {
unsigned const jc = word & (~(~0u<<(26 - W_CTO)) & (~0u<<2));
set_be32(b+ic, (0xfc000003&word)|(0x03fffffc&(jc-ic-addvalue)));
f->calls++;
f->lastcall = ic;
}
else {
f->noncalls++;
}
}
return 0;
}
#endif
#undef F
#undef U
#undef W_CTO
/*
vi:ts=4:et:nowrap
*/
+25
View File
@@ -29,6 +29,12 @@
#include "conf.h" #include "conf.h"
#include "filter.h" #include "filter.h"
static unsigned
umin(unsigned const a, unsigned const b)
{
return (a<=b) ? a : b;
}
#define set_dummy(p, v) ((void)0) #define set_dummy(p, v) ((void)0)
#define get_8(p) (*(p)) #define get_8(p) (*(p))
@@ -145,6 +151,19 @@
#undef COND_CALL #undef COND_CALL
/*************************************************************************
// PowerPC branch [incl. call] trick
**************************************************************************/
#define COND(b,x) (18==(get_be32(b+x)>>26))
#define F f_ppcbxx
#define U u_ppcbxx
#include "filter/ppcbxx.h"
#define F s_ppcbxx
#include "filter/ppcbxx.h"
#undef COND
/************************************************************************* /*************************************************************************
// database for use in class Filter // database for use in class Filter
**************************************************************************/ **************************************************************************/
@@ -205,6 +224,9 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
{ 0x46, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le }, { 0x46, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
{ 0x49, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le }, { 0x49, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
// 24-bit calltrick for arm
{ 0x50, 8, 0x01ffffff, f_ct24arm_le, u_ct24arm_le, s_ct24arm_le },
// 32-bit cto calltrick with jmp and jcc(swap 0x0f/0x8Y) and relative renumbering // 32-bit cto calltrick with jmp and jcc(swap 0x0f/0x8Y) and relative renumbering
{ 0x80, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le }, { 0x80, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
{ 0x81, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le }, { 0x81, 8, 0x00ffffff, f_ctojr32_e8e9_bswap_le, u_ctojr32_e8e9_bswap_le, s_ctojr32_e8e9_bswap_le },
@@ -230,6 +252,9 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
{ 0xb1,99, 0, f_sub32_2, u_sub32_2, s_sub32_2 }, { 0xb1,99, 0, f_sub32_2, u_sub32_2, s_sub32_2 },
{ 0xb2,99, 0, f_sub32_3, u_sub32_3, s_sub32_3 }, { 0xb2,99, 0, f_sub32_3, u_sub32_3, s_sub32_3 },
{ 0xb3,99, 0, f_sub32_4, u_sub32_4, s_sub32_4 }, { 0xb3,99, 0, f_sub32_4, u_sub32_4, s_sub32_4 },
// PowerPC branch+call trick
{ 0xd0, 8, 0, f_ppcbxx, u_ppcbxx, s_ppcbxx },
}; };
const int FilterImp::n_filters = TABLESIZE(filters); const int FilterImp::n_filters = TABLESIZE(filters);
+18 -14
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -48,8 +48,8 @@ void show_head(void)
fg = con_fg(f,FG_GREEN); fg = con_fg(f,FG_GREEN);
con_fprintf(f, con_fprintf(f,
" Ultimate Packer for eXecutables\n" " Ultimate Packer for eXecutables\n"
" Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004\n" " Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006\n"
"UPX %-12s Markus F.X.J. Oberhumer & Laszlo Molnar %20s\n\n", "UPX %-10s Markus Oberhumer, Laszlo Molnar & John Reiser %14s\n\n",
#if (ACC_OS_DOS16 || ACC_OS_DOS32) #if (ACC_OS_DOS16 || ACC_OS_DOS32)
V("d"), V("d"),
#elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) #elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
@@ -229,8 +229,6 @@ void show_help(int x)
" --compress-icons=1 compress all but the first icon\n" " --compress-icons=1 compress all but the first icon\n"
" --compress-icons=2 compress all but the first icon directory [default]\n" " --compress-icons=2 compress all but the first icon directory [default]\n"
" --compress-resources=0 do not compress any resources at all\n" " --compress-resources=0 do not compress any resources at all\n"
" --strip-loadconf=0 do not strip SEH load config [default]\n"
" --strip-loadconf=1 strip SEH load config [DANGEROUS]\n"
" --strip-relocs=0 do not strip relocations\n" " --strip-relocs=0 do not strip relocations\n"
" --strip-relocs=1 strip relocations [default]\n" " --strip-relocs=1 strip relocations [default]\n"
" --all-methods try all available compression methods\n" " --all-methods try all available compression methods\n"
@@ -245,6 +243,11 @@ void show_help(int x)
con_fprintf(f,"This version supports:\n"); con_fprintf(f,"This version supports:\n");
fg = con_fg(f,fg); fg = con_fg(f,fg);
con_fprintf(f," " con_fprintf(f," "
// TODO:
// support for mach/ppc32
// support for linux elf/ppc32
// support for linux elf/amd64
" arm/pe,"
" atari/tos," " atari/tos,"
" bvmlinuz/386," " bvmlinuz/386,"
" djgpp2/coff," " djgpp2/coff,"
@@ -253,13 +256,14 @@ void show_help(int x)
" dos/sys," " dos/sys,"
"\n " "\n "
//" elks/8086," //" elks/8086,"
" linux/386," " linux/amd64,"
" linux/elf386," " linux/i386,"
" linux/sh386," " linux/ppc32,"
" mach/ppc32,"
" ps1/exe," " ps1/exe,"
" rtm32/pe," " rtm32/pe,"
" tmt/adam,"
"\n " "\n "
" tmt/adam,"
" vmlinux/386," " vmlinux/386,"
" vmlinuz/386," " vmlinuz/386,"
" watcom/le," " watcom/le,"
@@ -348,10 +352,10 @@ void show_version(int x)
#if defined(WITH_UCL) #if defined(WITH_UCL)
fprintf(f,"UCL data compression library %s\n", ucl_version_string()); fprintf(f,"UCL data compression library %s\n", ucl_version_string());
#endif #endif
fprintf(f,"Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer\n"); fprintf(f,"Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(f,"Copyright (C) 1996-2004 Laszlo Molnar\n"); fprintf(f,"Copyright (C) 1996-2006 Laszlo Molnar\n");
fprintf(f,"Copyright (C) 2000-2004 John F. Reiser\n"); fprintf(f,"Copyright (C) 2000-2006 John F. Reiser\n");
fprintf(f,"Copyright (C) 2002-2004 Jens Medoch\n"); fprintf(f,"Copyright (C) 2002-2006 Jens Medoch\n");
fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname); fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
} }
+49 -22
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2005 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2005 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -22,33 +22,47 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
*/ */
#include "conf.h" #include "conf.h"
#include "linker.h" #include "linker.h"
class LinkerLabel
{
enum { LINKER_MAX_LABEL_LEN = 32 };
char label[LINKER_MAX_LABEL_LEN + 1];
public:
unsigned set(const char *l)
{
strncpy(label, l, sizeof(label));
return strlen(label) + 1;
}
operator const char *() const { return label; }
};
struct Linker::section struct Linker::section
{ {
int istart; int istart;
int ostart; int ostart;
int len; int len;
char name[8]; LinkerLabel name;
}; };
struct Linker::jump struct Linker::jump
{ {
int pos; int pos;
int len; int len;
char tsect[8];
int toffs; int toffs;
LinkerLabel tsect;
}; };
Linker::Linker(const void *pdata, int plen, int pinfo) Linker::Linker(const void *pdata, int plen, int pinfo)
{ {
iloader = new char[(ilen = plen) + 4096]; iloader = new char[(ilen = plen) + 8192];
memcpy(iloader,pdata,plen); memcpy(iloader,pdata,plen);
oloader = new char[plen]; oloader = new char[plen];
olen = 0; olen = 0;
@@ -57,7 +71,7 @@ Linker::Linker(const void *pdata, int plen, int pinfo)
info = pinfo; info = pinfo;
njumps = nsections = frozen = 0; njumps = nsections = frozen = 0;
jumps = new jump[200]; jumps = new jump[200];
#define NSECTIONS 350 #define NSECTIONS 550
sections = new section[NSECTIONS]; sections = new section[NSECTIONS];
char *p = iloader + info; char *p = iloader + info;
@@ -65,10 +79,10 @@ Linker::Linker(const void *pdata, int plen, int pinfo)
{ {
if (get32(p)) if (get32(p))
{ {
memcpy(sections[nsections].name,p,8); p += sections[nsections].name.set(p);
sections[nsections].istart = get32(p+8); sections[nsections].istart = get32(p);
sections[nsections++].ostart = -1; sections[nsections++].ostart = -1;
p += 12; p += 4;
assert(nsections < NSECTIONS); assert(nsections < NSECTIONS);
} }
else else
@@ -79,9 +93,9 @@ Linker::Linker(const void *pdata, int plen, int pinfo)
jumps[njumps].pos = l+1; jumps[njumps].pos = l+1;
jumps[njumps].len = get32(p+4)-jumps[njumps].pos; jumps[njumps].len = get32(p+4)-jumps[njumps].pos;
memcpy(jumps[njumps].tsect,p+8,8); p += 8 + jumps[njumps].tsect.set(p + 8);
jumps[njumps++].toffs = get32(p+16); jumps[njumps++].toffs = get32(p);
p += 20; p += 4;
assert(njumps < 200); assert(njumps < 200);
} }
} }
@@ -112,11 +126,21 @@ static int hex(char c)
return (c & 0xf) + (c > '9' ? 9 : 0); return (c & 0xf) + (c > '9' ? 9 : 0);
} }
int Linker::addSection(const char *sect) int Linker::addSection(const char *psect)
{ {
int ic; if (psect[0] == 0)
while (*sect) return olen;
char *begin = strdup(psect);
char *end = begin + strlen(begin);
for (char *sect = begin; sect < end; )
{ {
for (char *tokend = sect; *tokend; tokend++)
if (*tokend == ' ' || *tokend == ',')
{
*tokend = 0;
break;
}
if (*sect == '+') // alignment if (*sect == '+') // alignment
{ {
if (sect[1] == '0') if (sect[1] == '0')
@@ -131,19 +155,22 @@ int Linker::addSection(const char *sect)
} }
else else
{ {
int ic;
for (ic = 0; ic < nsections; ic++) for (ic = 0; ic < nsections; ic++)
if (memcmp(sect,sections[ic].name,8) == 0) if (strcmp(sect, sections[ic].name) == 0)
{ {
memcpy(oloader+olen,iloader+sections[ic].istart,sections[ic].len); memcpy(oloader+olen,iloader+sections[ic].istart,sections[ic].len);
sections[ic].ostart = olen; sections[ic].ostart = olen;
olen += sections[ic].len; olen += sections[ic].len;
break; break;
} }
//printf("%8.8s",sect); if (ic == nsections)
printf("%s", sect);
assert(ic != nsections); assert(ic != nsections);
} }
sect += 8; sect += strlen(sect) + 1;
} }
free(begin);
return olen; return olen;
} }
@@ -151,7 +178,7 @@ int Linker::addSection(const char *sect)
void Linker::addSection(const char *sname, const void *sdata, unsigned len) void Linker::addSection(const char *sname, const void *sdata, unsigned len)
{ {
// add a new section - can be used for adding stuff like ident or header // add a new section - can be used for adding stuff like ident or header
memcpy(sections[nsections].name,sname,8); sections[nsections].name.set(sname);
sections[nsections].istart = ilen; sections[nsections].istart = ilen;
sections[nsections].len = len; sections[nsections].len = len;
sections[nsections++].ostart = olen; sections[nsections++].ostart = olen;
@@ -177,7 +204,7 @@ const char *Linker::getLoader(int *llen)
continue; continue;
for (kc = 0; kc < nsections-1; kc++) for (kc = 0; kc < nsections-1; kc++)
if (memcmp(jumps[ic].tsect,sections[kc].name,8) == 0) if (strcmp(jumps[ic].tsect,sections[kc].name) == 0)
break; break;
assert(kc!=nsections-1); assert(kc!=nsections-1);
@@ -203,7 +230,7 @@ int Linker::getSection(const char *name, int *slen) const
if (!frozen) if (!frozen)
return -1; return -1;
for (int ic = 0; ic < nsections; ic++) for (int ic = 0; ic < nsections; ic++)
if (memcmp(name,sections[ic].name,8) == 0) if (strcmp(name, sections[ic].name) == 0)
{ {
if (slen) if (slen)
*slen = sections[ic].len; *slen = sections[ic].len;
+122 -44
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -71,12 +71,11 @@ void init_options(struct options_t *o)
for (unsigned i = 0; i < TABLESIZE(o->win32_pe.compress_rt); i++) for (unsigned i = 0; i < TABLESIZE(o->win32_pe.compress_rt); i++)
o->win32_pe.compress_rt[i] = -1; o->win32_pe.compress_rt[i] = -1;
o->win32_pe.compress_rt[24] = false; // 24 == RT_MANIFEST o->win32_pe.compress_rt[24] = false; // 24 == RT_MANIFEST
o->win32_pe.strip_loadconf = -1;
o->win32_pe.strip_relocs = -1; o->win32_pe.strip_relocs = -1;
} }
static struct options_t global_options; static struct options_t global_options;
struct options_t * volatile opt = &global_options; struct options_t *opt = &global_options;
static int done_output_name = 0; static int done_output_name = 0;
static int done_script_name = 0; static int done_script_name = 0;
@@ -444,7 +443,7 @@ static int do_option(int optc, const char *arg)
set_cmd(CMD_DECOMPRESS); set_cmd(CMD_DECOMPRESS);
break; break;
case 'D': case 'D':
opt->debug++; opt->debug.debug_level++;
break; break;
case 'f': case 'f':
opt->force++; opt->force++;
@@ -538,6 +537,23 @@ static int do_option(int optc, const char *arg)
e_method(opt->method, 10); e_method(opt->method, 10);
break; break;
// debug
case 542:
if (!mfx_optarg || strlen(mfx_optarg) != 4)
e_optarg(arg);
memcpy(opt->debug.fake_stub_version, mfx_optarg, 4);
break;
case 543:
if (!mfx_optarg || strlen(mfx_optarg) != 4)
e_optarg(arg);
memcpy(opt->debug.fake_stub_year, mfx_optarg, 4);
break;
case 544:
if (!mfx_optarg || !mfx_optarg[0])
e_optarg(arg);
opt->debug.dump_stub_loader = mfx_optarg;
break;
// misc // misc
case 512: case 512:
opt->console = CON_FILE; opt->console = CON_FILE;
@@ -567,6 +583,7 @@ static int do_option(int optc, const char *arg)
case 522: // --no-filter case 522: // --no-filter
opt->filter = 0; opt->filter = 0;
opt->all_filters = false; opt->all_filters = false;
opt->no_filter = true;
break; break;
case 523: // --all-filters case 523: // --all-filters
opt->all_filters = true; opt->all_filters = true;
@@ -677,10 +694,7 @@ static int do_option(int optc, const char *arg)
//printf("compress_resources: %d\n", opt->win32_pe.compress_resources); //printf("compress_resources: %d\n", opt->win32_pe.compress_resources);
break; break;
case 633: case 633:
opt->win32_pe.strip_loadconf = 1; // opt->win32_pe.strip_loadconf - OBSOLETE - IGNORED
if (mfx_optarg && strcmp(mfx_optarg,"0") == 0)
opt->win32_pe.strip_loadconf = 0;
//printf("strip_loadconf: %d\n", opt->win32_pe.strip_loadconf);
break; break;
case 634: case 634:
opt->win32_pe.strip_relocs = 1; opt->win32_pe.strip_relocs = 1;
@@ -703,14 +717,20 @@ static int do_option(int optc, const char *arg)
set_script_name(mfx_optarg,1); set_script_name(mfx_optarg,1);
break; break;
case 663: case 663:
opt->o_unix.ptinterp = true; opt->o_unix.is_ptinterp = true;
break;
case 664:
opt->o_unix.use_ptinterp = true;
break;
case 665:
opt->o_unix.make_ptinterp = true;
break; break;
case 670: case 670:
opt->ps1_exe.console_run = true; opt->ps1_exe.boot_only = true;
break; break;
case 671: case 671:
opt->ps1_exe.no_align = true; opt->ps1_exe.no_align = true;
opt->ps1_exe.console_run = true; opt->ps1_exe.boot_only = false;
break; break;
case 672: case 672:
opt->ps1_exe.do_8bit = true; opt->ps1_exe.do_8bit = true;
@@ -750,7 +770,6 @@ static const struct mfx_option longopts[] =
{"version", 0, 0, 'V'+256}, // display version number {"version", 0, 0, 'V'+256}, // display version number
// options // options
{"debug", 0x10, 0, 'D'},
{"force", 0, 0, 'f'}, // force overwrite of output files {"force", 0, 0, 'f'}, // force overwrite of output files
{"force-compress", 0, 0, 'f'}, // and compression of suspicious files {"force-compress", 0, 0, 'f'}, // and compression of suspicious files
{"info", 0, 0, 'i'}, // info mode {"info", 0, 0, 'i'}, // info mode
@@ -766,6 +785,12 @@ static const struct mfx_option longopts[] =
#endif #endif
{"verbose", 0, 0, 'v'}, // verbose mode {"verbose", 0, 0, 'v'}, // verbose mode
// debug options
{"debug", 0x10, 0, 'D'},
{"dump-stub-loader" ,0x31, 0, 544}, // for internal debugging
{"fake-stub-version",0x31, 0, 542}, // for internal debugging
{"fake-stub-year" ,0x31, 0, 543}, // for internal debugging
// backup options // backup options
{"backup", 0, 0, 'k'}, {"backup", 0, 0, 'k'},
{"keep", 0, 0, 'k'}, {"keep", 0, 0, 'k'},
@@ -823,17 +848,19 @@ static const struct mfx_option longopts[] =
#if 0 #if 0
{"script", 0x31, 0, 662}, // --script= {"script", 0x31, 0, 662}, // --script=
#endif #endif
{"ptinterp", 0, 0, 663}, // linux/elf386 PT_INTERP program {"is_ptinterp", 0, 0, 663}, // linux/elf386 PT_INTERP program
{"use_ptinterp", 0, 0, 664}, // linux/elf386 PT_INTERP program
{"make_ptinterp", 0, 0, 665}, // linux/elf386 PT_INTERP program
// watcom/le // watcom/le
{"le", 0, 0, 620}, // produce LE output {"le", 0, 0, 620}, // produce LE output
// win32/pe // win32/pe
{"compress-exports", 2, 0, 630}, {"compress-exports", 2, 0, 630},
{"compress-icons", 2, 0, 631}, {"compress-icons", 2, 0, 631},
{"compress-resources", 2, 0, 632}, {"compress-resources", 2, 0, 632},
{"strip-loadconf", 0x12, 0, 633}, {"strip-loadconf", 0x12, 0, 633}, // OBSOLETE - IGNORED
{"strip-relocs", 0x12, 0, 634}, {"strip-relocs", 0x12, 0, 634},
// ps1/exe // ps1/exe
{"console-run", 0x10, 0, 670}, {"boot-only", 0x10, 0, 670},
{"no-align", 0x10, 0, 671}, {"no-align", 0x10, 0, 671},
{"8-bit", 0x10, 0, 672}, {"8-bit", 0x10, 0, 672},
@@ -912,7 +939,7 @@ static const struct mfx_option longopts[] =
{"compress-exports", 2, 0, 630}, {"compress-exports", 2, 0, 630},
{"compress-icons", 2, 0, 631}, {"compress-icons", 2, 0, 631},
{"compress-resources", 2, 0, 632}, {"compress-resources", 2, 0, 632},
{"strip-loadconf", 0x12, 0, 633}, {"strip-loadconf", 0x12, 0, 633}, // OBSOLETE - IGNORED
{"strip-relocs", 0x12, 0, 634}, {"strip-relocs", 0x12, 0, 634},
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
@@ -1028,9 +1055,38 @@ static void first_options(int argc, char **argv)
// assert a sane architecture and compiler // assert a sane architecture and compiler
**************************************************************************/ **************************************************************************/
template <class T> struct TestBELE {
static int test(void)
{
T allbits; allbits = 0; allbits -= 1;
T v1; v1 = 1; v1 *= 2; v1 -= 1;
T v2; v2 = 1;
assert( (v1 == v2)); assert(!(v1 != v2));
assert( (v1 <= v2)); assert( (v1 >= v2));
assert(!(v1 < v2)); assert(!(v1 > v2));
v2 ^= allbits;
assert(!(v1 == v2)); assert( (v1 != v2));
assert( (v1 <= v2)); assert(!(v1 >= v2));
assert( (v1 < v2)); assert(!(v1 > v2));
v2 += 2;
assert(v1 == 1); assert(v2 == 0);
v1 <<= 1; v1 |= v2; v1 >>= 1; v2 &= v1; v2 /= v1; v2 *= v1;
assert(v1 == 1); assert(v2 == 0);
return (v1 ^ v2) == 1;
}};
#define ACC_WANT_ACC_CHK_CH 1
#undef ACCCHK_ASSERT
#include "miniacc.h"
void upx_sanity_check(void) void upx_sanity_check(void)
{ {
#include "acc/acc_chk.ch" #define ACC_WANT_ACC_CHK_CH 1
#undef ACCCHK_ASSERT
#define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT(expr)
#include "miniacc.h"
#undef ACCCHK_ASSERT
COMPILE_TIME_ASSERT(sizeof(char) == 1) COMPILE_TIME_ASSERT(sizeof(char) == 1)
COMPILE_TIME_ASSERT(sizeof(short) == 2) COMPILE_TIME_ASSERT(sizeof(short) == 2)
@@ -1043,40 +1099,67 @@ void upx_sanity_check(void)
COMPILE_TIME_ASSERT(sizeof(BE16) == 2) COMPILE_TIME_ASSERT(sizeof(BE16) == 2)
COMPILE_TIME_ASSERT(sizeof(BE32) == 4) COMPILE_TIME_ASSERT(sizeof(BE32) == 4)
COMPILE_TIME_ASSERT(sizeof(BE64) == 8)
COMPILE_TIME_ASSERT(sizeof(LE16) == 2) COMPILE_TIME_ASSERT(sizeof(LE16) == 2)
COMPILE_TIME_ASSERT(sizeof(LE32) == 4) COMPILE_TIME_ASSERT(sizeof(LE32) == 4)
COMPILE_TIME_ASSERT(sizeof(LE64) == 8)
COMPILE_TIME_ASSERT_ALIGNOF(BE16, char) COMPILE_TIME_ASSERT_ALIGNOF(BE16, char)
COMPILE_TIME_ASSERT_ALIGNOF(BE32, char) COMPILE_TIME_ASSERT_ALIGNOF(BE32, char)
COMPILE_TIME_ASSERT_ALIGNOF(BE64, char)
COMPILE_TIME_ASSERT_ALIGNOF(LE16, char) COMPILE_TIME_ASSERT_ALIGNOF(LE16, char)
COMPILE_TIME_ASSERT_ALIGNOF(LE32, char) COMPILE_TIME_ASSERT_ALIGNOF(LE32, char)
COMPILE_TIME_ASSERT_ALIGNOF(LE64, char)
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1) COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1)
assert(strlen(UPX_VERSION_STRING4) == 4); assert(strlen(UPX_VERSION_STRING4) == 4);
assert(memcmp(UPX_VERSION_STRING4, UPX_VERSION_STRING, 4) == 0); assert(memcmp(UPX_VERSION_STRING4, UPX_VERSION_STRING, 4) == 0);
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_YEAR) == 4 + 1)
assert(strlen(UPX_VERSION_YEAR) == 4);
assert(memcmp(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4) == 0);
assert(memcmp(UPX_VERSION_DATE + strlen(UPX_VERSION_DATE) - 4, UPX_VERSION_YEAR, 4) == 0);
#if 1 #if 1
const unsigned char dd[4] = { 0xff, 0xfe, 0xfd, 0xfc }; # if 1 && !defined(UPX_OFFICIAL_BUILD)
assert(upx_adler32(dd, 4) == 0x09f003f7); assert(TestBELE<LE16>::test());
assert(upx_adler32(dd, 4, 0) == 0x09ec03f6); assert(TestBELE<LE32>::test());
assert(upx_adler32(dd, 4, 1) == 0x09f003f7); assert(TestBELE<LE64>::test());
assert(TestBELE<BE16>::test());
assert(get_be16(dd) == 0xfffe); assert(TestBELE<BE32>::test());
assert(get_be16_signed(dd) == -2); assert(TestBELE<BE64>::test());
assert(get_be24(dd) == 0xfffefd); # endif
assert(get_be24_signed(dd) == -259); {
assert(get_be32(dd) == 0xfffefdfc); static const unsigned char dd[32] = { 0, 0, 0, 0, 0, 0, 0,
assert(get_be32_signed(dd) == -66052); 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
assert(get_le16(dd) == 0xfeff); 0, 0, 0, 0,
assert(get_le16_signed(dd) == -257); 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78,
assert(get_le24(dd) == 0xfdfeff); 0, 0, 0, 0, 0 };
assert(get_le24_signed(dd) == -131329); const unsigned char *d;
assert(get_le32(dd) == 0xfcfdfeff); d = dd + 7;
assert(get_le32_signed(dd) == -50462977); assert(upx_adler32(d, 4) == 0x09f003f7);
assert(find_be16(dd, sizeof(dd), 0xfffe) == 0); assert(upx_adler32(d, 4, 0) == 0x09ec03f6);
assert(find_le16(dd, sizeof(dd), 0xfeff) == 0); assert(upx_adler32(d, 4, 1) == 0x09f003f7);
assert(find_be32(dd, sizeof(dd), 0xfffefdfc) == 0); assert(get_be16(d) == 0xfffe);
assert(find_le32(dd, sizeof(dd), 0xfcfdfeff) == 0); assert(get_be16_signed(d) == -2);
assert(get_be24(d) == 0xfffefd);
assert(get_be24_signed(d) == -259);
assert(get_be32(d) == 0xfffefdfc);
assert(get_be32_signed(d) == -66052);
assert(get_le16(d) == 0xfeff);
assert(get_le16_signed(d) == -257);
assert(get_le24(d) == 0xfdfeff);
assert(get_le24_signed(d) == -131329);
assert(get_le32(d) == 0xfcfdfeff);
assert(get_le32_signed(d) == -50462977);
assert(find_be16(d, 2, 0xfffe) == 0);
assert(find_le16(d, 2, 0xfeff) == 0);
assert(find_be32(d, 4, 0xfffefdfc) == 0);
assert(find_le32(d, 4, 0xfcfdfeff) == 0);
d += 12;
assert(get_be16_signed(d) == 32638);
assert(get_be24_signed(d) == 8355453);
assert(get_be32_signed(d) == 2138996092);
}
#endif #endif
} }
@@ -1096,11 +1179,6 @@ int __acc_cdecl_main main(int argc, char *argv[])
#if 0 && defined(__DJGPP__) #if 0 && defined(__DJGPP__)
// LFN=n may cause problems with 2.03's _rename and mkdir under WinME // LFN=n may cause problems with 2.03's _rename and mkdir under WinME
putenv("LFN=y"); putenv("LFN=y");
#endif
#if defined(__MINT__)
__binmode(1);
__set_binmode(stdout, 0);
__set_binmode(stderr, 0);
#endif #endif
acc_wildargv(&argc, &argv); acc_wildargv(&argc, &argv);
+6 -4
View File
@@ -60,6 +60,8 @@ static int mcheck_init()
MemBuffer::MemBuffer() : MemBuffer::MemBuffer() :
b(NULL), b_size(0) b(NULL), b_size(0)
{ {
if (use_mcheck < 0)
mcheck_init();
} }
MemBuffer::MemBuffer(unsigned size) : MemBuffer::MemBuffer(unsigned size) :
@@ -87,7 +89,7 @@ void MemBuffer::dealloc()
set_be32(b + b_size, 0); set_be32(b + b_size, 0);
set_be32(b + b_size + 4, 0); set_be32(b + b_size + 4, 0);
// //
::free(b - 8); ::free(b - 16);
} }
else else
::free(b); ::free(b);
@@ -115,7 +117,7 @@ void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra
unsigned size = uncompressed_size + extra; unsigned size = uncompressed_size + extra;
// size += 512; // 512 safety bytes // size += 512; // 512 safety bytes
// INFO: 3 bytes are the allowed overrun for the i386 asm_fast decompressors // INFO: 3 bytes are the allowed overrun for the i386 asm_fast decompressors
#if (ACC_ARCH_IA32) #if (ACC_ARCH_I386)
size += 3; size += 3;
#endif #endif
alloc(size); alloc(size);
@@ -173,7 +175,7 @@ void MemBuffer::alloc(unsigned size)
assert(b_size == 0); assert(b_size == 0);
// //
assert((int)size > 0); assert((int)size > 0);
unsigned total = use_mcheck ? size + 16 : size; unsigned total = use_mcheck ? size + 32 : size;
assert((int)total > 0); assert((int)total > 0);
unsigned char *p = (unsigned char *) malloc(total); unsigned char *p = (unsigned char *) malloc(total);
if (!p) if (!p)
@@ -185,7 +187,7 @@ void MemBuffer::alloc(unsigned size)
b_size = size; b_size = size;
if (use_mcheck) if (use_mcheck)
{ {
b = p + 8; b = p + 16;
// store magic constants to detect buffer overruns // store magic constants to detect buffer overruns
set_be32(b - 8, b_size); set_be32(b - 8, b_size);
set_be32(b - 4, MAGIC1(b)); set_be32(b - 4, MAGIC1(b));
+6357
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -66,9 +66,9 @@ void printClearLine(FILE *f)
static void pr_print(bool c, const char *msg) static void pr_print(bool c, const char *msg)
{ {
if (c && !opt->to_stdout) if (c && !opt->to_stdout)
con_fprintf(stderr,msg); con_fprintf(stderr, "%s", msg);
else else
fprintf(stderr,msg); fprintf(stderr, "%s", msg);
} }
static void pr_error(const char *iname, const char *msg, bool is_warning) static void pr_error(const char *iname, const char *msg, bool is_warning)
+14 -5
View File
@@ -51,11 +51,11 @@ struct options_t {
int filter; // preferred filter from Packer::getFilters() int filter; // preferred filter from Packer::getFilters()
bool all_methods; // try all available compression methods ? bool all_methods; // try all available compression methods ?
bool all_filters; // try all available filters ? bool all_filters; // try all available filters ?
bool no_filter; // force no filter
// other options // other options
int backup; int backup;
int console; int console;
int debug;
int force; int force;
int info_mode; int info_mode;
bool ignorewarn; bool ignorewarn;
@@ -66,6 +66,14 @@ struct options_t {
int verbose; int verbose;
bool to_stdout; bool to_stdout;
// debug options
struct {
int debug_level;
const char *dump_stub_loader;
char fake_stub_version[4+1]; // for internal debugging
char fake_stub_year[4+1]; // for internal debugging
} debug;
// overlay handling // overlay handling
enum { enum {
SKIP_OVERLAY = 0, SKIP_OVERLAY = 0,
@@ -109,14 +117,16 @@ struct options_t {
bool no_reloc; bool no_reloc;
} dos_exe; } dos_exe;
struct { struct {
bool console_run; bool boot_only;
bool no_align; bool no_align;
bool do_8bit; bool do_8bit;
} ps1_exe; } ps1_exe;
struct { struct {
unsigned blocksize; unsigned blocksize;
bool force_execve; // force the linux/386 execve format bool force_execve; // force the linux/386 execve format
bool ptinterp; // is PT_INTERP, so don't adjust auxv_t bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
bool use_ptinterp; // use PT_INTERP /opt/upx/run
bool make_ptinterp; // make PT_INTERP [ignore current file!]
enum { SCRIPT_MAX = 32 }; enum { SCRIPT_MAX = 32 };
const char *script_name; const char *script_name;
} o_unix; } o_unix;
@@ -128,12 +138,11 @@ struct options_t {
int compress_icons; int compress_icons;
int compress_resources; int compress_resources;
signed char compress_rt[25]; // 25 == RT_LAST signed char compress_rt[25]; // 25 == RT_LAST
int strip_loadconf;
int strip_relocs; int strip_relocs;
} win32_pe; } win32_pe;
}; };
extern struct options_t * volatile opt; extern struct options_t *opt;
#endif /* already included */ #endif /* already included */
+2468
View File
File diff suppressed because it is too large Load Diff
+253
View File
@@ -0,0 +1,253 @@
/* p_armpe.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@users.sourceforge.net
*/
#ifndef __UPX_P_ARMPE_H
#define __UPX_P_ARMPE_H
class PackArmPe_Interval;
class PackArmPe_Reloc;
class PackArmPe_Resource;
class PackArmPe_Export;
/*************************************************************************
// arm/pe
**************************************************************************/
class PackArmPe : public Packer
{
typedef Packer super;
public:
PackArmPe(InputFile *f);
~PackArmPe();
virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_WINCE_ARM_PE; }
virtual const char *getName() const { return "arm/pe"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;
virtual void pack(OutputFile *fo);
virtual void unpack(OutputFile *fo);
virtual bool canPack();
virtual int canUnpack();
// unpacker capabilities
virtual bool canUnpackVersion(int version) const
{ return version == 13; }
protected:
virtual int readFileHeader();
virtual bool testUnpackVersion(int version) const;
virtual int buildLoader(const Filter *ft);
unsigned pe_offset;
unsigned processImports();
void processImports(unsigned);
void rebuildImports(upx_byte *&);
upx_byte *oimport;
unsigned soimport;
upx_byte *oimpdlls;
unsigned soimpdlls;
void processRelocs();
void processRelocs(PackArmPe_Reloc *);
void rebuildRelocs(upx_byte *&);
upx_byte *orelocs;
unsigned sorelocs;
upx_byte *oxrelocs;
unsigned soxrelocs;
void processExports(PackArmPe_Export *);
void processExports(PackArmPe_Export *,unsigned);
void rebuildExports();
upx_byte *oexport;
unsigned soexport;
void processResources(PackArmPe_Resource *);
void processResources(PackArmPe_Resource *, unsigned);
void rebuildResources(upx_byte *&);
upx_byte *oresources;
unsigned soresources;
void processTls(PackArmPe_Interval *);
void processTls(PackArmPe_Reloc *,const PackArmPe_Interval *,unsigned);
void rebuildTls();
upx_byte *otls;
unsigned sotls;
unsigned stripDebug(unsigned);
unsigned icondir_offset;
int icondir_count;
bool importbyordinal;
bool kernel32ordinal;
unsigned tlsindex;
unsigned rvamin;
unsigned cimports; // rva of preprocessed imports
unsigned crelocs; // rva of preprocessed fixups
int big_relocs;
bool use_thumb_stub;
struct pe_header_t
{
// 0x0
char _[4]; // pemagic
LE16 cpu;
LE16 objects;
char __[12]; // timestamp + reserved
LE16 opthdrsize;
LE16 flags;
// optional header
char ___[4]; // coffmagic + linkerversion
LE32 codesize;
// 0x20
LE32 datasize;
LE32 bsssize;
LE32 entry;
LE32 codebase;
// 0x30
LE32 database;
// nt specific fields
LE32 imagebase;
LE32 objectalign;
LE32 filealign; // should set to 0x200 ?
// 0x40
char ____[16]; // versions
// 0x50
LE32 imagesize;
LE32 headersize;
LE32 chksum; // should set to 0
LE16 subsystem;
LE16 dllflags;
// 0x60
char _____[20]; // stack + heap sizes
// 0x74
LE32 ddirsentries; // usually 16
struct ddirs_t
{
LE32 vaddr;
LE32 size;
}
__attribute_packed;
struct ddirs_t ddirs[16];
}
__attribute_packed;
struct pe_section_t
{
char name[8];
LE32 vsize;
LE32 vaddr;
LE32 size;
LE32 rawdataptr;
char _[12];
LE32 flags;
}
__attribute_packed;
pe_header_t ih, oh;
pe_section_t *isection;
static unsigned virta2objnum (unsigned, pe_section_t *, unsigned);
unsigned tryremove (unsigned, unsigned);
enum {
PEDIR_EXPORT = 0,
PEDIR_IMPORT = 1,
PEDIR_RESOURCE = 2,
PEDIR_EXCEPTION = 3, // Exception table
PEDIR_SEC = 4, // Certificate table (file pointer)
PEDIR_RELOC = 5,
PEDIR_DEBUG = 6,
PEDIR_COPYRIGHT = 7, // Architecture-specific data
PEDIR_GLOBALPTR = 8, // Global pointer
PEDIR_TLS = 9,
PEDIR_LOADCONF = 10, // Load Config Table
PEDIR_BOUNDIM = 11,
PEDIR_IAT = 12,
PEDIR_DELAYIMP = 13, // Delay Import Descriptor
PEDIR_COMRT = 14 // Com+ Runtime Header
};
enum {
PEFL_CODE = 0x20,
PEFL_DATA = 0x40,
PEFL_BSS = 0x80,
PEFL_INFO = 0x200,
PEFL_EXTRELS = 0x01000000, // extended relocations
PEFL_DISCARD = 0x02000000,
PEFL_NOCACHE = 0x04000000,
PEFL_NOPAGE = 0x08000000,
PEFL_SHARED = 0x10000000,
PEFL_EXEC = 0x20000000,
PEFL_READ = 0x40000000,
PEFL_WRITE = 0x80000000
};
enum {
RELOCS_STRIPPED = 0x0001,
EXECUTABLE = 0x0002,
LNUM_STRIPPED = 0x0004,
LSYMS_STRIPPED = 0x0008,
AGGRESSIVE_TRIM = 0x0010,
TWO_GIGS_AWARE = 0x0020,
FLITTLE_ENDIAN = 0x0080,
BITS_32_MACHINE = 0x0100,
DEBUG_STRIPPED = 0x0200,
REMOVABLE_SWAP = 0x0400,
SYSTEM_PROGRAM = 0x1000,
DLL_FLAG = 0x2000,
FBIG_ENDIAN = 0x8000
};
// predefined resource types
enum {
RT_CURSOR = 1, RT_BITMAP, RT_ICON, RT_MENU, RT_DIALOG, RT_STRING,
RT_FONTDIR, RT_FONT, RT_ACCELERATOR, RT_RCDATA, RT_MESSAGETABLE,
RT_GROUP_CURSOR, RT_GROUP_ICON = 14, RT_VERSION = 16, RT_DLGINCLUDE,
RT_PLUGPLAY = 19, RT_VXD, RT_ANICURSOR, RT_ANIICON, RT_HTML,
RT_MANIFEST, RT_LAST
};
};
#endif /* already included */
/*
vi:ts=4:et
*/
+6 -6
View File
@@ -22,7 +22,7 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
*/ */
@@ -142,15 +142,15 @@ void PackCom::patchLoader(OutputFile *fo,
int PackCom::buildLoader(const Filter *ft) int PackCom::buildLoader(const Filter *ft)
{ {
initLoader(nrv2b_loader,sizeof(nrv2b_loader)); initLoader(nrv2b_loader,sizeof(nrv2b_loader));
addLoader("COMMAIN1""COMSUBSI", addLoader("COMMAIN1,COMSUBSI",
ph.first_offset_found == 1 ? "COMSBBBP" : "", ph.first_offset_found == 1 ? "COMSBBBP" : "",
"COMPSHDI", "COMPSHDI",
ft->id ? "COMCALLT" : "", ft->id ? "COMCALLT" : "",
"COMMAIN2""UPX1HEAD""COMCUTPO""NRV2B160", "COMMAIN2,UPX1HEAD,COMCUTPO,NRV2B160",
ft->id ? "NRVDDONE" : "NRVDRETU", ft->id ? "NRVDDONE" : "NRVDRETU",
"NRVDECO1", "NRVDECO1",
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00", ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
"NRVDECO2""NRV2B169", "NRVDECO2,NRV2B169",
NULL NULL
); );
if (ft->id) if (ft->id)
@@ -170,7 +170,7 @@ void PackCom::addFilter16(int filter_id)
if (filter_id % 3 == 0) if (filter_id % 3 == 0)
addLoader("CALLTR16", addLoader("CALLTR16",
filter_id < 4 ? "CT16SUB0" : "", filter_id < 4 ? "CT16SUB0" : "",
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I086" : "CT16I286""CT16SUB0"), filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I086" : "CT16I286,CT16SUB0"),
"CALLTRI2", "CALLTRI2",
getFormat() == UPX_F_DOS_COM ? "CORETURN" : "", getFormat() == UPX_F_DOS_COM ? "CORETURN" : "",
NULL NULL
@@ -180,7 +180,7 @@ void PackCom::addFilter16(int filter_id)
"CALLTRI5", "CALLTRI5",
getFormat() == UPX_F_DOS_COM ? "CT16JEND" : "CT16JUL2", getFormat() == UPX_F_DOS_COM ? "CT16JEND" : "CT16JUL2",
filter_id < 4 ? "CT16SUB1" : "", filter_id < 4 ? "CT16SUB1" : "",
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I087" : "CT16I287""CT16SUB1"), filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I087" : "CT16I287,CT16SUB1"),
"CALLTRI6", "CALLTRI6",
NULL NULL
); );
+5 -5
View File
@@ -22,7 +22,7 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
*/ */
@@ -53,7 +53,7 @@ PackDjgpp2::PackDjgpp2(InputFile *f) :
COMPILE_TIME_ASSERT(STUBIFY_STUB_ADLER32 == 0xbf689ba8); COMPILE_TIME_ASSERT(STUBIFY_STUB_ADLER32 == 0xbf689ba8);
COMPILE_TIME_ASSERT(STUBIFY_STUB_CRC32 == 0x2ae982b2); COMPILE_TIME_ASSERT(STUBIFY_STUB_CRC32 == 0x2ae982b2);
//printf("0x%08x\n", upx_adler32(stubify_stub, sizeof(stubify_stub))); //printf("0x%08x\n", upx_adler32(stubify_stub, sizeof(stubify_stub)));
assert(upx_adler32(stubify_stub, sizeof(stubify_stub)) == STUBIFY_STUB_ADLER32); //assert(upx_adler32(stubify_stub, sizeof(stubify_stub)) == STUBIFY_STUB_ADLER32);
} }
@@ -86,7 +86,7 @@ int PackDjgpp2::buildLoader(const Filter *ft)
{ {
// prepare loader // prepare loader
initLoader(nrv_loader, sizeof(nrv_loader)); initLoader(nrv_loader, sizeof(nrv_loader));
addLoader("IDENTSTR""DJ2MAIN1", addLoader("IDENTSTR,DJ2MAIN1",
ft->id ? "DJCALLT1" : "", ft->id ? "DJCALLT1" : "",
"DJ2MAIN2", "DJ2MAIN2",
getDecompressor(), getDecompressor(),
@@ -99,7 +99,7 @@ int PackDjgpp2::buildLoader(const Filter *ft)
addLoader("DJCALLT2", NULL); addLoader("DJCALLT2", NULL);
addFilter32(ft->id); addFilter32(ft->id);
} }
addLoader("DJRETURN+40DXXXXUPX1HEAD", NULL); addLoader("DJRETURN,+40DXXXX,UPX1HEAD", NULL);
return getLoaderSize(); return getLoaderSize();
} }
@@ -159,7 +159,7 @@ static void handle_allegropak(InputFile *fi, OutputFile *fo)
if (memcmp(buf, "slh+", 4) != 0) if (memcmp(buf, "slh+", 4) != 0)
return; return;
pfsize = get_be32_signed(buf+4); pfsize = get_be32_signed(buf+4);
if (pfsize <= 8 || pfsize >= fi->st.st_size) if (pfsize <= 8 || (off_t) pfsize >= (off_t) fi->st.st_size)
return; return;
fi->seek(-pfsize, SEEK_END); fi->seek(-pfsize, SEEK_END);
} catch (const IOException&) { } catch (const IOException&) {
+267 -56
View File
@@ -34,77 +34,131 @@
// Some ELF type definitinons // Some ELF type definitinons
**************************************************************************/ **************************************************************************/
namespace TT_Elf {
// The ELF file header. This appears at the start of every ELF file. // The ELF file header. This appears at the start of every ELF file.
struct Elf_LE32_Ehdr template <class Word, class Addr, class Off, class Half>
struct Ehdr
{ {
unsigned char e_ident[16]; /* Magic number and other info */ unsigned char e_ident[16]; /* Magic number and other info */
LE16 e_type; /* Object file type */ Half e_type; /* Object file type */
LE16 e_machine; /* Architecture */ Half e_machine; /* Architecture */
LE32 e_version; /* Object file version */ Word e_version; /* Object file version */
LE32 e_entry; /* Entry point virtual address */ Addr e_entry; /* Entry point virtual address */
LE32 e_phoff; /* Program header table file offset */ Off e_phoff; /* Program header table file offset */
LE32 e_shoff; /* Section header table file offset */ Off e_shoff; /* Section header table file offset */
LE32 e_flags; /* Processor-specific flags */ Word e_flags; /* Processor-specific flags */
LE16 e_ehsize; /* ELF header size in bytes */ Half e_ehsize; /* ELF header size in bytes */
LE16 e_phentsize; /* Program header table entry size */ Half e_phentsize; /* Program header table entry size */
LE16 e_phnum; /* Program header table entry count */ Half e_phnum; /* Program header table entry count */
LE16 e_shentsize; /* Section header table entry size */ Half e_shentsize; /* Section header table entry size */
LE16 e_shnum; /* Section header table entry count */ Half e_shnum; /* Section header table entry count */
LE16 e_shstrndx; /* Section header string table index */ Half e_shstrndx; /* Section header string table index */
// Values for e_type enum { // e_ident[]
enum { EI_CLASS = 4,
EI_DATA = 5, /* Data encoding */
EI_VERSION = 6,
EI_OSABI = 7,
EI_ABIVERSION = 8,
};
enum { // e_ident[EI_CLASS]
ELFCLASS32 = 1, /* 32-bit objects */
ELFCLASS64 = 2, /* 64-bit objects */
};
enum { // e_ident[EI_DATA]
ELFDATA2LSB = 1, /* 2's complement, little endian */
ELFDATA2MSB = 2 /* 2's complement, big endian */
};
enum { // e_ident[EI_OSABI]
ELFOSABI_LINUX = 3
};
enum { // e_type
ET_NONE = 0, /* No file type */ ET_NONE = 0, /* No file type */
ET_REL = 1, /* Relocatable file */ ET_REL = 1, /* Relocatable file */
ET_EXEC = 2, /* Executable file */ ET_EXEC = 2, /* Executable file */
ET_DYN = 3, /* Shared object file */ ET_DYN = 3, /* Shared object file */
ET_CORE = 4 /* Core file */ ET_CORE = 4, /* Core file */
};
enum { // e_machine
EM_386 = 3,
EM_PPC = 20,
EM_PPC64 = 21,
EM_ARM = 40,
EM_X86_64 = 62,
};
enum { // e_version
EV_CURRENT = 1,
}; };
} }
__attribute_packed; __attribute_packed;
template <class Word, class Addr>
struct Dyn
{
Word d_tag;
Addr d_val;
enum { // d_tag
DT_NULL = 0, /* End flag */
DT_NEEDED = 1, /* Name of needed library */
DT_HASH = 4, /* Hash table of symbol names */
DT_STRTAB = 5, /* String table */
DT_SYMTAB = 6, /* Symbol table */
DT_STRSZ = 10, /* Sizeof string table */
};
}
__attribute_packed;
} // namespace TT_Elf
namespace TT_Elf32 {
// Program segment header. // Program segment header.
struct Elf_LE32_Phdr template <class Word, class Addr, class Off>
struct Phdr
{ {
LE32 p_type; /* Segment type */ Word p_type; /* Segment type */
LE32 p_offset; /* Segment file offset */ Off p_offset; /* Segment file offset */
LE32 p_vaddr; /* Segment virtual address */ Addr p_vaddr; /* Segment virtual address */
LE32 p_paddr; /* Segment physical address */ Addr p_paddr; /* Segment physical address */
LE32 p_filesz; /* Segment size in file */ Word p_filesz; /* Segment size in file */
LE32 p_memsz; /* Segment size in memory */ Word p_memsz; /* Segment size in memory */
LE32 p_flags; /* Segment flags */ Word p_flags; /* Segment flags */
LE32 p_align; /* Segment alignment */ Word p_align; /* Segment alignment */
// Values for p_type enum { // p_type
enum {
PT_LOAD = 1, /* Loadable program segment */ PT_LOAD = 1, /* Loadable program segment */
PT_DYNAMIC = 2, /* Dynamic linking information */ PT_DYNAMIC = 2, /* Dynamic linking information */
PT_PHDR = 6 /* Entry for header table itself */ PT_INTERP = 3, /* Name of program interpreter */
PT_PHDR = 6, /* Entry for header table itself */
}; };
// Values for p_flags enum { // p_flags
enum { PF_X = (1 << 0) }; /* Segment is executable */ PF_X = 1, /* Segment is executable */
enum { PF_W = (1 << 1) }; /* Segment is writable */ PF_W = 2, /* Segment is writable */
enum { PF_R = (1 << 2) }; /* Segment is readable */ PF_R = 4, /* Segment is readable */
};
} }
__attribute_packed; __attribute_packed;
template <class Word, class Addr, class Off>
struct Elf_LE32_Shdr struct Shdr
{ {
LE32 sh_name; /* Section name (string tbl index) */ Word sh_name; /* Section name (string tbl index) */
LE32 sh_type; /* Section type */ Word sh_type; /* Section type */
LE32 sh_flags; /* Section flags */ Word sh_flags; /* Section flags */
LE32 sh_addr; /* Section virtual addr at execution */ Addr sh_addr; /* Section virtual addr at execution */
LE32 sh_offset; /* Section file offset */ Off sh_offset; /* Section file offset */
LE32 sh_size; /* Section size in bytes */ Word sh_size; /* Section size in bytes */
LE32 sh_link; /* Link to another section */ Word sh_link; /* Link to another section */
LE32 sh_info; /* Additional section information */ Word sh_info; /* Additional section information */
LE32 sh_addralign; /* Section alignment */ Word sh_addralign; /* Section alignment */
LE32 sh_entsize; /* Entry size if section holds table */ Word sh_entsize; /* Entry size if section holds table */
enum { // values for sh_type enum { // sh_type
SHT_NULL = 0, /* Section header table entry unused */ SHT_NULL = 0, /* Section header table entry unused */
SHT_PROGBITS = 1, /* Program data */ SHT_PROGBITS = 1, /* Program data */
SHT_SYMTAB = 2, /* Symbol table */ SHT_SYMTAB = 2, /* Symbol table */
@@ -123,10 +177,10 @@ struct Elf_LE32_Shdr
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */ SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
SHT_GROUP = 17, /* Section group */ SHT_GROUP = 17, /* Section group */
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */ SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
SHT_NUM = 19 /* Number of defined types. */ SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
}; };
enum { // values for sh_flags enum { // sh_flags
SHF_WRITE = (1 << 0), /* Writable */ SHF_WRITE = (1 << 0), /* Writable */
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */ SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
SHF_EXECINSTR = (1 << 2), /* Executable */ SHF_EXECINSTR = (1 << 2), /* Executable */
@@ -138,20 +192,177 @@ struct Elf_LE32_Shdr
} }
__attribute_packed; __attribute_packed;
struct Elf_LE32_Dyn template <class TT16, class TT32, class TT64>
struct Sym
{ {
LE32 d_tag; TT32 st_name; /* symbol name (index into string table) */
LE32 d_val; TT32 st_value; /* symbol value */
TT32 st_size; /* symbol size */
unsigned char st_info; /* symbol type and binding */
unsigned char st_other; /* symbol visibility */
TT16 st_shndx; /* section index */
enum { // tags unsigned int st_bind(unsigned int x) const { return 0xf & (x>>4); }
DT_NULL = 0, /* End flag */ unsigned int st_type(unsigned int x) const { return 0xf & x ; }
DT_NEEDED = 1, /* Name of needed library */ unsigned char St_info(unsigned bind, unsigned type) const { return (bind<<4) + (0xf & type); }
DT_STRTAB = 5, /* String table */
DT_STRSZ = 10 /* Sizeof string table */ enum { // st_bind (high 4 bits of st_info)
STB_LOCAL = 0, /* Local symbol */
STB_GLOBAL = 1, /* Global symbol */
STB_WEAK = 2, /* Weak symbol */
};
enum { // st_type (low 4 bits of st_info)
STT_NOTYPE = 0, /* Symbol type is unspecified */
STT_OBJECT = 1, /* Symbol is a data object */
STT_FUNC = 2, /* Symbol is a code object */
STT_SECTION = 3, /* Symbol associated with a section */
STT_FILE = 4, /* Symbol's name is file name */
STT_COMMON = 5, /* Symbol is a common data object */
STT_TLS = 6, /* Symbol is thread-local data object*/
};
enum { // st_other (visibility)
STV_DEFAULT = 0, /* Default symbol visibility rules */
STV_INTERNAL = 1, /* Processor specific hidden class */
STV_HIDDEN = 2, /* Sym unavailable in other modules */
STV_PROTECTED= 3, /* Not preemptible, not exported */
};
enum { // st_shndx
SHN_UNDEF = 0, /* Undefined section */
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
SHN_COMMON = 0xfff2, /* Associated symbol is common */
}; };
} }
__attribute_packed; __attribute_packed;
} // namespace TT_Elf32
namespace TT_Elf64 {
// Program segment header.
template <class Word, class Xword, class Addr, class Off>
struct Phdr
{
Word p_type; /* Segment type */
Word p_flags; /* Segment flags */
Off p_offset; /* Segment file offset */
Addr p_vaddr; /* Segment virtual address */
Addr p_paddr; /* Segment physical address */
Xword p_filesz; /* Segment size in file */
Xword p_memsz; /* Segment size in memory */
Xword p_align; /* Segment alignment */
enum { // p_type
PT_LOAD = 1, /* Loadable program segment */
PT_DYNAMIC = 2, /* Dynamic linking information */
PT_INTERP = 3, /* Name of program interpreter */
PT_PHDR = 6, /* Entry for header table itself */
};
enum { // p_flags
PF_X = 1, /* Segment is executable */
PF_W = 2, /* Segment is writable */
PF_R = 4, /* Segment is readable */
};
}
__attribute_packed;
template <class Word, class Xword, class Addr, class Off>
struct Shdr
{
Word sh_name; /* Section name (string tbl index) */
Word sh_type; /* Section type */
Xword sh_flags; /* Section flags */
Addr sh_addr; /* Section virtual addr at execution */
Off sh_offset; /* Section file offset */
Xword sh_size; /* Section size in bytes */
Word sh_link; /* Link to another section */
Word sh_info; /* Additional section information */
Xword sh_addralign; /* Section alignment */
Xword sh_entsize; /* Entry size if section holds table */
enum { // sh_type
SHT_NULL = 0, /* Section header table entry unused */
SHT_PROGBITS = 1, /* Program data */
SHT_SYMTAB = 2, /* Symbol table */
SHT_STRTAB = 3, /* String table */
SHT_RELA = 4, /* Relocation entries with addends */
SHT_HASH = 5, /* Symbol hash table */
SHT_DYNAMIC = 6, /* Dynamic linking information */
SHT_NOTE = 7, /* Notes */
SHT_NOBITS = 8, /* Program space with no data (bss) */
SHT_REL = 9, /* Relocation entries, no addends */
SHT_SHLIB = 10, /* Reserved */
SHT_DYNSYM = 11, /* Dynamic linker symbol table */
/* 12, 13 hole */
SHT_INIT_ARRAY = 14, /* Array of constructors */
SHT_FINI_ARRAY = 15, /* Array of destructors */
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
SHT_GROUP = 17, /* Section group */
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
};
}
__attribute_packed;
} // namespace TT_Elf64
/*************************************************************************
// now for the actual types
**************************************************************************/
typedef TT_Elf ::Ehdr<LE32,LE32,LE32,LE16> Elf_LE32_Ehdr;
typedef TT_Elf32::Phdr<LE32,LE32,LE32> Elf_LE32_Phdr;
typedef TT_Elf32::Shdr<LE32,LE32,LE32> Elf_LE32_Shdr;
typedef TT_Elf ::Dyn <LE32,LE32> Elf_LE32_Dyn;
typedef TT_Elf32::Sym <LE16,LE32,void> Elf_LE32_Sym;
typedef TT_Elf ::Ehdr<unsigned int,unsigned int,unsigned int,unsigned short> Elf32_Ehdr;
typedef TT_Elf32::Phdr<unsigned int,unsigned int,unsigned int> Elf32_Phdr;
typedef TT_Elf32::Shdr<unsigned int,unsigned int,unsigned int> Elf32_Shdr;
typedef TT_Elf ::Dyn <unsigned int,unsigned int> Elf32_Dyn;
typedef TT_Elf32::Sym <unsigned short,unsigned int,void> Elf32_Sym;
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Ehdr) == 52)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Phdr) == 32)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Shdr) == 40)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Dyn) == 8)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE32_Sym) == 16)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Ehdr) == 52)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Phdr) == 32)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Shdr) == 40)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Dyn) == 8)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf32_Sym) == 16)
typedef TT_Elf ::Ehdr<LE32,LE64,LE64,LE16> Elf_LE64_Ehdr;
typedef TT_Elf64::Phdr<LE32,LE64,LE64,LE64> Elf_LE64_Phdr;
typedef TT_Elf64::Shdr<LE32,LE64,LE64,LE64> Elf_LE64_Shdr;
typedef TT_Elf ::Dyn <LE64,LE64> Elf_LE64_Dyn;
typedef TT_Elf ::Ehdr<unsigned int,unsigned long long,
unsigned long long,unsigned short> Elf64_Ehdr;
typedef TT_Elf64::Phdr<unsigned int,unsigned long long,
unsigned long long,unsigned long long> Elf64_Phdr;
typedef TT_Elf64::Shdr<unsigned int,unsigned long long,
unsigned long long,unsigned long long> Elf64_Shdr;
typedef TT_Elf ::Dyn <unsigned long long,unsigned long long> Elf64_Dyn;
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Ehdr) == 64)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Phdr) == 56)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Shdr) == 64)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf_LE64_Dyn) == 16)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Ehdr) == 64)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Phdr) == 56)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Shdr) == 64)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(Elf64_Dyn) == 16)
#endif /* already included */ #endif /* already included */
+10 -8
View File
@@ -22,7 +22,7 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
*/ */
@@ -110,7 +110,7 @@ int PackExe::buildLoader(const Filter *)
initLoader(nrv_loader,sizeof(nrv_loader)); initLoader(nrv_loader,sizeof(nrv_loader));
addLoader("EXEENTRY", addLoader("EXEENTRY",
relocsize ? "EXERELPU" : "", relocsize ? "EXERELPU" : "",
"EXEMAIN4""+G5DXXXX""UPX1HEAD""EXECUTPO", "EXEMAIN4,+G5DXXXX,UPX1HEAD,EXECUTPO",
NULL NULL
); );
if (ph.method == M_NRV2B_8) if (ph.method == M_NRV2B_8)
@@ -122,7 +122,7 @@ int PackExe::buildLoader(const Filter *)
opt->cpu == opt->CPU_8086 ? "N2BX8602" : "N2B28602", opt->cpu == opt->CPU_8086 ? "N2BX8602" : "N2B28602",
"NRV2BEX3", "NRV2BEX3",
ph.c_len > 0xffff ? "N2B64K02" : "", ph.c_len > 0xffff ? "N2B64K02" : "",
"NRV2BEX9""NRV2B16E", "NRV2BEX9,NRV2B16E",
NULL NULL
); );
else if (ph.method == M_NRV2D_8) else if (ph.method == M_NRV2D_8)
@@ -134,7 +134,7 @@ int PackExe::buildLoader(const Filter *)
opt->cpu == opt->CPU_8086 ? "N2DX8602" : "N2D28602", opt->cpu == opt->CPU_8086 ? "N2DX8602" : "N2D28602",
"NRV2DEX3", "NRV2DEX3",
ph.c_len > 0xffff ? "N2D64K02" : "", ph.c_len > 0xffff ? "N2D64K02" : "",
"NRV2DEX9""NRV2D16E", "NRV2DEX9,NRV2D16E",
NULL NULL
); );
else if (ph.method == M_NRV2E_8) else if (ph.method == M_NRV2E_8)
@@ -146,7 +146,7 @@ int PackExe::buildLoader(const Filter *)
opt->cpu == opt->CPU_8086 ? "N2EX8602" : "N2E28602", opt->cpu == opt->CPU_8086 ? "N2EX8602" : "N2E28602",
"NRV2EEX3", "NRV2EEX3",
ph.c_len > 0xffff ? "N2E64K02" : "", ph.c_len > 0xffff ? "N2E64K02" : "",
"NRV2EEX9""NRV2E16E", "NRV2EEX9,NRV2E16E",
NULL NULL
); );
else else
@@ -293,7 +293,9 @@ unsigned optimize_relocs(upx_byte *b, const unsigned size,
{ {
addr = get_le32(relocs+4*i); addr = get_le32(relocs+4*i);
//printf ("%x\n",es*16+di); //printf ("%x\n",es*16+di);
if (addr - es*16 > 0xfffe) if ((addr - es*16 > 0xfffe)
|| (i == nrelocs - 1 && addr - es * 16 > 0xff00)
)
{ {
// segment change // segment change
t = 1+(0xffff-di)/254; t = 1+(0xffff-di)/254;
@@ -409,7 +411,7 @@ void PackExe::pack(OutputFile *fo)
throwCantPack("decompressor limit exceeded, send a bugreport"); throwCantPack("decompressor limit exceeded, send a bugreport");
#ifdef TESTING #ifdef TESTING
if (opt->debug) if (opt->debug.debug_level)
{ {
printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len); printf("image+relocs %d -> %d\n",ih_imagesize+relocsize,ph.c_len);
printf("offsets: %d - %d\nmatches: %d - %d\nruns: %d - %d\n", printf("offsets: %d - %d\nmatches: %d - %d\nruns: %d - %d\n",
@@ -525,7 +527,7 @@ void PackExe::pack(OutputFile *fo)
// write header + write loader + compressed file // write header + write loader + compressed file
#ifdef TESTING #ifdef TESTING
if (opt->debug) if (opt->debug.debug_level)
printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len); printf("\n%d %d %d %d\n",(int)sizeof(oh),e_len,packedsize,d_len);
#endif #endif
fo->write(&oh,sizeof(oh)); fo->write(&oh,sizeof(oh));
+1444 -208
View File
File diff suppressed because it is too large Load Diff
+265 -14
View File
@@ -31,6 +31,256 @@
#define __UPX_P_LX_ELF_H #define __UPX_P_LX_ELF_H
class PackLinuxElf : public PackUnix
{
typedef PackUnix super;
public:
PackLinuxElf(InputFile *f);
virtual ~PackLinuxElf();
/*virtual int buildLoader(const Filter *);*/
virtual bool canUnpackVersion(int version) const { return (version >= 11); }
protected:
virtual const int *getCompressionMethods(int method, int level) const;
// All other virtual functions in this class must be pure virtual
// because they depend on Elf32 or Elf64 data structures, which differ.
virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header
virtual void pack2(OutputFile *, Filter &) = 0; // append compressed data
//virtual void pack3(OutputFile *, Filter &) = 0; // append loader
virtual void pack4(OutputFile *, Filter &) = 0; // append pack header
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
) = 0;
virtual int buildLinuxLoader(
upx_byte const *const proto, // assembly-only sections
unsigned const szproto,
upx_byte const *const fold, // linked assembly + C section
unsigned const szfold,
Filter const *ft
) = 0;
virtual void unpack(OutputFile *fo) = 0;
protected:
unsigned sz_phdrs; // sizeof Phdr[]
unsigned sz_elf_hdrs; // all Elf headers
};
class PackLinuxElf32 : public PackLinuxElf
{
typedef PackLinuxElf super;
public:
PackLinuxElf32(InputFile *f);
virtual ~PackLinuxElf32();
protected:
virtual int checkEhdr(
Elf32_Ehdr const *ehdr,
unsigned char e_machine,
unsigned char ei_class,
unsigned char ei_data) const;
virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
//virtual void pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append pack header
virtual void unpack(OutputFile *fo);
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
);
virtual off_t getbrk(const Elf32_Phdr *phdr, int e_phnum) const;
virtual void patchLoader();
virtual void updateLoader(OutputFile *fo);
virtual unsigned find_LOAD_gap(Elf32_Phdr const *const phdri, unsigned const k,
unsigned const e_phnum);
protected:
Elf32_Ehdr ehdri; // from input file
Elf32_Phdr *phdri; // for input file
struct cprElfHdr1 {
Elf32_Ehdr ehdr;
Elf32_Phdr phdr[1];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr2 {
Elf32_Ehdr ehdr;
Elf32_Phdr phdr[2];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr3 {
Elf32_Ehdr ehdr;
Elf32_Phdr phdr[3];
l_info linfo;
}
__attribute_packed;
cprElfHdr3 elfout;
};
class PackLinuxElf64 : public PackLinuxElf
{
typedef PackLinuxElf super;
public:
PackLinuxElf64(InputFile *f);
virtual ~PackLinuxElf64();
/*virtual int buildLoader(const Filter *);*/
protected:
virtual int checkEhdr(
Elf64_Ehdr const *ehdr,
unsigned char e_machine,
unsigned char ei_class,
unsigned char ei_data) const;
virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
//virtual void pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append pack header
virtual void unpack(OutputFile *fo);
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
);
virtual off_t getbrk(const Elf64_Phdr *phdr, int e_phnum) const;
virtual void patchLoader();
virtual void updateLoader(OutputFile *fo);
virtual unsigned find_LOAD_gap(Elf64_Phdr const *const phdri, unsigned const k,
unsigned const e_phnum);
protected:
Elf64_Ehdr ehdri; // from input file
Elf64_Phdr *phdri; // for input file
struct cprElfHdr1 {
Elf64_Ehdr ehdr;
Elf64_Phdr phdr[1];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr2 {
Elf64_Ehdr ehdr;
Elf64_Phdr phdr[2];
l_info linfo;
}
__attribute_packed;
struct cprElfHdr3 {
Elf64_Ehdr ehdr;
Elf64_Phdr phdr[3];
l_info linfo;
}
__attribute_packed;
cprElfHdr3 elfout;
};
class PackLinuxElf32Be : public PackLinuxElf32
{
typedef PackLinuxElf32 super;
protected:
PackLinuxElf32Be(InputFile *f) : super(f) { }
virtual acc_uint64l_t get_native64(const void *b) const { return get_be64(b); }
virtual unsigned get_native32(const void *b) const { return get_be32(b); }
virtual unsigned get_native16(const void *b) const { return get_be16(b); }
virtual void set_native64(void *b, acc_uint64l_t v) const { set_be64(b, v); }
virtual void set_native32(void *b, unsigned v) const { set_be32(b, v); }
virtual void set_native16(void *b, unsigned v) const { set_be16(b, v); }
};
class PackLinuxElf64Le : public PackLinuxElf64
{
typedef PackLinuxElf64 super;
protected:
PackLinuxElf64Le(InputFile *f) : super(f) { }
virtual acc_uint64l_t get_native64(const void *b) const { return get_le64(b); }
virtual unsigned get_native32(const void *b) const { return get_le32(b); }
virtual unsigned get_native16(const void *b) const { return get_le16(b); }
virtual void set_native64(void *b, acc_uint64l_t v) const { set_le64(b, v); }
virtual void set_native32(void *b, unsigned v) const { set_le32(b, v); }
virtual void set_native16(void *b, unsigned v) const { set_le16(b, v); }
};
/*************************************************************************
// linux/elf64amd
**************************************************************************/
class PackLinuxElf64amd : public PackLinuxElf64Le
{
typedef PackLinuxElf64Le super;
public:
PackLinuxElf64amd(InputFile *f);
virtual ~PackLinuxElf64amd();
virtual int getFormat() const { return UPX_F_LINUX_ELF64_AMD; }
virtual const char *getName() const { return "linux/ElfAMD"; }
virtual const int *getFilters() const;
virtual bool canPack();
protected:
virtual void pack3(OutputFile *, Filter &); // append loader
virtual const int *getCompressionMethods(int method, int level) const;
virtual int buildLinuxLoader(
upx_byte const *const proto, // assembly-only sections
unsigned const szproto,
upx_byte const *const fold, // linked assembly + C section
unsigned const szfold,
Filter const *ft
);
virtual int buildLoader(const Filter *);
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
);
};
/*************************************************************************
// linux/elf32ppc
**************************************************************************/
class PackLinuxElf32ppc : public PackLinuxElf32Be
{
typedef PackLinuxElf32Be super;
public:
PackLinuxElf32ppc(InputFile *f);
virtual ~PackLinuxElf32ppc();
virtual int getFormat() const { return UPX_F_LINUX_ELFPPC32; }
virtual const char *getName() const { return "linux/ElfPPC"; }
virtual const int *getFilters() const;
virtual bool canPack();
protected:
virtual void pack3(OutputFile *, Filter &); // append loader
virtual const int *getCompressionMethods(int method, int level) const;
virtual int buildLinuxLoader(
upx_byte const *const proto, // assembly-only sections
unsigned const szproto,
upx_byte const *const fold, // linked assembly + C section
unsigned const szfold,
Filter const *ft
);
virtual int buildLoader(const Filter *);
virtual void generateElfHdr(
OutputFile *,
void const *proto,
unsigned const brka
);
};
/************************************************************************* /*************************************************************************
// linux/elf386 // linux/elf386
**************************************************************************/ **************************************************************************/
@@ -53,29 +303,30 @@ public:
virtual bool canUnpackVersion(int version) const virtual bool canUnpackVersion(int version) const
{ return (version >= 11); } { return (version >= 11); }
protected:
struct Extent {
off_t offset;
off_t size;
};
virtual void packExtent(const Extent &x,
unsigned &total_in, unsigned &total_out, Filter *, OutputFile *);
virtual void unpackExtent(unsigned wanted, OutputFile *fo,
unsigned &total_in, unsigned &total_out,
unsigned &c_adler, unsigned &u_adler,
bool first_PF_X, unsigned szb_info );
protected: protected:
virtual void pack1(OutputFile *, Filter &); // generate executable header virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data virtual void pack2(OutputFile *, Filter &); // append compressed data
virtual void pack3(OutputFile *, Filter &); // append loader virtual void pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append pack header
virtual void patchLoader(); virtual void patchLoader();
Elf_LE32_Ehdr ehdri; // from input file Elf32_Ehdr ehdri; // from input file
Elf_LE32_Phdr *phdri; // for input file Elf32_Phdr *phdri; // for input file
unsigned sz_phdrs; // sizeof Phdr[] unsigned sz_phdrs; // sizeof Phdr[]
char *file_image; // if ET_DYN investigation
Elf32_Dyn const *dynseg; // from PT_DYNAMIC
unsigned int const *hashtab; // from DT_HASH
char const *dynstr; // from DT_STRTAB
Elf32_Sym const *dynsym; // from DT_SYMTAB
static unsigned elf_hash(char const *) /*const*/;
virtual void const *elf_find_dynamic(unsigned) const;
virtual Elf32_Sym const *elf_lookup(char const *) const;
virtual unsigned elf_get_offset_from_address(unsigned) const;
virtual unsigned find_LOAD_gap(Elf32_Phdr const *const phdri, unsigned const k,
unsigned const e_phnum);
}; };
+120 -64
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2001-2004 John F. Reiser Copyright (C) 2001-2006 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -37,12 +37,14 @@
#include "p_unix.h" #include "p_unix.h"
#include "p_lx_exc.h" #include "p_lx_exc.h"
#define PT_LOAD Elf_LE32_Phdr::PT_LOAD #define PT_LOAD Elf32_Phdr::PT_LOAD
#define PT_DYNAMIC Elf_LE32_Phdr::PT_DYNAMIC #define PT_DYNAMIC Elf32_Phdr::PT_DYNAMIC
#define DT_NULL Elf_LE32_Dyn::DT_NULL #if 0 // UNUSED
#define DT_NEEDED Elf_LE32_Dyn::DT_NEEDED #define DT_NULL Elf32_Dyn::DT_NULL
#define DT_STRTAB Elf_LE32_Dyn::DT_STRTAB #define DT_NEEDED Elf32_Dyn::DT_NEEDED
#define DT_STRSZ Elf_LE32_Dyn::DT_STRSZ #define DT_STRTAB Elf32_Dyn::DT_STRTAB
#define DT_STRSZ Elf32_Dyn::DT_STRSZ
#endif
/************************************************************************* /*************************************************************************
@@ -88,12 +90,13 @@ PackLinuxI386::generateElfHdr(
{ {
cprElfHdr1 *const h1 = (cprElfHdr1 *)&elfout; cprElfHdr1 *const h1 = (cprElfHdr1 *)&elfout;
cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout; cprElfHdr2 *const h2 = (cprElfHdr2 *)&elfout;
memcpy(h2, proto, sizeof(*h2)); cprElfHdr3 *const h3 = (cprElfHdr3 *)&elfout;
memcpy(h3, proto, sizeof(*h3)); // reads beyond, but OK
assert(h2->ehdr.e_phoff == sizeof(Elf_LE32_Ehdr)); assert(h2->ehdr.e_phoff == sizeof(Elf32_Ehdr));
assert(h2->ehdr.e_shoff == 0); assert(h2->ehdr.e_shoff == 0);
assert(h2->ehdr.e_ehsize == sizeof(Elf_LE32_Ehdr)); assert(h2->ehdr.e_ehsize == sizeof(Elf32_Ehdr));
assert(h2->ehdr.e_phentsize == sizeof(Elf_LE32_Phdr)); assert(h2->ehdr.e_phentsize == sizeof(Elf32_Phdr));
assert(h2->ehdr.e_shnum == 0); assert(h2->ehdr.e_shnum == 0);
#if 0 //{ #if 0 //{
@@ -105,12 +108,22 @@ PackLinuxI386::generateElfHdr(
// Info for OS kernel to set the brk() // Info for OS kernel to set the brk()
if (brka) { if (brka) {
#define PAGE_MASK (~0ul<<12)
// linux-2.6.14 binfmt_elf.c: SIGKILL if (0==.p_memsz) on a page boundary
unsigned const brkb = brka | ((0==(~PAGE_MASK & brka)) ? 0x20 : 0);
h2->phdr[1].p_type = PT_LOAD; // be sure h2->phdr[1].p_type = PT_LOAD; // be sure
h2->phdr[1].p_offset = 0xfff&brka; h2->phdr[1].p_offset = ~PAGE_MASK & brkb;
h2->phdr[1].p_vaddr = brka; h2->phdr[1].p_vaddr = brkb;
h2->phdr[1].p_paddr = brka; h2->phdr[1].p_paddr = brkb;
h2->phdr[1].p_filesz = 0; h2->phdr[1].p_filesz = 0;
h2->phdr[1].p_memsz = 0; h2->phdr[1].p_memsz = 0;
if (0==h2->phdr[1].p_flags) {
h2->phdr[1].p_flags = Elf32_Phdr::PF_R|Elf32_Phdr::PF_W;
}
if (0==h2->phdr[1].p_align) {
h2->phdr[1].p_align = 0x1000;
}
#undef PAGE_MASK
} }
if (ph.format==UPX_F_LINUX_i386 ) { if (ph.format==UPX_F_LINUX_i386 ) {
@@ -125,10 +138,15 @@ PackLinuxI386::generateElfHdr(
} }
else if (ph.format==UPX_F_LINUX_SH_i386) { else if (ph.format==UPX_F_LINUX_SH_i386) {
assert(h2->ehdr.e_phnum==1); assert(h2->ehdr.e_phnum==1);
h2->ehdr.e_phnum = 2; h2->ehdr.e_phnum = 1;
memset(&h2->linfo, 0, sizeof(h2->linfo)); memset(&h2->linfo, 0, sizeof(h2->linfo));
fo->write(h2, sizeof(*h2)); fo->write(h2, sizeof(*h2));
} }
else if (ph.format==UPX_F_LINUX_ELFI_i386) {
assert(h3->ehdr.e_phnum==3);
memset(&h3->linfo, 0, sizeof(h3->linfo));
fo->write(h3, sizeof(*h3));
}
else { else {
assert(false); // unknown ph.format, PackUnix::generateElfHdr assert(false); // unknown ph.format, PackUnix::generateElfHdr
} }
@@ -150,10 +168,10 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
(elfout.ehdr.e_phentsize * elfout.ehdr.e_phnum) + (elfout.ehdr.e_phentsize * elfout.ehdr.e_phnum) +
sizeof(l_info) + sizeof(l_info) +
((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) ; ((elfout.ehdr.e_phnum==3) ? (unsigned) elfout.phdr[2].p_memsz : 0) ;
unsigned len = fo->getBytesWritten();
set_native32(&elfout.phdr[0].p_filesz, len);
super::pack4(fo, ft); // write PackHeader and overlay_offset super::pack4(fo, ft); // write PackHeader and overlay_offset
unsigned eod = fo->getBytesWritten();
elfout.phdr[0].p_filesz = eod;
#if 0 // { #if 0 // {
// /usr/bin/strip from RedHat 8.0 (binutils-2.13.90.0.2-2) // /usr/bin/strip from RedHat 8.0 (binutils-2.13.90.0.2-2)
@@ -170,10 +188,11 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
// Supply a "linking view" that covers everything, // Supply a "linking view" that covers everything,
// so that 'strip' does not omit everything. // so that 'strip' does not omit everything.
Elf_LE32_Shdr shdr; Elf32_Shdr shdr;
// The section header string table. // The section header string table.
char const shstrtab[] = "\0.\0.shstrtab"; char const shstrtab[] = "\0.\0.shstrtab";
unsigned eod = elfout.phdr[0].p_filesz;
set_native32(&elfout.ehdr.e_shoff, eod); set_native32(&elfout.ehdr.e_shoff, eod);
set_native16(&elfout.ehdr.e_shentsize, sizeof(shdr)); set_native16(&elfout.ehdr.e_shentsize, sizeof(shdr));
set_native16(&elfout.ehdr.e_shnum, 3); set_native16(&elfout.ehdr.e_shnum, 3);
@@ -181,14 +200,14 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
// An empty Elf32_Shdr for space as a null index. // An empty Elf32_Shdr for space as a null index.
memset(&shdr, 0, sizeof(shdr)); memset(&shdr, 0, sizeof(shdr));
set_native32(&shdr.sh_type, Elf_LE32_Shdr::SHT_NULL); set_native32(&shdr.sh_type, Elf32_Shdr::SHT_NULL);
fo->write(&shdr, sizeof(shdr)); fo->write(&shdr, sizeof(shdr));
// Cover all the bits we need at runtime. // Cover all the bits we need at runtime.
memset(&shdr, 0, sizeof(shdr)); memset(&shdr, 0, sizeof(shdr));
set_native32(&shdr.sh_name, 1); set_native32(&shdr.sh_name, 1);
set_native32(&shdr.sh_type, Elf_LE32_Shdr::SHT_PROGBITS); set_native32(&shdr.sh_type, Elf32_Shdr::SHT_PROGBITS);
set_native32(&shdr.sh_flags, Elf_LE32_Shdr::SHF_ALLOC); set_native32(&shdr.sh_flags, Elf32_Shdr::SHF_ALLOC);
set_native32(&shdr.sh_addr, elfout.phdr[0].p_vaddr); set_native32(&shdr.sh_addr, elfout.phdr[0].p_vaddr);
set_native32(&shdr.sh_offset, overlay_offset); set_native32(&shdr.sh_offset, overlay_offset);
set_native32(&shdr.sh_size, eod - overlay_offset); set_native32(&shdr.sh_size, eod - overlay_offset);
@@ -198,7 +217,7 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
// A section header for the section header string table. // A section header for the section header string table.
memset(&shdr, 0, sizeof(shdr)); memset(&shdr, 0, sizeof(shdr));
set_native32(&shdr.sh_name, 3); set_native32(&shdr.sh_name, 3);
set_native32(&shdr.sh_type, Elf_LE32_Shdr::SHT_STRTAB); set_native32(&shdr.sh_type, Elf32_Shdr::SHT_STRTAB);
set_native32(&shdr.sh_offset, 3*sizeof(shdr) + eod); set_native32(&shdr.sh_offset, 3*sizeof(shdr) + eod);
set_native32(&shdr.sh_size, sizeof(shstrtab)); set_native32(&shdr.sh_size, sizeof(shstrtab));
fo->write(&shdr, sizeof(shdr)); fo->write(&shdr, sizeof(shdr));
@@ -206,6 +225,7 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
fo->write(shstrtab, sizeof(shstrtab)); fo->write(shstrtab, sizeof(shstrtab));
#endif // } #endif // }
#undef PAGE_MASK
#define PAGE_MASK (~0u<<12) #define PAGE_MASK (~0u<<12)
// pre-calculate for benefit of runtime disappearing act via munmap() // pre-calculate for benefit of runtime disappearing act via munmap()
elfout.phdr[0].p_memsz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz); elfout.phdr[0].p_memsz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
@@ -213,9 +233,7 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
// rewrite Elf header // rewrite Elf header
fo->seek(0, SEEK_SET); fo->seek(0, SEEK_SET);
fo->rewrite(&elfout, sizeof(elfout.ehdr) + fo->rewrite(&elfout, overlay_offset);
elfout.ehdr.e_phnum * sizeof(elfout.phdr[0]) +
sizeof(l_info) );
} }
static unsigned static unsigned
@@ -238,26 +256,37 @@ PackLinuxI386::buildLinuxLoader(
{ {
initLoader(proto, szproto); initLoader(proto, szproto);
cprElfHdr1 const *const hf = (cprElfHdr1 const *)fold;
unsigned const fold_hdrlen = umax(0x80, sizeof(hf->ehdr) +
hf->ehdr.e_phentsize * hf->ehdr.e_phnum + sizeof(l_info) );
struct b_info h; memset(&h, 0, sizeof(h)); struct b_info h; memset(&h, 0, sizeof(h));
h.sz_unc = szfold - fold_hdrlen; unsigned fold_hdrlen = 0;
if (0 < szfold) {
cprElfHdr1 const *const hf = (cprElfHdr1 const *)fold;
fold_hdrlen = sizeof(hf->ehdr) + hf->ehdr.e_phentsize * hf->ehdr.e_phnum +
sizeof(l_info);
if (0 == get_le32(fold_hdrlen + fold)) {
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
fold_hdrlen = umax(0x80, fold_hdrlen);
}
h.sz_unc = (szfold < fold_hdrlen) ? 0 : (szfold - fold_hdrlen);
h.b_method = (unsigned char) ph.method; h.b_method = (unsigned char) ph.method;
h.b_ftid = (unsigned char) ph.filter; h.b_ftid = (unsigned char) ph.filter;
h.b_cto8 = (unsigned char) ph.filter_cto; h.b_cto8 = (unsigned char) ph.filter_cto;
}
unsigned char const *const uncLoader = fold_hdrlen + fold; unsigned char const *const uncLoader = fold_hdrlen + fold;
unsigned char *const cprLoader = new unsigned char[sizeof(h) + h.sz_unc]; unsigned char *const cprLoader = new unsigned char[sizeof(h) + h.sz_unc];
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &h.sz_cpr, if (0 < szfold) {
unsigned sz_cpr;
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &sz_cpr,
NULL, ph.method, 10, NULL, NULL ); NULL, ph.method, 10, NULL, NULL );
h.sz_cpr = sz_cpr;
if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc) if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc)
throwInternalError("loader compression failed"); throwInternalError("loader compression failed");
}
memcpy(cprLoader, &h, sizeof(h)); memcpy(cprLoader, &h, sizeof(h));
// This adds the definition to the "library", to be used later. // This adds the definition to the "library", to be used later.
linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr); linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr);
delete cprLoader; delete [] cprLoader;
n_mru = ft->n_mru; n_mru = ft->n_mru;
@@ -276,71 +305,74 @@ PackLinuxI386::buildLinuxLoader(
// compressed data // compressed data
b_len + ph.c_len ); b_len + ph.c_len );
// entry to stub // entry to stub
addLoader("LEXEC000", 0); addLoader("LEXEC000", NULL);
if (ft->id) { if (ft->id) {
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
addLoader("LXUNF000", 0); addLoader("LXUNF000", NULL);
addLoader("LXUNF002", 0); addLoader("LXUNF002", NULL);
if (0x80==(ft->id & 0xF0)) { if (0x80==(ft->id & 0xF0)) {
if (256==n_mru) { if (256==n_mru) {
addLoader("MRUBYTE0", 0); addLoader("MRUBYTE0", NULL);
} }
else if (n_mru) { else if (n_mru) {
addLoader("LXMRU005", 0); addLoader("LXMRU005", NULL);
} }
if (n_mru) { if (n_mru) {
addLoader("LXMRU006", 0); addLoader("LXMRU006", NULL);
} }
else { else {
addLoader("LXMRU007", 0); addLoader("LXMRU007", NULL);
} }
} }
else if (0x40==(ft->id & 0xF0)) { else if (0x40==(ft->id & 0xF0)) {
addLoader("LXUNF008", 0); addLoader("LXUNF008", NULL);
} }
addLoader("LXUNF010", 0); addLoader("LXUNF010", NULL);
} }
if (n_mru) { if (n_mru) {
addLoader("LEXEC009", 0); addLoader("LEXEC009", NULL);
} }
} }
addLoader("LEXEC010", 0); addLoader("LEXEC010", NULL);
addLoader(getDecompressor(), 0); addLoader(getDecompressor(), NULL);
addLoader("LEXEC015", 0); addLoader("LEXEC015", NULL);
if (ft->id) { if (ft->id) {
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
if (0x80!=(ft->id & 0xF0)) { if (0x80!=(ft->id & 0xF0)) {
addLoader("LXUNF042", 0); addLoader("LXUNF042", NULL);
} }
} }
else { // decompr, unfilter not separate else { // decompr, unfilter not separate
if (0x80==(ft->id & 0xF0)) { if (0x80==(ft->id & 0xF0)) {
addLoader("LEXEC110", 0); addLoader("LEXEC110", NULL);
if (n_mru) { if (n_mru) {
addLoader("LEXEC100", 0); addLoader("LEXEC100", NULL);
} }
// bug in APP: jmp and label must be in same .asx/.asy // bug in APP: jmp and label must be in same .asx/.asy
addLoader("LEXEC016", 0); addLoader("LEXEC016", NULL);
} }
} }
addFilter32(ft->id); addFilter32(ft->id);
if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate if (ph.format==UPX_F_LINUX_ELF_i386) { // decompr, unfilter are separate
if (0x80==(ft->id & 0xF0)) { if (0x80==(ft->id & 0xF0)) {
if (0==n_mru) { if (0==n_mru) {
addLoader("LXMRU058", 0); addLoader("LXMRU058", NULL);
} }
} }
addLoader("LXUNF035", 0); addLoader("LXUNF035", NULL);
} }
else { // decompr always unfilters else { // decompr always unfilters
addLoader("LEXEC017", 0); addLoader("LEXEC017", NULL);
} }
} }
else {
addLoader("LEXEC017", NULL);
}
addLoader("IDENTSTR", 0); addLoader("IDENTSTR", NULL);
addLoader("LEXEC020", 0); addLoader("LEXEC020", NULL);
addLoader("FOLDEXEC", 0); addLoader("FOLDEXEC", NULL);
char *ptr_cto = (char *)const_cast<unsigned char *>(getLoader()); char *ptr_cto = (char *)const_cast<unsigned char *>(getLoader());
int sz_cto = getLoaderSize(); int sz_cto = getLoaderSize();
@@ -377,7 +409,14 @@ PackLinuxI386::buildLoader(Filter const *ft)
// filter // filter
optimizeFilter(&fold_ft, buf, sz_fold); optimizeFilter(&fold_ft, buf, sz_fold);
bool success = fold_ft.filter(buf + sizeof(cprElfHdr2), sz_fold - sizeof(cprElfHdr2));
unsigned fold_hdrlen = sizeof(l_info) + sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * get_native32(&((Elf32_Ehdr const *)(void *)buf)->e_phnum);
if (0 == get_le32(fold_hdrlen + buf)) {
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
fold_hdrlen = umax(0x80, fold_hdrlen);
}
bool success = fold_ft.filter(buf + fold_hdrlen, sz_fold - fold_hdrlen);
(void)success; (void)success;
return buildLinuxLoader( return buildLinuxLoader(
@@ -385,6 +424,7 @@ PackLinuxI386::buildLoader(Filter const *ft)
buf, sz_fold, ft ); buf, sz_fold, ft );
} }
// FIXME: getLoaderPrefixSize is unused?
int PackLinuxI386::getLoaderPrefixSize() const int PackLinuxI386::getLoaderPrefixSize() const
{ {
return 116; return 116;
@@ -396,7 +436,7 @@ int PackLinuxI386::getLoaderPrefixSize() const
**************************************************************************/ **************************************************************************/
// basic check of an Linux ELF Ehdr // basic check of an Linux ELF Ehdr
int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const int PackLinuxI386::checkEhdr(const Elf32_Ehdr *ehdr) const
{ {
const unsigned char * const buf = ehdr->e_ident; const unsigned char * const buf = ehdr->e_ident;
@@ -406,15 +446,16 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
// now check the ELF header // now check the ELF header
if (!memcmp(buf+8, "FreeBSD", 7)) // branded if (!memcmp(buf+8, "FreeBSD", 7)) // branded
return 1; return 1;
if (ehdr->e_type != 2) // executable if (ehdr->e_type != Elf32_Ehdr::ET_EXEC
&& ehdr->e_type != Elf32_Ehdr::ET_DYN ) // executable
return 2; return 2;
if (ehdr->e_machine != 3) // Intel 80386 if (ehdr->e_machine != Elf32_Ehdr::EM_386) // Intel 80386
return 3; return 3;
if (ehdr->e_version != 1) // version if (ehdr->e_version != Elf32_Ehdr::EV_CURRENT) // version
return 4; return 4;
if (ehdr->e_phnum < 1) if (ehdr->e_phnum < 1)
return 5; return 5;
if (ehdr->e_phentsize != sizeof(Elf_LE32_Phdr)) if (ehdr->e_phentsize != sizeof(Elf32_Phdr))
return 6; return 6;
// check for Linux kernels // check for Linux kernels
@@ -435,7 +476,7 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
} }
off_t PackLinuxI386::getbrk(const Elf_LE32_Phdr *phdr, int e_phnum) const off_t PackLinuxI386::getbrk(const Elf32_Phdr *phdr, int e_phnum) const
{ {
off_t brka = 0; off_t brka = 0;
for (int j = 0; j < e_phnum; ++phdr, ++j) { for (int j = 0; j < e_phnum; ++phdr, ++j) {
@@ -448,6 +489,21 @@ off_t PackLinuxI386::getbrk(const Elf_LE32_Phdr *phdr, int e_phnum) const
return brka; return brka;
} }
off_t PackLinuxI386::getbase(const Elf32_Phdr *phdr, int e_phnum) const
{
off_t base = ~0u;
for (int j = 0; j < e_phnum; ++phdr, ++j) {
if (phdr->PT_LOAD == phdr->p_type) {
if (phdr->p_vaddr < (unsigned) base)
base = phdr->p_vaddr;
}
}
if (0!=base) {
return base;
}
return 0x12000;
}
/************************************************************************* /*************************************************************************
// //
@@ -458,7 +514,7 @@ bool PackLinuxI386::canPack()
if (exetype != 0) if (exetype != 0)
return super::canPack(); return super::canPack();
Elf_LE32_Ehdr ehdr; Elf32_Ehdr ehdr;
unsigned char *buf = ehdr.e_ident; unsigned char *buf = ehdr.e_ident;
fi->readx(&ehdr, sizeof(ehdr)); fi->readx(&ehdr, sizeof(ehdr));
+13 -12
View File
@@ -74,8 +74,9 @@ protected:
virtual void updateLoader(OutputFile *); virtual void updateLoader(OutputFile *);
// ELF util // ELF util
virtual int checkEhdr(const Elf_LE32_Ehdr *ehdr) const; virtual int checkEhdr(const Elf32_Ehdr *ehdr) const;
virtual off_t getbrk(const Elf_LE32_Phdr *phdr, int e_phnum) const; virtual off_t getbrk(const Elf32_Phdr *phdr, int e_phnum) const;
virtual off_t getbase(const Elf32_Phdr *phdr, int e_phnum) const;
enum { enum {
UPX_ELF_MAGIC = 0x5850557f // "\x7fUPX" UPX_ELF_MAGIC = 0x5850557f // "\x7fUPX"
@@ -84,27 +85,27 @@ protected:
unsigned n_mru; unsigned n_mru;
struct cprElfHdr1 { struct cprElfHdr1 {
struct Elf_LE32_Ehdr ehdr; Elf32_Ehdr ehdr;
struct Elf_LE32_Phdr phdr[1]; Elf32_Phdr phdr[1];
struct l_info linfo; l_info linfo;
} }
__attribute_packed; __attribute_packed;
struct cprElfHdr2 { struct cprElfHdr2 {
struct Elf_LE32_Ehdr ehdr; Elf32_Ehdr ehdr;
struct Elf_LE32_Phdr phdr[2]; Elf32_Phdr phdr[2];
struct l_info linfo; l_info linfo;
} }
__attribute_packed; __attribute_packed;
struct cprElfHdr3 { struct cprElfHdr3 {
struct Elf_LE32_Ehdr ehdr; Elf32_Ehdr ehdr;
struct Elf_LE32_Phdr phdr[3]; Elf32_Phdr phdr[3];
struct l_info linfo; l_info linfo;
} }
__attribute_packed; __attribute_packed;
struct cprElfHdr3 elfout; cprElfHdr3 elfout;
}; };
+307
View File
@@ -0,0 +1,307 @@
/* p_lx_interp.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
*/
#include "conf.h"
#include "file.h"
#include "filter.h"
#include "linker.h"
#include "packer.h"
#include "p_elf.h"
#include "p_unix.h"
#include "p_lx_exc.h"
#include "p_lx_elf.h"
#include "p_lx_interp.h"
#define PT_LOAD Elf32_Phdr::PT_LOAD
#define PT_INTERP Elf32_Phdr::PT_INTERP
/*************************************************************************
//
**************************************************************************/
static const
#include "stub/l_lx_pti86.h"
static const
#include "stub/fold_pti86.h"
PackLinuxI386interp::PackLinuxI386interp(InputFile *f) :
super(f)
{
}
PackLinuxI386interp::~PackLinuxI386interp()
{
}
bool PackLinuxI386interp::canPack()
{
if (opt->o_unix.make_ptinterp) {
return true;
}
if (!opt->o_unix.use_ptinterp) {
return false;
}
return super::canPack();
}
void PackLinuxI386interp::pack1(OutputFile *fo, Filter &)
{
fi->seek(0, SEEK_SET);
fi->readx(&ehdri, sizeof(ehdri));
assert(ehdri.e_phoff == sizeof(Elf32_Ehdr)); // checked by canPack()
sz_phdrs = ehdri.e_phnum * ehdri.e_phentsize;
phdri = new Elf32_Phdr[(unsigned)ehdri.e_phnum];
fi->seek(ehdri.e_phoff, SEEK_SET);
fi->readx(phdri, sz_phdrs);
#define E Elf32_Ehdr
cprElfHdr3 h3;
memset(&h3, 0, sizeof(h3));
memcpy(h3.ehdr.e_ident, "\177ELF", 4);
h3.ehdr.e_ident[E::EI_CLASS] = E::ELFCLASS32;
h3.ehdr.e_ident[E::EI_DATA] = E::ELFDATA2LSB;
h3.ehdr.e_ident[E::EI_VERSION] = E::EV_CURRENT;
h3.ehdr.e_ident[E::EI_OSABI] = E::ELFOSABI_LINUX;
h3.ehdr.e_ident[E::EI_ABIVERSION] = E::EV_CURRENT;
h3.ehdr.e_type = E::ET_EXEC;
h3.ehdr.e_machine = E::EM_386;
h3.ehdr.e_version = 1;
h3.ehdr.e_phoff = sizeof(Elf32_Ehdr);
h3.ehdr.e_ehsize = sizeof(Elf32_Ehdr);
h3.ehdr.e_phentsize = sizeof(Elf32_Phdr);
h3.ehdr.e_phnum = 3;
h3.phdr[0].p_type = PT_LOAD;
h3.phdr[0].p_flags = Elf32_Phdr::PF_X | Elf32_Phdr::PF_R;
h3.phdr[0].p_align = 0x1000;
h3.phdr[1].p_type = PT_LOAD;
h3.phdr[1].p_flags = Elf32_Phdr::PF_W | Elf32_Phdr::PF_R;
h3.phdr[1].p_align = 1;
h3.phdr[2].p_type = PT_INTERP;
h3.phdr[2].p_offset = (char *)&h3.phdr[2].p_vaddr - (char *)&h3;
memcpy(&h3.phdr[2].p_vaddr, "/upxrun", h3.phdr[2].p_filesz = 8);
h3.phdr[2].p_align = 1;
if (opt->o_unix.make_ptinterp) { // unusual "once per release"
elfout = h3;
elfout.ehdr.e_phnum = 1;
fo->write(&elfout, elfout.ehdr.e_ehsize + elfout.ehdr.e_phentsize);
}
else { // usual case
generateElfHdr(fo, &h3, getbrk(phdri, ehdri.e_phnum));
}
#undef E
}
void PackLinuxI386interp::pack2(OutputFile *fo, Filter &ft)
{
if (opt->o_unix.make_ptinterp) {
return; // ignore current input file!
}
super::pack2(fo, ft);
}
#undef PAGE_MASK
#define PAGE_MASK (~0u<<12)
void PackLinuxI386interp::pack3(OutputFile *fo, Filter &/*ft*/)
{
unsigned base = getbase(phdri, ehdri.e_phnum);
unsigned sz = PAGE_MASK & (~PAGE_MASK + elfout.phdr[0].p_filesz);
if (base < (0x11000 + sz)) {
base = 0x11000 + sz;
}
if (opt->o_unix.make_ptinterp) {
base = 0x10000;
}
elfout.phdr[0].p_paddr = elfout.phdr[0].p_vaddr = base - sz;
if (opt->o_unix.make_ptinterp) {
initLoader(linux_i386pti_loader, sizeof(linux_i386pti_loader));
linker->addSection("FOLDEXEC", linux_i386pti_fold, sizeof(linux_i386pti_fold));
addLoader("LXPTI000", NULL);
addLoader("LXPTI040", NULL);
ph.method = M_NRV2B_LE32; addLoader(getDecompressor(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI041", NULL);
ph.method = M_NRV2D_LE32; addLoader(getDecompressor(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI042", NULL);
ph.method = M_NRV2E_LE32; addLoader(getDecompressor(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI043", NULL);
ph.method = M_CL1B_LE32; addLoader(getDecompressor(), NULL);
addLoader("LXPTI090", NULL);
addLoader("LXPTI091", NULL);
addLoader("LXPTI140", NULL);
addLoader("LXUNF002,LXUNF008,LXUNF010", NULL);
addFilter32(0x46);
addLoader("LXUNF042,LXUNF035", NULL);
addLoader("LXUNF002,LXUNF008,LXUNF010", NULL);
addFilter32(0x49);
addLoader("LXUNF042,LXUNF035", NULL);
addLoader("LXPTI200", NULL);
addLoader("FOLDEXEC", NULL);
upx_byte const *p = getLoader();
lsize = getLoaderSize();
updateLoader(fo);
fo->write(p, lsize);
elfout.phdr[0].p_filesz = fo->getBytesWritten();
}
else {
updateLoader(fo);
}
}
void PackLinuxI386interp::unpack(OutputFile *fo)
{
#define MAX_INTERP_HDR 512
char bufehdr[MAX_INTERP_HDR];
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *)bufehdr;
Elf32_Phdr const *phdr = (Elf32_Phdr *)(1+ehdr);
unsigned szb_info = sizeof(b_info);
{
fi->seek(0, SEEK_SET);
fi->readx(bufehdr, MAX_INTERP_HDR);
unsigned const e_entry = get_native32(&ehdr->e_entry);
if (e_entry < 0x401180) { /* old style, 8-byte b_info */
szb_info = 2*sizeof(unsigned);
}
}
fi->seek(overlay_offset, SEEK_SET);
p_info hbuf;
fi->readx(&hbuf, sizeof(hbuf));
unsigned orig_file_size = get_native32(&hbuf.p_filesize);
blocksize = get_native32(&hbuf.p_blocksize);
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("file header corrupted");
ibuf.alloc(blocksize + OVERHEAD);
b_info bhdr; memset(&bhdr, 0, sizeof(bhdr));
fi->readx(&bhdr, szb_info);
ph.u_len = get_native32(&bhdr.sz_unc);
ph.c_len = get_native32(&bhdr.sz_cpr);
ph.filter_cto = bhdr.b_cto8;
// Uncompress Ehdr and Phdrs.
fi->readx(ibuf, ph.c_len);
decompress(ibuf, (upx_byte *)ehdr, false);
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
off_t ptload0hi=0, ptload1lo=0, ptload1sz=0;
// decompress PT_LOAD
bool first_PF_X = true;
fi->seek(- (off_t) (szb_info + ph.c_len), SEEK_CUR);
for (unsigned j=0; j < ehdr->e_phnum; ++phdr, ++j) {
if (PT_LOAD==phdr->p_type) {
if (0==ptload0hi) {
ptload0hi = phdr->p_filesz + phdr->p_offset;
}
else if (0==ptload1lo) {
ptload1lo = phdr->p_offset;
ptload1sz = phdr->p_filesz;
}
if (fo)
fo->seek(phdr->p_offset, SEEK_SET);
if (Elf32_Phdr::PF_X & phdr->p_flags) {
unpackExtent(phdr->p_filesz, fo, total_in, total_out,
c_adler, u_adler, first_PF_X, szb_info);
first_PF_X = false;
}
else {
unpackExtent(phdr->p_filesz, fo, total_in, total_out,
c_adler, u_adler, false, szb_info);
}
}
}
if (0!=ptload1sz && ptload0hi < ptload1lo) { // alignment hole?
if (fo)
fo->seek(ptload0hi, SEEK_SET);
unpackExtent(ptload1lo - ptload0hi, fo, total_in, total_out,
c_adler, u_adler, false, szb_info);
}
if (total_out != orig_file_size) { // non-PT_LOAD stuff
if (fo)
fo->seek(0, SEEK_END);
unpackExtent(orig_file_size - total_out, fo, total_in, total_out,
c_adler, u_adler, false, szb_info);
}
// check for end-of-file
fi->readx(&bhdr, szb_info);
unsigned const sz_unc = ph.u_len = get_native32(&bhdr.sz_unc);
if (sz_unc == 0) { // uncompressed size 0 -> EOF
// note: magic is always stored le32
unsigned const sz_cpr = get_le32(&bhdr.sz_cpr);
if (sz_cpr != UPX_MAGIC_LE32) // sz_cpr must be h->magic
throwCompressedDataViolation();
}
else { // extra bytes after end?
throwCompressedDataViolation();
}
// update header with totals
ph.c_len = total_in;
ph.u_len = total_out;
// all bytes must be written
if (total_out != orig_file_size)
throwEOFException();
// finally test the checksums
if (ph.c_adler != c_adler || ph.u_adler != u_adler)
throwChecksumError();
#undef MAX_INTERP_HDR
}
/*
vi:ts=4:et
*/
+64
View File
@@ -0,0 +1,64 @@
/* p_lx_interp.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser
markus@oberhumer.com ml1050@cdata.tvnet.hu jreiser@BitWagon.com
*/
#ifndef __UPX_P_LX_INTERP_H //{
#define __UPX_P_LX_INTERP_H
/*************************************************************************
// linux/interp386
**************************************************************************/
class PackLinuxI386interp : public PackLinuxI386elf
{
typedef PackLinuxI386elf super;
public:
PackLinuxI386interp(InputFile *f);
virtual ~PackLinuxI386interp();
virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_LINUX_ELFI_i386; }
virtual const char *getName() const { return "linux/elfi386"; }
virtual bool canPack();
virtual void unpack(OutputFile *fo);
protected:
virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
virtual void pack3(OutputFile *, Filter &); // build loader
};
#endif /*} already included */
/*
vi:ts=4:et
*/
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+31 -5
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2000-2004 John F. Reiser Copyright (C) 2000-2006 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -59,6 +59,15 @@ PackLinuxI386sh::~PackLinuxI386sh()
{ {
} }
static unsigned
umax(unsigned a, unsigned b)
{
if (a <= b) {
return b;
}
return a;
}
int int
PackLinuxI386sh::buildLoader(Filter const *ft) PackLinuxI386sh::buildLoader(Filter const *ft)
{ {
@@ -78,7 +87,13 @@ PackLinuxI386sh::buildLoader(Filter const *ft)
// filter // filter
optimizeFilter(&fold_ft, buf, sz_fold); optimizeFilter(&fold_ft, buf, sz_fold);
bool success = fold_ft.filter(buf + sizeof(cprElfHdr2), sz_fold - sizeof(cprElfHdr2)); unsigned fold_hdrlen = sizeof(l_info) + sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * get_native32(&((Elf32_Ehdr const *)(void *)buf)->e_phnum);
if (0 == get_le32(fold_hdrlen + buf)) {
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
fold_hdrlen = umax(0x80, fold_hdrlen);
}
bool success = fold_ft.filter(buf + fold_hdrlen, sz_fold - fold_hdrlen);
UNUSED(success); UNUSED(success);
return buildLinuxLoader( return buildLinuxLoader(
@@ -104,7 +119,11 @@ bool PackLinuxI386sh::getShellName(char *buf)
return false; return false;
for (int j = 0; NULL != shname[j]; ++j) { for (int j = 0; NULL != shname[j]; ++j) {
if (0 == strcmp(shname[j], bname + 1)) { if (0 == strcmp(shname[j], bname + 1)) {
return super::canPack(); bool const s = super::canPack();
if (s) {
opt->o_unix.blocksize = blocksize = file_size;
}
return s;
} }
} }
return false; return false;
@@ -139,6 +158,13 @@ PackLinuxI386sh::pack1(OutputFile *fo, Filter &)
generateElfHdr(fo, linux_i386sh_fold, 0x08048000); generateElfHdr(fo, linux_i386sh_fold, 0x08048000);
} }
void
PackLinuxI386sh::pack3(OutputFile *fo, Filter &ft)
{
super::pack3(fo,ft);
elfout.phdr[0].p_filesz = fo->getBytesWritten();
}
/* /*
vi:ts=4:et vi:ts=4:et
*/ */
+1
View File
@@ -48,6 +48,7 @@ public:
virtual int buildLoader(const Filter *); virtual int buildLoader(const Filter *);
virtual void pack1(OutputFile *fo, Filter &ft); virtual void pack1(OutputFile *fo, Filter &ft);
virtual void pack3(OutputFile *fo, Filter &ft);
virtual bool canPack(); virtual bool canPack();
// virtual void unpack(OutputFile *fo) { super::unpack(fo); } // virtual void unpack(OutputFile *fo) { super::unpack(fo); }
+443
View File
@@ -0,0 +1,443 @@
/* p_mach.cpp -- pack Mach Object executable
This file is part of the UPX executable compressor.
Copyright (C) 2004 John Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
John Reiser
jreiser@users.sourceforge.net
*/
#include "conf.h"
#include "file.h"
#include "filter.h"
#include "linker.h"
#include "packer.h"
#include "p_mach.h"
static const
#include "stub/l_mac_ppc32.h"
static const
#include "stub/fold_machppc32.h"
PackMachPPC32::PackMachPPC32(InputFile *f) :
super(f), n_segment(0), rawmseg(0), msegcmd(0)
{
}
PackMachPPC32::~PackMachPPC32()
{
delete [] msegcmd;
delete [] rawmseg;
}
const int *PackMachPPC32::getCompressionMethods(int /*method*/, int /*level*/) const
{
// There really is no LE bias in M_NRV2E_LE32.
static const int m_nrv2e[] = { M_NRV2E_LE32, -1 };
return m_nrv2e;
}
const int *PackMachPPC32::getFilters() const
{
static const int filters[] = { 0xd0, -1 };
return filters;
}
int
PackMachPPC32::buildMachLoader(
upx_byte const *const proto,
unsigned const szproto,
upx_byte const *const fold,
unsigned const szfold,
Filter const */*ft*/
)
{
int eof_empty = -1;
initLoader(&eof_empty, 4096, 0, 0);
struct b_info h; memset(&h, 0, sizeof(h));
unsigned fold_hdrlen = 0;
if (0 < szfold) {
h.sz_unc = (szfold < fold_hdrlen) ? 0 : (szfold - fold_hdrlen);
h.b_method = (unsigned char) ph.method;
h.b_ftid = (unsigned char) ph.filter;
h.b_cto8 = (unsigned char) ph.filter_cto;
}
unsigned char const *const uncLoader = fold_hdrlen + fold;
unsigned char *const cprLoader = new unsigned char[sizeof(h) + h.sz_unc];
if (0 < szfold) {
unsigned sz_cpr;
int r = upx_compress(uncLoader, h.sz_unc, sizeof(h) + cprLoader, &sz_cpr,
NULL, ph.method, 10, NULL, NULL );
h.sz_cpr = sz_cpr;
if (r != UPX_E_OK || h.sz_cpr >= h.sz_unc)
throwInternalError("loader compression failed");
}
memcpy(cprLoader, &h, sizeof(h));
// This adds the definition to the "library", to be used later.
linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr);
delete [] cprLoader;
int const GAP = 128; // must match stub/l_mac_ppc.S
segcmdo.vmsize += h.sz_unc - h.sz_cpr + GAP + 64;
linker->addSection("MACOS000", proto, szproto);
addLoader("MACOS000", NULL);
addLoader("FOLDEXEC", NULL);
return getLoaderSize();
}
int
PackMachPPC32::buildLoader(const Filter *ft)
{
return buildMachLoader(
l_mac_ppc32_loader, sizeof(l_mac_ppc32_loader),
fold_machppc32, sizeof(fold_machppc32), ft );
}
void PackMachPPC32::patchLoader() { }
void PackMachPPC32::updateLoader(OutputFile *) {}
void
PackMachPPC32::patchLoaderChecksum()
{
unsigned char *const ptr = const_cast<unsigned char *>(getLoader());
l_info *const lp = &linfo;
// checksum for loader; also some PackHeader info
lp->l_checksum = 0;
lp->l_magic = UPX_MAGIC_LE32; // LE32 always
lp->l_lsize = (unsigned short) lsize;
lp->l_version = (unsigned char) ph.version;
lp->l_format = (unsigned char) ph.format;
// INFO: lp->l_checksum is currently unused
lp->l_checksum = upx_adler32(ptr, lsize);
}
static int __acc_cdecl_qsort
compare_segment_command(void const *const aa, void const *const bb)
{
Mach_segment_command const *const a = (Mach_segment_command const *)aa;
Mach_segment_command const *const b = (Mach_segment_command const *)bb;
unsigned const xa = a->cmd - Mach_segment_command::LC_SEGMENT;
unsigned const xb = b->cmd - Mach_segment_command::LC_SEGMENT;
if (xa < xb) return -1; // LC_SEGMENT first
if (xa > xb) return 1;
if (a->vmaddr < b->vmaddr) return -1; // ascending by .vmaddr
if (a->vmaddr > b->vmaddr) return 1;
return 0;
}
void
PackMachPPC32::pack4(OutputFile *fo, Filter &ft) // append PackHeader
{
// offset of p_info in compressed file
overlay_offset = sizeof(mhdro) + sizeof(segcmdo) + sizeof(threado) + sizeof(linfo);
super::pack4(fo, ft);
segcmdo.filesize = fo->getBytesWritten();
segcmdo.vmsize += segcmdo.filesize;
fo->seek(sizeof(mhdro), SEEK_SET);
fo->write(&segcmdo, sizeof(segcmdo));
fo->write(&threado, sizeof(threado));
fo->write(&linfo, sizeof(linfo));
}
void
PackMachPPC32::pack3(OutputFile *fo, Filter &ft) // append loader
{
BE32 disp;
unsigned const zero = 0;
unsigned len = fo->getBytesWritten();
fo->write(&zero, 3& -len);
len += (3& -len) + sizeof(disp);
set_be32(&disp, 4+ len - sz_mach_headers); // 4: sizeof(instruction)
fo->write(&disp, sizeof(disp));
threado.state.srr0 = len + segcmdo.vmaddr; /* entry address */
super::pack3(fo, ft);
}
// Determine length of gap between PT_LOAD phdri[k] and closest PT_LOAD
// which follows in the file (or end-of-file). Optimize for common case
// where the PT_LOAD are adjacent ascending by .p_offset. Assume no overlap.
unsigned PackMachPPC32::find_SEGMENT_gap(
unsigned const k
)
{
if (Mach_segment_command::LC_SEGMENT!=msegcmd[k].cmd
|| 0==msegcmd[k].filesize ) {
return 0;
}
unsigned const hi = get_native32(&msegcmd[k].fileoff) +
get_native32(&msegcmd[k].filesize);
unsigned lo = ph.u_file_size;
unsigned j = k;
for (;;) { // circular search, optimize for adjacent ascending
++j;
if (n_segment==j) {
j = 0;
}
if (k==j) {
break;
}
if (Mach_segment_command::LC_SEGMENT==msegcmd[j].cmd
&& 0!=msegcmd[j].filesize ) {
unsigned const t = get_native32(&msegcmd[j].fileoff);
if ((t - hi) < (lo - hi)) {
lo = t;
if (hi==lo) {
break;
}
}
}
}
return lo - hi;
}
void
PackMachPPC32::pack2(OutputFile *fo, Filter &ft) // append compressed body
{
Extent x;
unsigned k;
// count passes, set ptload vars
ui_total_passes = 0;
for (k = 0; k < n_segment; ++k) {
if (Mach_segment_command::LC_SEGMENT==msegcmd[k].cmd
&& 0!=msegcmd[k].filesize ) {
ui_total_passes++;
if (find_SEGMENT_gap(k)) {
ui_total_passes++;
}
}
}
// compress extents
unsigned total_in = 0;
unsigned total_out = 0;
unsigned hdr_ulen = mhdri.sizeofcmds;
ui_pass = 0;
ft.addvalue = 0;
int nx = 0;
for (k = 0; k < n_segment; ++k)
if (Mach_segment_command::LC_SEGMENT==msegcmd[k].cmd
&& 0!=msegcmd[k].filesize ) {
x.offset = msegcmd[k].fileoff;
x.size = msegcmd[k].filesize;
if (0 == nx) { // 1st LC_SEGMENT must cover Mach_header at 0==fileoffset
unsigned const delta = mhdri.sizeofcmds;
x.offset += delta;
x.size -= delta;
}
packExtent(x, total_in, total_out,
((Mach_segment_command::VM_PROT_EXECUTE & msegcmd[k].initprot)
? &ft : 0 ), fo, hdr_ulen );
hdr_ulen = 0;
++nx;
}
for (k = 0; k < n_segment; ++k) {
x.size = find_SEGMENT_gap(k);
if (x.size) {
x.offset = get_native32(&msegcmd[k].fileoff) +
get_native32(&msegcmd[k].filesize);
packExtent(x, total_in, total_out, 0, fo);
}
}
if ((off_t)total_in != file_size)
throwEOFException();
segcmdo.filesize = fo->getBytesWritten();
}
#undef PAGE_MASK
#undef PAGE_SIZE
#define PAGE_MASK (~0u<<12)
#define PAGE_SIZE -PAGE_MASK
void
PackMachPPC32::pack1(OutputFile *fo, Filter &/*ft*/) // generate executable header
{
mhdro = mhdri;
mhdro.ncmds = 2;
mhdro.sizeofcmds = sizeof(segcmdo) + sizeof(threado);
mhdro.flags = Mach_header::MH_NOUNDEFS;
fo->write(&mhdro, sizeof(mhdro));
segcmdo.cmd = Mach_segment_command::LC_SEGMENT;
segcmdo.cmdsize = sizeof(segcmdo);
strncpy((char *)&segcmdo.segname, "__TEXT", sizeof(segcmdo.segname));
segcmdo.vmaddr = PAGE_MASK & (~PAGE_MASK +
msegcmd[n_segment -1].vmsize + msegcmd[n_segment -1].vmaddr );
segcmdo.vmsize = 0; // adjust later
segcmdo.fileoff = 0;
segcmdo.filesize = 0; // adjust later
segcmdo.initprot = segcmdo.maxprot =
Mach_segment_command::VM_PROT_READ |
Mach_segment_command::VM_PROT_WRITE |
Mach_segment_command::VM_PROT_EXECUTE;
segcmdo.nsects = 0;
segcmdo.flags = 0;
fo->write(&segcmdo, sizeof(segcmdo));
threado.cmd = Mach_segment_command::LC_UNIXTHREAD;
threado.cmdsize = sizeof(threado);
threado.flavor = Mach_thread_command::PPC_THREAD_STATE;
threado.count = Mach_thread_command::PPC_THREAD_STATE_COUNT;
memset(&threado.state, 0, sizeof(threado.state));
fo->write(&threado, sizeof(threado));
sz_mach_headers = fo->getBytesWritten();
memset((char *)&linfo, 0, sizeof(linfo));
fo->write(&linfo, sizeof(linfo));
return;
}
void
PackMachPPC32::unpack(OutputFile *fo)
{
fi->seek(overlay_offset, SEEK_SET);
p_info hbuf;
fi->readx(&hbuf, sizeof(hbuf));
unsigned orig_file_size = get_native32(&hbuf.p_filesize);
blocksize = get_native32(&hbuf.p_blocksize);
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
throwCantUnpack("file header corrupted");
ibuf.alloc(blocksize + OVERHEAD);
b_info bhdr; memset(&bhdr, 0, sizeof(bhdr));
fi->readx(&bhdr, sizeof(bhdr));
ph.u_len = get_native32(&bhdr.sz_unc);
ph.c_len = get_native32(&bhdr.sz_cpr);
ph.filter_cto = bhdr.b_cto8;
// Uncompress Macho headers
fi->readx(ibuf, ph.c_len);
Mach_header *const mhdr = (Mach_header *)new upx_byte[ph.u_len];
decompress(ibuf, (upx_byte *)mhdr, false);
unsigned const ncmds = mhdr->ncmds;
msegcmd = new Mach_segment_command[ncmds];
unsigned char *ptr = (unsigned char *)(1+mhdr);
for (unsigned j= 0; j < ncmds; ++j) {
msegcmd[j] = *(Mach_segment_command *)ptr;
ptr += (unsigned) ((Mach_segment_command *)ptr)->cmdsize;
}
// Put LC_SEGMENT together at the beginning, ascending by .vmaddr.
qsort(msegcmd, ncmds, sizeof(*msegcmd), compare_segment_command);
n_segment = 0;
for (unsigned j= 0; j < ncmds; ++j) {
n_segment += (Mach_segment_command::LC_SEGMENT==msegcmd[j].cmd);
}
unsigned total_in = 0;
unsigned total_out = 0;
unsigned c_adler = upx_adler32(NULL, 0);
unsigned u_adler = upx_adler32(NULL, 0);
Mach_segment_command const *sc = (Mach_segment_command const *)(1+ mhdr);
unsigned k;
fi->seek(- (off_t)(sizeof(bhdr) + ph.c_len), SEEK_CUR);
for (
k = 0;
k < ncmds;
(++k), (sc = (Mach_segment_command const *)(sc->cmdsize + (char const *)sc))
) {
if (Mach_segment_command::LC_SEGMENT==sc->cmd
&& 0!=sc->filesize ) {
unsigned filesize = get_be32(&sc->filesize);
unpackExtent(filesize, fo, total_in, total_out, c_adler, u_adler, false, sizeof(bhdr));
}
}
for (unsigned j = 0; j < ncmds; ++j) {
unsigned const size = find_SEGMENT_gap(j);
if (size) {
unsigned const where = get_native32(&msegcmd[k].fileoff) +
get_native32(&msegcmd[k].filesize);
if (fo)
fo->seek(where, SEEK_SET);
unpackExtent(size, fo, total_in, total_out,
c_adler, u_adler, false, sizeof(bhdr));
}
}
}
bool
PackMachPPC32::canPack()
{
fi->seek(0, SEEK_SET);
fi->readx(&mhdri, sizeof(mhdri));
if (Mach_header::MH_MAGIC !=mhdri.magic
|| Mach_header::CPU_TYPE_POWERPC !=mhdri.cputype
|| Mach_header::MH_EXECUTE !=mhdri.filetype
)
return false;
rawmseg = (Mach_segment_command *)new char[mhdri.sizeofcmds];
fi->readx(rawmseg, mhdri.sizeofcmds);
msegcmd = new Mach_segment_command[mhdri.ncmds];
unsigned char *ptr = (unsigned char *)rawmseg;
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
msegcmd[j] = *(Mach_segment_command *)ptr;
ptr += (unsigned) ((Mach_segment_command *)ptr)->cmdsize;
}
// Put LC_SEGMENT together at the beginning, ascending by .vmaddr.
qsort(msegcmd, mhdri.ncmds, sizeof(*msegcmd), compare_segment_command);
// Check that LC_SEGMENTs form one contiguous chunk of the file.
for (unsigned j= 0; j < mhdri.ncmds; ++j) {
if (Mach_segment_command::LC_SEGMENT==msegcmd[j].cmd) {
if (0xfff & (msegcmd[j].fileoff | msegcmd[j].vmaddr)) {
return false;
}
if (0 < j) {
unsigned const sz = ~0xfff
& (0xfff + msegcmd[j-1].filesize);
if ((sz + msegcmd[j-1].fileoff)!=msegcmd[j].fileoff) {
return false;
}
}
++n_segment;
sz_segment = msegcmd[j].filesize + msegcmd[j].fileoff - msegcmd[0].fileoff;
}
}
// set options
opt->o_unix.blocksize = file_size;
return 0 < n_segment;
}
/*
vi:ts=4:et
*/
+214
View File
@@ -0,0 +1,214 @@
/* p_mach.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu
*/
#ifndef __UPX_P_MACHO_H
#define __UPX_P_MACHO_H
/*************************************************************************
// Mach Mach Object executable
**************************************************************************/
struct Mach_header {
BE32 magic;
enum {
MH_MAGIC = 0xfeedface
};
BE32 cputype;
enum {
CPU_TYPE_POWERPC = 18
};
BE32 cpysubtype;
BE32 filetype;
enum {
MH_EXECUTE = 2
};
BE32 ncmds;
BE32 sizeofcmds;
BE32 flags;
enum {
MH_NOUNDEFS = 1
};
}
__attribute_packed;
struct Mach_segment_command {
BE32 cmd;
enum {
LC_SEGMENT = 0x1,
LC_THREAD = 0x4,
LC_UNIXTHREAD = 0x5,
LC_LOAD_DYLINKER = 0xe
};
BE32 cmdsize;
char segname[16];
BE32 vmaddr;
BE32 vmsize;
BE32 fileoff;
BE32 filesize;
BE32 maxprot;
enum {
VM_PROT_READ = 1,
VM_PROT_WRITE = 2,
VM_PROT_EXECUTE = 4
};
BE32 initprot;
BE32 nsects;
BE32 flags;
}
__attribute_packed;
struct Mach_section {
char sectname[16];
char segname[16];
BE32 addr; /* memory address */
BE32 size; /* size in bytes */
BE32 offset; /* file offset */
BE32 align; /* power of 2 */
BE32 reloff; /* file offset of relocation entries */
BE32 nreloc; /* number of relocation entries */
BE32 flags; /* section type and attributes */
enum {
S_REGULAR = 0,
S_ZEROFILL,
S_CSTRING_LITERALS,
S_4BYTE_LITERALS,
S_8BYTE_LITERALS,
S_LITERAL_POINTERS,
S_NON_LAZY_SYMBOL_POINTERS,
S_LAZY_SYMBOL_POINTERS,
S_SYMBOL_STUBS,
S_MOD_INIT_FUNC_POINTERS,
S_MOD_TERM_FNC_POINTERS,
S_COALESCED
};
enum {
S_ATTR_PURE_INSTRUCTIONS = 0x80000000,
S_ATTR_NO_TOC = 0x40000000,
S_ATTR_STRIP_STATIC_SYMS = 0x20000000,
S_ATTR_SOME_INSTRUCTIONS = 0x00000400,
S_ATTR_EXT_RELOC = 0x00000200,
S_ATTR_LOC_RELOC = 0x00000100
};
BE32 reserved1;
BE32 reserved2;
}
__attribute_packed;
struct Mach_ppc_thread_state {
BE32 srr0; /* Instruction address register (PC; entry addr) */
BE32 srr1; /* Machine state register (supervisor) */
BE32 r0, r1, r2, r3, r4, r5, r6, r7;
BE32 r8, r9,r10,r11,r12,r13,r14,r15;
BE32 r16,r17,r18,r19,r20,r21,r22,r23;
BE32 r24,r25,r26,r27,r28,r29,r30,r31;
BE32 cr; /* Condition register */
BE32 xer; /* User's integer exception register */
BE32 lr; /* Link register */
BE32 ctr; /* Count register */
BE32 mq; /* MQ register (601 only) */
BE32 vrsave; /* Vector Save Register */
};
struct Mach_thread_command {
BE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
BE32 cmdsize; /* total size of this command */
BE32 flavor;
enum {
PPC_THREAD_STATE = 1
};
BE32 count; /* sizeof(following_thread_state)/4 */
enum {
PPC_THREAD_STATE_COUNT = sizeof(struct Mach_ppc_thread_state)/4
};
struct Mach_ppc_thread_state state;
}
__attribute_packed;
#include "p_unix.h"
class PackMachPPC32 : public PackUnixBe32
{
typedef PackUnixBe32 super;
public:
PackMachPPC32(InputFile *f);
virtual ~PackMachPPC32();
virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_MACH_PPC32; }
virtual const char *getName() const { return "Mach/ppc32"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;
// called by the generic pack()
virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual void pack2(OutputFile *, Filter &); // append compressed data
virtual void pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append PackHeader
virtual void unpack(OutputFile *fo);
virtual bool canPack();
virtual unsigned find_SEGMENT_gap(unsigned const k);
protected:
virtual int buildLoader(const Filter *ft);
virtual void patchLoader();
virtual void patchLoaderChecksum();
virtual void updateLoader(OutputFile *);
virtual int buildMachLoader(
upx_byte const *const proto,
unsigned const szproto,
upx_byte const *const fold,
unsigned const szfold,
Filter const *ft );
unsigned n_segment;
unsigned sz_segment;
unsigned sz_mach_headers;
Mach_segment_command *rawmseg; // as input, with sections
Mach_segment_command *msegcmd; // LC_SEGMENT first, without sections
Mach_header mhdri;
Mach_header mhdro;
Mach_segment_command segcmdo;
Mach_thread_command threado;
struct l_info linfo;
};
#endif /* already included */
/*
vi:ts=4:et
*/
+70 -42
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2004 Laszlo Molnar Copyright (C) 1996-2006 Laszlo Molnar
Copyright (C) 2002-2004 Jens Medoch Copyright (C) 2002-2006 Jens Medoch
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -49,6 +49,8 @@ static const
#define CD_SEC 2048 #define CD_SEC 2048
#define PS_HDR_SIZE CD_SEC #define PS_HDR_SIZE CD_SEC
#define PS_RAM_SIZE 0x200000
#define PS_MIN_SIZE (PS_HDR_SIZE*3)
#define PS_MAX_SIZE 0x1e8000 #define PS_MAX_SIZE 0x1e8000
#define SZ_IH_BKUP (10 * sizeof(LE32)) #define SZ_IH_BKUP (10 * sizeof(LE32))
@@ -75,17 +77,17 @@ static const
PackPs1::PackPs1(InputFile *f) : PackPs1::PackPs1(InputFile *f) :
super(f), super(f),
isCon(false^opt->ps1_exe.console_run), is32Bit(true^opt->ps1_exe.do_8bit), isCon(!opt->ps1_exe.boot_only), is32Bit(!opt->ps1_exe.do_8bit),
overlap(0), sa_cnt(0), cfile_size(0) overlap(0), sa_cnt(0)
{ {
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 188); COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 188);
COMPILE_TIME_ASSERT(PS_HDR_SIZE > sizeof(ps1_exe_t)); COMPILE_TIME_ASSERT(PS_HDR_SIZE > sizeof(ps1_exe_t));
COMPILE_TIME_ASSERT(SZ_IH_BKUP == 40); COMPILE_TIME_ASSERT(SZ_IH_BKUP == 40);
#if 1 || defined(WITH_NRV) #if 1 || defined(WITH_NRV)
COMPILE_TIME_ASSERT(sizeof(nrv_boot_loader) == 3918); COMPILE_TIME_ASSERT(sizeof(nrv_boot_loader) == 3935);
COMPILE_TIME_ASSERT(NRV_BOOT_LOADER_CRC32 == 0xb1939f02); COMPILE_TIME_ASSERT(NRV_BOOT_LOADER_CRC32 == 0x0ac25782);
COMPILE_TIME_ASSERT(sizeof(nrv_con_loader) == 2810); COMPILE_TIME_ASSERT(sizeof(nrv_con_loader) == 2829);
COMPILE_TIME_ASSERT(NRV_CON_LOADER_CRC32 == 0xaf39f37f); COMPILE_TIME_ASSERT(NRV_CON_LOADER_CRC32 == 0x923b55c4);
#endif #endif
fdata_size = file_size - PS_HDR_SIZE; fdata_size = file_size - PS_HDR_SIZE;
} }
@@ -127,23 +129,30 @@ int PackPs1::readFileHeader()
bool PackPs1::checkFileHeader() bool PackPs1::checkFileHeader()
{ {
if (fdata_size != ih.tx_len || (ih.tx_len & 3) && !opt->force ) if (fdata_size != ih.tx_len || (ih.tx_len & 3))
{ {
infoWarning("check header for file size"); if (!opt->force)
throwCantPack("file size entry damaged (try --force)");
else
{
opt->info_mode += !opt->info_mode ? 1 : 0;
infoWarning("fixing damaged header, keeping backup file");
opt->backup = 1;
ih.tx_len = fdata_size;
}
}
if (!opt->force &&
(ih.da_ptr != 0 || ih.da_len != 0 ||
ih.bs_ptr != 0 || ih.bs_len != 0))
{
infoWarning("unsupported header field entry");
return false; return false;
} }
cfile_size = fdata_size; if (!opt->force && ih.is_ptr == 0)
if (ih.da_ptr != 0 || ih.da_len != 0 ||
ih.bs_ptr != 0 || ih.bs_len != 0 && !opt->force)
{ {
infoWarning("stack pointer field empty");
return false; return false;
} }
if (ih.is_ptr == 0 && !opt->force)
{
infoWarning("check header for stack pointer");
return false;
}
cfile_size = ih.tx_len;
return true; return true;
} }
@@ -189,20 +198,30 @@ void PackPs1::patch_mips_le(void *b, int blen, const void *old, unsigned new_)
bool PackPs1::canPack() bool PackPs1::canPack()
{ {
unsigned char buf[PS_HDR_SIZE-HD_CODE_OFS];
if (!readFileHeader()) if (!readFileHeader())
return false; return false;
unsigned char buf[PS_HDR_SIZE-HD_CODE_OFS];
fi->readx(buf, sizeof(buf)); fi->readx(buf, sizeof(buf));
for (unsigned i = 0; i < sizeof(buf); i++)
if (buf[i] != 0 && !opt->force)
throwCantPack("unknown data in header (try --force)");
checkAlreadyPacked(buf, sizeof(buf)); checkAlreadyPacked(buf, sizeof(buf));
for (unsigned i = 0; i < sizeof(buf); i++)
if (buf[i] != 0)
if (!opt->force)
throwCantPack("unknown data in header (try --force)");
else
{
opt->info_mode += !opt->info_mode ? 1 : 0;
infoWarning("clearing header, keeping backup file");
opt->backup = 1;
break;
}
if (!checkFileHeader()) if (!checkFileHeader())
throwCantPack("unsupported header flags (try --force)"); throwCantPack("unsupported header flags (try --force)");
if (file_size <= (PS_HDR_SIZE*3) && !opt->force) if (!opt->force && file_size < PS_MIN_SIZE)
throwCantPack("file is too small (try --force)"); throwCantPack("file is too small (try --force)");
if (file_size > PS_MAX_SIZE && !opt->force) if (!opt->force && file_size > PS_MAX_SIZE)
throwCantPack("file is too big (try --force)"); throwCantPack("file is too big (try --force)");
return true; return true;
} }
@@ -223,8 +242,7 @@ int PackPs1::buildLoader(const Filter *)
isCon ? ph.c_len & 3 ? "PS1PADCD" : "" : "PS1ENTRY", isCon ? ph.c_len & 3 ? "PS1PADCD" : "" : "PS1ENTRY",
ih.tx_ptr & 0xffff ? "PS1CONHL" : "PS1CONHI", ih.tx_ptr & 0xffff ? "PS1CONHL" : "PS1CONHI",
isCon ? "PS1ENTRY" : "", isCon ? "PS1ENTRY" : "",
NULL NULL);
);
if (ph.method == M_NRV2B_8) if (ph.method == M_NRV2B_8)
addLoader("PS1N2B08", NULL); addLoader("PS1N2B08", NULL);
@@ -242,14 +260,14 @@ int PackPs1::buildLoader(const Filter *)
throwInternalError("unknown compression method"); throwInternalError("unknown compression method");
if (sa_cnt) if (sa_cnt)
addLoader(sa_cnt > 0xfffc ? "PS1MSETB" : "PS1MSETS", // set small/big memset addLoader(sa_cnt > (0x10000 << 2) ? "PS1MSETB" : "PS1MSETS",
ih.tx_len & 3 ? "PS1MSETU" : "PS1MSETA", // un/aligned memset ih.tx_len & 3 ? "PS1MSETU" : "PS1MSETA",
NULL NULL);
);
addLoader("PS1EXITC", "IDENTSTR", "PS1PAHDR", addLoader("PS1EXITC", "IDENTSTR", "PS1PAHDR",
isCon ? "PS1SREGS" : "", isCon ? "PS1SREGS" : "",
NULL NULL);
);
return getLoaderSize(); return getLoaderSize();
} }
@@ -262,7 +280,7 @@ void PackPs1::pack(OutputFile *fo)
{ {
ibuf.alloc(fdata_size); ibuf.alloc(fdata_size);
obuf.allocForCompression(fdata_size); obuf.allocForCompression(fdata_size);
const upx_byte *p_scan = ibuf+(fdata_size-1); const upx_byte *p_scan = ibuf+fdata_size;
// read file // read file
fi->seek(PS_HDR_SIZE,SEEK_SET); fi->seek(PS_HDR_SIZE,SEEK_SET);
@@ -270,10 +288,10 @@ void PackPs1::pack(OutputFile *fo)
// scan EOF for 2048 bytes sector alignment // scan EOF for 2048 bytes sector alignment
// the removed space will secure in-place decompression // the removed space will secure in-place decompression
while (!(*p_scan--)) { if (sa_cnt++ > (0xfffc<<3)) break; } while (!(*--p_scan)) { if (sa_cnt++ > (0x10000<<5) || sa_cnt >= fdata_size-1024) break; }
if (sa_cnt > 0xfffc) if (sa_cnt > (0x10000<<2))
sa_cnt = ALIGN_DOWN(sa_cnt,8); sa_cnt = ALIGN_DOWN(sa_cnt,32);
else else
sa_cnt = ALIGN_DOWN(sa_cnt,4); sa_cnt = ALIGN_DOWN(sa_cnt,4);
@@ -304,6 +322,14 @@ void PackPs1::pack(OutputFile *fo)
memcpy(&oh.ih_bkup, &ih.epc, SZ_IH_BKUP); memcpy(&oh.ih_bkup, &ih.epc, SZ_IH_BKUP);
oh.ih_csum = upx_adler32(&ih.epc, SZ_IH_BKUP); oh.ih_csum = upx_adler32(&ih.epc, SZ_IH_BKUP);
if (ih.is_ptr == 0)
oh.is_ptr = PS_RAM_SIZE-0x10;
if (ih.da_ptr != 0 || ih.da_len != 0 ||
ih.bs_ptr != 0 || ih.bs_len != 0)
oh.da_ptr = oh.da_len =
oh.bs_ptr = oh.bs_len = 0;
const int lsize = getLoaderSize(); const int lsize = getLoaderSize();
MemBuffer loader(lsize); MemBuffer loader(lsize);
memcpy(loader, getLoader(), lsize); memcpy(loader, getLoader(), lsize);
@@ -311,7 +337,7 @@ void PackPs1::pack(OutputFile *fo)
patchPackHeader(loader,lsize); patchPackHeader(loader,lsize);
unsigned pad = 0; unsigned pad = 0;
unsigned filelen = ALIGN_UP((cfile_size ? cfile_size : (unsigned) ih.tx_len), 4); unsigned filelen = ALIGN_UP(ih.tx_len, 4);
unsigned pad_code = TIL_ALIGNED(ph.c_len, 4); unsigned pad_code = TIL_ALIGNED(ph.c_len, 4);
const unsigned decomp_data_start = ih.tx_ptr; const unsigned decomp_data_start = ih.tx_ptr;
@@ -335,7 +361,8 @@ void PackPs1::pack(OutputFile *fo)
patch_mips_le(loader,c_len,"JPEP",MIPS_JP(ih.epc)); patch_mips_le(loader,c_len,"JPEP",MIPS_JP(ih.epc));
if (sa_cnt) if (sa_cnt)
patch_mips_le(loader,c_len,"SC",MIPS_LO(sa_cnt > 0xfffc ? sa_cnt >> 3 : sa_cnt)); patch_mips_le(loader,c_len,"SC",
MIPS_LO(sa_cnt > (0x10000 << 2) ? sa_cnt >> 5 : sa_cnt >> 2));
if (ih.tx_ptr & 0xffff) if (ih.tx_ptr & 0xffff)
patch_mips_le(loader,c_len,"DECO",decomp_data_start); patch_mips_le(loader,c_len,"DECO",decomp_data_start);
else else
@@ -401,6 +428,7 @@ void PackPs1::pack(OutputFile *fo)
throwNotCompressible(); throwNotCompressible();
#if 0 #if 0
printf("%-13s: uncompressed : %8ld bytes\n", getName(), (long) ph.u_len);
printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len); printf("%-13s: compressed : %8ld bytes\n", getName(), (long) ph.c_len);
printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) lsize - h_len); printf("%-13s: decompressor : %8ld bytes\n", getName(), (long) lsize - h_len);
printf("%-13s: code entry : %08X bytes\n", getName(), (unsigned int) oh.epc); printf("%-13s: code entry : %08X bytes\n", getName(), (unsigned int) oh.epc);
@@ -448,7 +476,7 @@ void PackPs1::unpack(OutputFile *fo)
assert(oh.tx_len >= ph.u_len); assert(oh.tx_len >= ph.u_len);
const unsigned pad = oh.tx_len - ph.u_len; const unsigned pad = oh.tx_len - ph.u_len;
ibuf.alloc(fdata_size); ibuf.alloc(fdata_size > PS_HDR_SIZE ? fdata_size : PS_HDR_SIZE);
obuf.allocForUncompression(ph.u_len, pad); obuf.allocForUncompression(ph.u_len, pad);
fi->seek(PS_HDR_SIZE, SEEK_SET); fi->seek(PS_HDR_SIZE, SEEK_SET);
@@ -466,7 +494,7 @@ void PackPs1::unpack(OutputFile *fo)
// write header // write header
fo->write(&oh, sizeof(oh)); fo->write(&oh, sizeof(oh));
// align the ps exe header (mode 2 sector data size) // align the ps exe header (mode 2 sector data size)
ibuf.clear(0, PS_HDR_SIZE - sizeof(oh)); ibuf.clear();
// write uncompressed data + pad // write uncompressed data + pad
fo->write(ibuf, PS_HDR_SIZE - sizeof(oh)); fo->write(ibuf, PS_HDR_SIZE - sizeof(oh));
obuf.clear(ph.u_len, pad); obuf.clear(ph.u_len, pad);
-2
View File
@@ -104,8 +104,6 @@ protected:
// filesize-PS_HDR_SIZE // filesize-PS_HDR_SIZE
unsigned fdata_size; unsigned fdata_size;
// calculated filesize
unsigned cfile_size;
}; };
+4 -4
View File
@@ -22,7 +22,7 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer Laszlo Molnar
markus@oberhumer.com ml1050@cdata.tvnet.hu markus@oberhumer.com ml1050@users.sourceforge.net
*/ */
@@ -107,12 +107,12 @@ int PackSys::buildLoader(const Filter *ft)
initLoader(nrv2b_loader,sizeof(nrv2b_loader)); initLoader(nrv2b_loader,sizeof(nrv2b_loader));
addLoader("SYSMAIN1", addLoader("SYSMAIN1",
opt->cpu == opt->CPU_8086 ? "SYSI0861" : "SYSI2861", opt->cpu == opt->CPU_8086 ? "SYSI0861" : "SYSI2861",
"SYSMAIN2""SYSSUBSI", "SYSMAIN2,SYSSUBSI",
ph.first_offset_found == 1 ? "SYSSBBBP" : "", ph.first_offset_found == 1 ? "SYSSBBBP" : "",
ft->id ? "SYSCALLT" : "", ft->id ? "SYSCALLT" : "",
"SYSMAIN3""UPX1HEAD""SYSCUTPO""NRV2B160""NRVDDONE""NRVDECO1", "SYSMAIN3,UPX1HEAD,SYSCUTPO,NRV2B160,NRVDDONE,NRVDECO1",
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00", ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
"NRVDECO2""NRV2B169", "NRVDECO2,NRV2B169",
NULL NULL
); );
if (ft->id) if (ft->id)

Some files were not shown because too many files have changed in this diff Show More