riboseinc / retrace

retrace is a versatile security vulnerability / bug discovery tool through monitoring and modifying the behavior of compiled binaries on Linux, OpenBSD/FreeBSD/NetBSD (shared object) and macOS (dynamic library).
Other
60 stars 19 forks source link

V2 isn't compiled on MacOS #344

Closed jjr840430 closed 6 years ago

jjr840430 commented 6 years ago

Here is the error while compiling v2 on MacOS.

devs-Mac-2:retrace_v2 dev$ make
gcc -fPIC -shared -o "retrace_v2.so"  ./x86-64/arch_spec_bottom.c ./x86-64/arch_spec_top.S  ./actions.c ./data_types.c ./engine.c ./funcs.c ./main.c ./parson.c ./real_impls.c -ldl
./x86-64/arch_spec_bottom.c:84:5: error: invalid operand for instruction
                                "pushq %%rax;"
                                ^
<inline asm>:1:1386: note: instantiated into assembly here
  ...%r11;_call_x86_64_systemv_ret_MoreParams:;movq (%r11), %rax;pushq (%rax);decq %r10;jz _call_x86_64_systemv_ret_ParamSetupDone;addq $8, %r11;jmp _call_x86_64_systemv_ret_MoreParams;_call_x86_64_systemv_ret_ParamSetupDone:;xorq %rax, %rax;callq %r14;movq %rax, (%r...
                                                                                                                                                                                                                                                        ^~~~~
1 error generated.
<instantiation>:6:3: error: unknown directive
  .type getenv_wrapper, @function
  ^
./x86-64/arch_spec_top.S:109:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V getenv
^
<instantiation>:7:3: error: unknown directive
  .type getenv, @function
  ^
./x86-64/arch_spec_top.S:109:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V getenv
^
<instantiation>:41:3: error: unknown use of instruction mnemonic without a size suffix
  call %rax
  ^
./x86-64/arch_spec_top.S:109:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V getenv
^
<instantiation>:6:3: error: unknown directive
  .type write_wrapper, @function
  ^
./x86-64/arch_spec_top.S:110:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V write
^
<instantiation>:7:3: error: unknown directive
  .type write, @function
  ^
./x86-64/arch_spec_top.S:110:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V write
^
<instantiation>:41:3: error: unknown use of instruction mnemonic without a size suffix
  call %rax
  ^
./x86-64/arch_spec_top.S:110:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V write
^
<instantiation>:6:3: error: unknown directive
  .type writev_wrapper, @function
  ^
./x86-64/arch_spec_top.S:111:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V writev
^
<instantiation>:7:3: error: unknown directive
  .type writev, @function
  ^
./x86-64/arch_spec_top.S:111:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V writev
^
<instantiation>:41:3: error: unknown use of instruction mnemonic without a size suffix
  call %rax
  ^
./x86-64/arch_spec_top.S:111:1: note: while in macro instantiation
WRAPPER_ENTRY_SYSTEM_V writev
^
./actions.c:236:26: error: no member named '__builtin___snprintf_chk' in 'RetraceRealImpls_t'
                retrace_real_impls.snprintf(deref_sz, sizeof(deref_sz),
                ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:57:3: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
1 error generated.
./data_types.c:207:25: error: no member named '__builtin___sprintf_chk' in 'RetraceRealImpls_t'
        retrace_real_impls.sprintf(str, "%s", serialized_string);
        ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:47:3: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:288:28: error: no member named '__builtin___sprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.sprintf(str, "%d", *((const int*) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:47:3: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:294:28: error: no member named '__builtin___snprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.snprintf(NULL, 0, "%d", *((const int*) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:57:3: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:318:21: error: no member named '__builtin___strcpy_chk' in 'RetraceRealImpls_t'
        retrace_real_impls.strcpy(str, (const char*) data);
        ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_string.h:83:3: note: expanded from macro 'strcpy'
                __builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
./data_types.c:348:28: error: no member named '__builtin___sprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.sprintf(str, "0x%02x", *((const char*) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:47:3: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:354:28: error: no member named '__builtin___snprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.snprintf(NULL, 0, "0x%02x", *((const char*) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:57:3: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:377:28: error: no member named '__builtin___sprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.sprintf(str, "%zu", *((const size_t*) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:47:3: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:383:28: error: no member named '__builtin___snprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.snprintf(NULL, 0, "%zu", *((const size_t*) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:57:3: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:407:28: error: no member named '__builtin___sprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.sprintf(str, "%p", *((void **) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:47:3: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
./data_types.c:413:28: error: no member named '__builtin___snprintf_chk' in 'RetraceRealImpls_t'
        return retrace_real_impls.snprintf(NULL, 0, "%p", *((void **) data));
               ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:57:3: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
  ^
10 errors generated.
./engine.c:274:28: error: no member named '__builtin___memset_chk' in 'RetraceRealImpls_t'
        retrace_real_impls.memset(thread_ctx, 0, sizeof(*thread_ctx));
        ~~~~~~~~~~~~~~~~~~ ^
/usr/include/secure/_string.h:76:3: note: expanded from macro 'memset'
                __builtin___memset_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
                ^
./engine.c:386:5: warning: format specifies type 'unsigned long' but the argument has type 'pthread_t _Nonnull' (aka 'struct _opaque_pthread_t *') [-Wformat]
                                pthread_self());
                                ^~~~~~~~~~~~~~
./engine.c:38:66: note: expanded from macro 'retrace_engine_info'
#define retrace_engine_info(fmt, ...) printf("[INFO] " fmt "\n", __VA_ARGS__)
ghost commented 6 years ago

Guys, I have very limited capabilities porting/adapting v2 on Mac. Currently there is no Mac machine that i posses. I could possibly install a hackintosh on my PC but it would require a huge amount of efforts that I prefer to put in a more urgent stuff like implementing scripting support

ronaldtse commented 6 years ago

@jjr840430 @ikolomi is this fixed now? Thanks.

ghost commented 6 years ago

I had provided and tested 3 makefiles for each platforms linux mac and bsd. Id ask you guys to integrate it into the build script of the original retrace...

On Sat, Mar 10, 2018, 19:16 Ronald Tse notifications@github.com wrote:

@jjr840430 https://github.com/jjr840430 @ikolomi https://github.com/ikolomi is this fixed now? Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/riboseinc/retrace/issues/344#issuecomment-372046090, or mute the thread https://github.com/notifications/unsubscribe-auth/AfMHW3yhL0Ch7hWzqkPCfut82nZohEsdks5tdAqGgaJpZM4RoU-J .

ghost commented 6 years ago

@jjr840430 I think we can close this issue