mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
tail order the args for better compressability;
special syscall1m for mmap because Z0 and Z1 don't work there. committer: jreiser <jreiser> 958847154 +0000
This commit is contained in:
parent
7854a924c7
commit
1c24a96864
|
@ -132,12 +132,12 @@ type name(type1 arg1) \
|
||||||
long __res; \
|
long __res; \
|
||||||
if (Z1(__NR_##name)) { \
|
if (Z1(__NR_##name)) { \
|
||||||
if (Z0(arg1)) { \
|
if (Z0(arg1)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; xorl %%ebx,%%ebx; int $0x80" \
|
__asm__ __volatile__ ("xorl %%ebx,%%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name) \
|
: "g" (__NR_##name) \
|
||||||
: "ebx"); \
|
: "ebx"); \
|
||||||
} else if (Z1(arg1)) { \
|
} else if (Z1(arg1)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; push %2; popl %%ebx; int $0x80" \
|
__asm__ __volatile__ ("push %2; popl %%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name),"g" ((long)(arg1)) \
|
: "g" (__NR_##name),"g" ((long)(arg1)) \
|
||||||
: "ebx"); \
|
: "ebx"); \
|
||||||
|
@ -154,33 +154,44 @@ type name(type1 arg1) \
|
||||||
return (type) __res; \
|
return (type) __res; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special for mmap; somehow Z0(arg1) and Z1(arg1) don't work
|
||||||
|
#define _syscall1m(type,name,type1,arg1) \
|
||||||
|
type name(type1 arg1) \
|
||||||
|
{ \
|
||||||
|
long __res; \
|
||||||
|
__asm__ __volatile__ ("push %1; popl %0; int $0x80" \
|
||||||
|
: "=a" (__res) \
|
||||||
|
: "g" (__NR_##name),"b" ((long)(arg1))); \
|
||||||
|
return (type) __res; \
|
||||||
|
}
|
||||||
|
|
||||||
#define _syscall2(type,name,type1,arg1,type2,arg2) \
|
#define _syscall2(type,name,type1,arg1,type2,arg2) \
|
||||||
type name(type1 arg1,type2 arg2) \
|
type name(type1 arg1,type2 arg2) \
|
||||||
{ \
|
{ \
|
||||||
long __res; \
|
long __res; \
|
||||||
if (Z1(__NR_##name)) { \
|
if (Z1(__NR_##name)) { \
|
||||||
if (Z0(arg1) && Z0(arg2)) { \
|
if (Z0(arg1) && Z0(arg2)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; xorl %%ebx,%%ebx; xorl %%ecx,%%ecx; int $0x80" \
|
__asm__ __volatile__ ("xorl %%ecx,%%ecx; xorl %%ebx,%%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name) \
|
: "g" (__NR_##name) \
|
||||||
: "ebx", "ecx"); \
|
: "ebx", "ecx"); \
|
||||||
} else if (Z0(arg1) && Z1(arg2)) { \
|
} else if (Z0(arg1) && Z1(arg2)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; xorl %%ebx,%%ebx; push %2; popl %%ecx; int $0x80" \
|
__asm__ __volatile__ ("push %2; popl %%ecx; xorl %%ebx,%%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name),"g" ((long)(arg2)) \
|
: "g" (__NR_##name),"g" ((long)(arg2)) \
|
||||||
: "ebx", "ecx"); \
|
: "ebx", "ecx"); \
|
||||||
} else if (Z1(arg1) && Z0(arg2)) { \
|
} else if (Z1(arg1) && Z0(arg2)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; push %2; popl %%ebx; xorl %%ecx,%%ecx; int $0x80" \
|
__asm__ __volatile__ ("xorl %%ecx,%%ecx; push %2; popl %%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name),"g" ((long)(arg1)) \
|
: "g" (__NR_##name),"g" ((long)(arg1)) \
|
||||||
: "ebx", "ecx"); \
|
: "ebx", "ecx"); \
|
||||||
} else if (Z1(arg1) && Z1(arg2)) { \
|
} else if (Z1(arg1) && Z1(arg2)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; push %2; popl %%ebx; push %3; popl %%ecx; int $0x80" \
|
__asm__ __volatile__ ("push %3; popl %%ecx; push %2; popl %%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name),"g" ((long)(arg1)),"g" ((long)(arg2)) \
|
: "g" (__NR_##name),"g" ((long)(arg1)),"g" ((long)(arg2)) \
|
||||||
: "ebx", "ecx"); \
|
: "ebx", "ecx"); \
|
||||||
} else if (Z0(arg1)) { \
|
} else if (Z0(arg1)) { \
|
||||||
__asm__ __volatile__ ("push %1; popl %0; xorl %%ebx,%%ebx; int $0x80" \
|
__asm__ __volatile__ ("xorl %%ebx,%%ebx; push %1; popl %0; int $0x80" \
|
||||||
: "=a" (__res) \
|
: "=a" (__res) \
|
||||||
: "g" (__NR_##name),"c" ((long)(arg2)) \
|
: "g" (__NR_##name),"c" ((long)(arg2)) \
|
||||||
: "ebx"); \
|
: "ebx"); \
|
||||||
|
@ -253,7 +264,7 @@ static inline _syscall0(pid_t,getpid)
|
||||||
static inline _syscall2(int,getrusage,int,who,struct rusage *,usage);
|
static inline _syscall2(int,getrusage,int,who,struct rusage *,usage);
|
||||||
static inline _syscall2(int,gettimeofday,struct timeval *,tv,void *,tz)
|
static inline _syscall2(int,gettimeofday,struct timeval *,tv,void *,tz)
|
||||||
static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,whence)
|
static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,whence)
|
||||||
static inline _syscall1(caddr_t,mmap,const int *,args)
|
static inline _syscall1m(caddr_t,mmap,const int *,args)
|
||||||
static inline _syscall3(int,mprotect,void *,addr,size_t,len,int,prot)
|
static inline _syscall3(int,mprotect,void *,addr,size_t,len,int,prot)
|
||||||
static inline _syscall3(int,msync,const void *,start,size_t,length,int,flags)
|
static inline _syscall3(int,msync,const void *,start,size_t,length,int,flags)
|
||||||
static inline _syscall2(int,munmap,void *,start,size_t,length)
|
static inline _syscall2(int,munmap,void *,start,size_t,length)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user