lccnet 리녹스 포팅 중의 에러
글쓴이: hys545 / 작성시간: 일, 2004/10/17 - 10:48오후
#include <stdlib.h> #include <stddef.h> #include <string.h> #include <stdio.h> #ifdef _WIN32 #include <windows.h> #endif #ifndef EXPORT #define EXPORT #endif static char rcsid[] = "$Id: thunks.c#5 2002/08/30 14:24:46 REDMOND\\drh $"; struct thunk { struct thunk *link; void (*entrypoint)(); unsigned char code[16]; }; static struct thunk *thunktable[237]; #define HASH(f) ((int)(((unsigned)f)>>2)%(sizeof thunktable/sizeof thunktable[0])) static void *newthunk(void (*f)(), void *thunkcode, size_t size, size_t offset) { int i = HASH(f); struct thunk *tp = malloc(sizeof *tp); if (tp == NULL) return NULL; /* cause an exception when dereferenced */ tp->link = thunktable[i]; thunktable[i] = tp; tp->entrypoint = f; memcpy(tp->code, thunkcode, size); *(int *)(tp->code + offset) = (char *)f - (tp->code + offset + 4); return tp->code; } #define NOP 0x90 EXPORT void *__getUMThunk(void (*f)()) { static struct thunkcode { /* must be <= 16 bytes */ unsigned char code[12]; int offset; } thunkcode = { NOP, NOP, NOP, 0x8B, 0x4C, 0x24, 0x04, /* mov ecx,DWORD PTR [esp+4] */ 0x8B, 0x54, 0x24, 0x08, /* mov edx,DWORD PTR [esp+8] */ 0xE9, /* jmp rel32 */ 0 }; int i = HASH(f); struct thunk *tp = thunktable[i]; for ( ; tp != NULL; tp = tp->link) if (tp->entrypoint == f) return tp->code; return newthunk(f, &thunkcode, sizeof thunkcode, offsetof(struct thunkcode,offset)); } EXPORT void *__getMUThunk(void (*f)()) { static struct thunkcode { /* must be <= 16 bytes */ unsigned char code[4]; int offset; unsigned char retcode[4]; } thunkcode = { NOP, 0x52, /* push edx */ 0x51, /* push ecx */ 0xE8, /* call rel32 */ 0, 0x83, 0xC4, 0x08, /* add esp,8 */ 0xC3 /* ret */ }; int i = HASH(f); struct thunk *tp = thunktable[i]; for ( ; tp != NULL; tp = tp->link) if (tp->entrypoint == f) return tp->code; return newthunk(f, &thunkcode, sizeof thunkcode, offsetof(struct thunkcode,offset)); }
cc -c -o/home/hys545/tmp/build/thunks.o lib/thunks.c
lib/thunks.c: In function `newthunk':
lib/thunks.c:33: error: invalid operands to binary -
make: *** [/home/hys545/tmp/build/thunks.o] 오류 1
이런 에러가 나는데 이거 어떻게 고쳐야 하는지 궁금
Forums:
Re: lccnet 리녹스 포팅 중의 에러
Re: lccnet 리녹스 포팅 중의 에러
즐린
저는 프로그램의 의도를 알 수 없고, 문제가 되는 코드는 정의되지 않은
저는 프로그램의 의도를 알 수 없고, 문제가 되는 코드는 정의되지 않은 결과를
보이므로 어떻게 하라고 말씀드리기는 힘듭니다.
이렇게 하면 컴파일이야 되겠지만 결과를 보장하지는 못합니다. 함수 포인터 f를
대상체 포인터로 변환하는 결과는 정의되지 않기 때문입니다. 특정 환경에서
결과를 보장한다면 다른 문제이겠습니다만.
이거 원래 lcc.net에 있던 겁니다원래 윈도우 용인데리녹스로
이거 원래 lcc.net에 있던 겁니다
원래 윈도우 용인데
리녹스로 포팅작업중입니다
lcc를 참고해서 하는중인데.
[url=http://my.dreamwiz.com/hys545/lccnet-4.2.zip ]http://my.dreamwiz.com/hys545/lccnet-4.2.zip [/url]
이게 원본인데
분석해주시면 ㄳ
즐린
댓글 달기