mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Fixes for gcc 3.4 (-funit-at-a-time). Reduced size of stubs a little bit.
committer: mfx <mfx> 1084323518 +0000
This commit is contained in:
parent
55cde23f10
commit
7ce85ab712
|
@ -100,13 +100,12 @@ CC_LINUX_I386_GCC295 += -Os -fno-omit-frame-pointer
|
|||
CC_LINUX_I386_GCC295 += -malign-functions=0 -malign-jumps=0 -malign-loops=0
|
||||
CC_LINUX_I386_GCC295 += -Werror
|
||||
|
||||
# gcc 3.4.0 (fold_*.bin: 1541 / 931 / 1236)
|
||||
# gcc 3.4.0 (fold_*.bin: 1482 / 931 / 1173)
|
||||
CC_LINUX_I386_GCC340 = gcc-3.4 -march=i386 -mtune=k6 -fno-exceptions
|
||||
CC_LINUX_I386_GCC340 += -Os -fno-omit-frame-pointer
|
||||
CC_LINUX_I386_GCC340 += -momit-leaf-frame-pointer
|
||||
CC_LINUX_I386_GCC340 += -fno-align-functions -fno-align-jumps -fno-align-labels -fno-align-loops
|
||||
##CC_LINUX_I386_GCC340 += -fweb
|
||||
CC_LINUX_I386_GCC340 += -fno-unit-at-a-time
|
||||
CC_LINUX_I386_GCC340 += -Werror
|
||||
|
||||
CC_LINUX_I386 = $(CC_LINUX_I386_GCC272)
|
||||
|
|
|
@ -55,6 +55,9 @@ struct Extent {
|
|||
|
||||
|
||||
static void
|
||||
#if (ACC_CC_GNUC >= 0x030300)
|
||||
__attribute__((__noinline__, __used__, regparm(3), stdcall))
|
||||
#endif
|
||||
xread(struct Extent *x, char *buf, size_t count)
|
||||
{
|
||||
char *p=x->buf, *q=buf;
|
||||
|
@ -94,7 +97,7 @@ do_brk(void *addr)
|
|||
}
|
||||
|
||||
static char *
|
||||
__attribute__((cdecl))
|
||||
__attribute_cdecl
|
||||
do_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
(void)len; (void)prot; (void)flags; (void)fd; (void)offset;
|
||||
|
@ -177,7 +180,7 @@ ERR_LAB
|
|||
|
||||
// Create (or find) an escape hatch to use when munmapping ourselves the stub.
|
||||
// Called by do_xmap to create it, and by assembler code to find it.
|
||||
void *
|
||||
static void *
|
||||
make_hatch(Elf32_Phdr const *const phdr)
|
||||
{
|
||||
unsigned *hatch = 0;
|
||||
|
|
|
@ -128,7 +128,7 @@ static uint32_t ascii5(char *p, uint32_t v, unsigned n)
|
|||
|
||||
|
||||
static char *
|
||||
__attribute__((cdecl))
|
||||
__attribute_cdecl
|
||||
do_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
(void)len; (void)prot; (void)flags; (void)fd; (void)offset;
|
||||
|
@ -158,6 +158,9 @@ do_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
|||
// which causes too many offsets to expand from 1 byte to 4.
|
||||
|
||||
static int
|
||||
#if (ACC_CC_GNUC >= 0x030300)
|
||||
__attribute__((__noinline__, __used__, __stdcall__))
|
||||
#endif
|
||||
go_self(char const *tmpname, char *argv[], char *envp[])
|
||||
{
|
||||
// Old FreeBSD does not have /proc/self, so use /proc/<pid> instead.
|
||||
|
@ -198,6 +201,7 @@ go_self(char const *tmpname, char *argv[], char *envp[])
|
|||
return fdi;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// UPX & NRV stuff
|
||||
**************************************************************************/
|
||||
|
|
|
@ -112,7 +112,7 @@ do_brk(void *addr)
|
|||
}
|
||||
|
||||
static char *
|
||||
__attribute__((cdecl))
|
||||
__attribute_cdecl
|
||||
do_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
(void)len; (void)prot; (void)flags; (void)fd; (void)offset;
|
||||
|
@ -196,7 +196,7 @@ ERR_LAB
|
|||
|
||||
// Create (or find) an escape hatch to use when munmapping ourselves the stub.
|
||||
// Called by do_xmap to create it, and by assembler code to find it.
|
||||
void *
|
||||
static void *
|
||||
make_hatch(Elf32_Phdr const *const phdr)
|
||||
{
|
||||
if (phdr->p_type==PT_LOAD && phdr->p_flags & PF_X) {
|
||||
|
|
|
@ -94,7 +94,7 @@ do_brk(void *addr)
|
|||
}
|
||||
|
||||
static char *
|
||||
__attribute__((cdecl))
|
||||
__attribute_cdecl
|
||||
do_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
(void)len; (void)prot; (void)flags; (void)fd; (void)offset;
|
||||
|
@ -251,7 +251,7 @@ ERR_LAB
|
|||
}
|
||||
|
||||
|
||||
Elf32_Addr // entry address
|
||||
static Elf32_Addr // entry address
|
||||
getexec(char const *const fname, Elf32_Ehdr *const ehdr, Elf32_auxv_t *const av)
|
||||
{
|
||||
int const fdi = open(fname, O_RDONLY, 0);
|
||||
|
|
|
@ -470,6 +470,25 @@ struct p_info // 12-byte packed program header follows stub loader
|
|||
((type) ((uintptr_t) (var)))
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# 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
|
||||
#endif
|
||||
|
||||
#if (ACC_CC_GNUC >= 0x030300)
|
||||
# define __attribute_cdecl __attribute__((__cdecl__, __used__))
|
||||
#elif (ACC_CC_GNUC >= 0x020700)
|
||||
# define __attribute_cdecl __attribute__((__cdecl__))
|
||||
#else
|
||||
# define __attribute_cdecl
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
vi:ts=4:et:nowrap
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user