fixed gcc/fpic issue for x86 in syscall macros
This commit is contained in:
parent
cb34385ded
commit
4c2df3b4dd
@ -381,29 +381,29 @@ typedef DIR qse_dir_t;
|
|||||||
#define QSE_SYSCALL0(ret,num) \
|
#define QSE_SYSCALL0(ret,num) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"movq %1, %%rax\n\t" \
|
"movq %1, %%rax\n\t" \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=&a"(ret): \
|
: "=&a"(ret) \
|
||||||
"g"((qse_uint64_t)num): \
|
: "g"((qse_uint64_t)num) \
|
||||||
"%rcx", "%r11")
|
: "%rcx", "%r11")
|
||||||
|
|
||||||
#define QSE_SYSCALL1(ret,num,arg1) \
|
#define QSE_SYSCALL1(ret,num,arg1) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"movq %1, %%rax\n\t" \
|
"movq %1, %%rax\n\t" \
|
||||||
"movq %2, %%rdi\n\t" \
|
"movq %2, %%rdi\n\t" \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=&a"(ret): \
|
: "=&a"(ret) \
|
||||||
"g"((qse_uint64_t)num), "g"((qse_uint64_t)arg1): \
|
: "g"((qse_uint64_t)num), "g"((qse_uint64_t)arg1) \
|
||||||
"%rdi", "%rcx", "%r11")
|
: "%rdi", "%rcx", "%r11")
|
||||||
|
|
||||||
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"movq %1, %%rax\n\t" \
|
"movq %1, %%rax\n\t" \
|
||||||
"movq %2, %%rdi\n\t" \
|
"movq %2, %%rdi\n\t" \
|
||||||
"movq %3, %%rsi\n\t" \
|
"movq %3, %%rsi\n\t" \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=&a"(ret): \
|
: "=&a"(ret) \
|
||||||
"g"((qse_uint64_t)num), "g"((qse_uint64_t)arg1), "g"((qse_uint64_t)arg2): \
|
: "g"((qse_uint64_t)num), "g"((qse_uint64_t)arg1), "g"((qse_uint64_t)arg2) \
|
||||||
"%rdi", "%rsi", "%rcx", "%r11")
|
: "%rdi", "%rsi", "%rcx", "%r11")
|
||||||
|
|
||||||
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
@ -411,39 +411,39 @@ typedef DIR qse_dir_t;
|
|||||||
"movq %2, %%rdi\n\t" \
|
"movq %2, %%rdi\n\t" \
|
||||||
"movq %3, %%rsi\n\t" \
|
"movq %3, %%rsi\n\t" \
|
||||||
"movq %4, %%rdx\n\t" \
|
"movq %4, %%rdx\n\t" \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=&a"(ret): \
|
: "=&a"(ret) \
|
||||||
"g"((qse_uint64_t)num), "g"((qse_uint64_t)arg1), "g"((qse_uint64_t)arg2), "g"((qse_uint64_t)arg3): \
|
: "g"((qse_uint64_t)num), "g"((qse_uint64_t)arg1), "g"((qse_uint64_t)arg2), "g"((qse_uint64_t)arg3) \
|
||||||
"%rdi", "%rsi", "%rdx", "%rcx", "%r11")
|
: "%rdi", "%rsi", "%rdx", "%rcx", "%r11")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define QSE_SYSCALL0(ret,num) \
|
#define QSE_SYSCALL0(ret,num) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint64_t)num) : \
|
:"a"((qse_uint64_t)num) \
|
||||||
"%rcx", "%r11")
|
: "%rcx", "%r11")
|
||||||
|
|
||||||
#define QSE_SYSCALL1(ret,num,arg1) \
|
#define QSE_SYSCALL1(ret,num,arg1) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint64_t)num), "D"((qse_uint64_t)arg1): \
|
: "a"((qse_uint64_t)num), "D"((qse_uint64_t)arg1) \
|
||||||
"%rcx", "%r11")
|
: "%rcx", "%r11")
|
||||||
|
|
||||||
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint64_t)num), "D"((qse_uint64_t)arg1), "S"((qse_uint64_t)arg2): \
|
: "a"((qse_uint64_t)num), "D"((qse_uint64_t)arg1), "S"((qse_uint64_t)arg2) \
|
||||||
"%rcx", "%r11")
|
: "%rcx", "%r11")
|
||||||
|
|
||||||
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"syscall\n": \
|
"syscall\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint64_t)num), "D"((qse_uint64_t)arg1), "S"((qse_uint64_t)arg2), "d"((qse_uint64_t)arg3): \
|
: "a"((qse_uint64_t)num), "D"((qse_uint64_t)arg1), "S"((qse_uint64_t)arg2), "d"((qse_uint64_t)arg3) \
|
||||||
"%rcx", "%r11")
|
: "%rcx", "%r11")
|
||||||
|
|
||||||
#elif defined(__linux) && defined(__GNUC__) && defined(__i386)
|
#elif defined(__linux) && defined(__GNUC__) && defined(__i386)
|
||||||
|
|
||||||
@ -451,27 +451,65 @@ typedef DIR qse_dir_t;
|
|||||||
|
|
||||||
#define QSE_SYSCALL0(ret,num) \
|
#define QSE_SYSCALL0(ret,num) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"int $0x80\n": \
|
"int $0x80\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint32_t)num))
|
: "a"((qse_uint32_t)num) \
|
||||||
|
: "memory")
|
||||||
|
|
||||||
|
/*
|
||||||
#define QSE_SYSCALL1(ret,num,arg1) \
|
#define QSE_SYSCALL1(ret,num,arg1) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"int $0x80\n": \
|
"int $0x80\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint32_t)num), "b"((qse_uint32_t)arg1))
|
: "a"((qse_uint32_t)num), "b"((qse_uint32_t)arg1))
|
||||||
|
|
||||||
|
GCC in x86 PIC mode uses ebx to store the GOT table. so the macro shouldn't
|
||||||
|
clobber the ebx register. this modified version stores ebx before interrupt
|
||||||
|
and restores it after interrupt.
|
||||||
|
*/
|
||||||
|
#define QSE_SYSCALL1(ret,num,arg1) \
|
||||||
|
__asm__ volatile ( \
|
||||||
|
"push %%ebx\n" \
|
||||||
|
"movl %2, %%ebx\n" \
|
||||||
|
"int $0x80\n" \
|
||||||
|
"pop %%ebx\n" \
|
||||||
|
: "=a"(ret) \
|
||||||
|
: "a"((qse_uint32_t)num), "r"((qse_uint32_t)arg1) \
|
||||||
|
: "memory")
|
||||||
|
|
||||||
|
/*
|
||||||
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"int $0x80\n": \
|
"int $0x80\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint32_t)num), "b"((qse_uint32_t)arg1), "c"((qse_uint32_t)arg2))
|
: "a"((qse_uint32_t)num), "b"((qse_uint32_t)arg1), "c"((qse_uint32_t)arg2))
|
||||||
|
*/
|
||||||
|
#define QSE_SYSCALL2(ret,num,arg1,arg2) \
|
||||||
|
__asm__ volatile ( \
|
||||||
|
"push %%ebx\n" \
|
||||||
|
"movl %2, %%ebx\n" \
|
||||||
|
"int $0x80\n" \
|
||||||
|
"pop %%ebx\n" \
|
||||||
|
: "=a"(ret) \
|
||||||
|
: "a"((qse_uint32_t)num), "r"((qse_uint32_t)arg1), "c"((qse_uint32_t)arg2) \
|
||||||
|
: "memory")
|
||||||
|
|
||||||
|
/*
|
||||||
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
||||||
__asm__ volatile ( \
|
__asm__ volatile ( \
|
||||||
"int $0x80\n": \
|
"int $0x80\n" \
|
||||||
"=a"(ret): \
|
: "=a"(ret) \
|
||||||
"a"((qse_uint32_t)num), "b"((qse_uint32_t)arg1), "c"((qse_uint32_t)arg2), "d"((qse_uint32_t)arg3))
|
: "a"((qse_uint32_t)num), "b"((qse_uint32_t)arg1), "c"((qse_uint32_t)arg2), "d"((qse_uint32_t)arg3))
|
||||||
|
*/
|
||||||
|
#define QSE_SYSCALL3(ret,num,arg1,arg2,arg3) \
|
||||||
|
__asm__ volatile ( \
|
||||||
|
"push %%ebx\n" \
|
||||||
|
"movl %2, %%ebx\n" \
|
||||||
|
"int $0x80\n" \
|
||||||
|
"pop %%ebx\n" \
|
||||||
|
: "=a"(ret) \
|
||||||
|
: "a"((qse_uint32_t)num), "r"((qse_uint32_t)arg1), "c"((qse_uint32_t)arg2), "d"((qse_uint32_t)arg3) \
|
||||||
|
: "memory")
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
# include <sys/epoll.h>
|
# include <sys/epoll.h>
|
||||||
# endif
|
# endif
|
||||||
# if defined(__linux__)
|
# if defined(__linux__)
|
||||||
|
# include <limits.h>
|
||||||
# include <linux/netfilter_ipv4.h> /* SO_ORIGINAL_DST */
|
# include <linux/netfilter_ipv4.h> /* SO_ORIGINAL_DST */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@ -1737,27 +1738,35 @@ oops:
|
|||||||
static int peek_request (
|
static int peek_request (
|
||||||
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req)
|
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (QSE_MEMCMP (&client->local_addr, &client->orgdst_addr, sizeof(client->orgdst_addr)) == 0)
|
if (QSE_MEMCMP (&client->local_addr, &client->orgdst_addr, sizeof(client->orgdst_addr)) == 0)
|
||||||
{
|
{
|
||||||
|
*/
|
||||||
return process_request (httpd, client, req, 1);
|
return process_request (httpd, client, req, 1);
|
||||||
|
/*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return proxy_request (httpd, client, req, 1);
|
return proxy_request (httpd, client, req, 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_request (
|
static int handle_request (
|
||||||
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req)
|
qse_httpd_t* httpd, qse_httpd_client_t* client, qse_htre_t* req)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (QSE_MEMCMP (&client->local_addr, &client->orgdst_addr, sizeof(client->orgdst_addr)) == 0)
|
if (QSE_MEMCMP (&client->local_addr, &client->orgdst_addr, sizeof(client->orgdst_addr)) == 0)
|
||||||
{
|
{
|
||||||
|
*/
|
||||||
return process_request (httpd, client, req, 0);
|
return process_request (httpd, client, req, 0);
|
||||||
|
/*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return proxy_request (httpd, client, req, 0);
|
return proxy_request (httpd, client, req, 0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static qse_httpd_scb_t httpd_system_callbacks =
|
static qse_httpd_scb_t httpd_system_callbacks =
|
||||||
|
Loading…
Reference in New Issue
Block a user