Example #1
0
def main():
  OPTIONS.parse_configure_file()

  functions = []
  for function in wrapped_functions.get_wrapped_functions():
    functions.append('  { "%s", reinterpret_cast<void*>(%s) },' %
                     (function, function))
  sys.stdout.write(_WRAPPED_FUNCTIONS_CC_TEMPLATE.substitute({
      'WRAPPED_FUNCTIONS': '\n'.join(functions)
  }))
def main():
    OPTIONS.parse_configure_file()

    print "// Auto-generated file - DO NOT EDIT!"
    print "// THIS FILE SHOULD BE USED FOR UNIT TESTS ONLY."
    print

    for name in wrapped_functions.get_wrapped_functions():
        print ".globl __real_%s" % name
        print ".type __real_%s, function" % name

    print "#if defined(__x86_64__) || defined(__i386__)"
    for name in wrapped_functions.get_wrapped_functions():
        print "__real_%s: jmp %s@PLT" % (name, name)

    print "#elif defined(__arm__)"
    for name in wrapped_functions.get_wrapped_functions():
        print "__real_%s: b %s@PLT" % (name, name)

    print "#else"
    print '#error "Unsupported architecture"'
    print "#endif"
Example #3
0
def main():
    OPTIONS.parse_configure_file()

    print '// Auto-generated file - DO NOT EDIT!'
    print '// THIS FILE SHOULD BE USED FOR UNIT TESTS ONLY.'
    print

    for name in wrapped_functions.get_wrapped_functions():
        print '.globl __real_%s' % name
        print '.type __real_%s, function' % name

    print '#if defined(__x86_64__) || defined(__i386__)'
    for name in wrapped_functions.get_wrapped_functions():
        print '__real_%s: jmp %s@PLT' % (name, name)

    print '#elif defined(__arm__)'
    for name in wrapped_functions.get_wrapped_functions():
        print '__real_%s: b %s@PLT' % (name, name)

    print '#else'
    print '#error "Unsupported architecture"'
    print '#endif'
def main():
  OPTIONS.parse_configure_file()
  print '''// Auto-generated file - DO NOT EDIT!
// THIS FILE SHOULD BE USED FOR UNIT TESTS ONLY.

#if defined(__native_client__) && defined(__i386__)
.type get_pc_thunk_cx, function
get_pc_thunk_cx:
    popl %ecx
    nacljmp %ecx
#endif

.macro trampoline_to_original_libc_call function
#if defined(__native_client__)
    #if defined(__i386__)
    call get_pc_thunk_cx
    addl $_GLOBAL_OFFSET_TABLE_, %ecx
    movl \\function@GOT(%ecx), %ecx
    nacljmp %ecx
    #elif defined(__x86_64__)
    jmp \\function@PLT
    #else
    #error "Unsupported NaCl architecture"
    #endif
#else  // defined(__native_client__)
    #if defined(__i386__)
    jmp \\function
    #elif defined(__arm__)
    b \\function
    #else
    #error "Unsupported architecture"
    #endif
#endif
.endm

.macro define_wrap_function_to_call_original_function function
.globl __wrap_\\function
.type __wrap_\\function, function
#if defined(__native_client__)
.balign 32
#endif  // defined(__native_client__)
__wrap_\\function:
    trampoline_to_original_libc_call \\function
.endm

'''

  for name in wrapped_functions.get_wrapped_functions():
    print 'define_wrap_function_to_call_original_function %s' % name
Example #5
0
def main():
    OPTIONS.parse_configure_file()
    print '''// Auto-generated file - DO NOT EDIT!
// THIS FILE SHOULD BE USED FOR UNIT TESTS ONLY.

#if defined(__native_client__) && defined(__i386__)
.type get_pc_thunk_cx, function
get_pc_thunk_cx:
    popl %ecx
    nacljmp %ecx
#endif

.macro trampoline_to_original_libc_call function
#if defined(__native_client__)
    #if defined(__i386__)
    call get_pc_thunk_cx
    addl $_GLOBAL_OFFSET_TABLE_, %ecx
    movl \\function@GOT(%ecx), %ecx
    nacljmp %ecx
    #elif defined(__x86_64__)
    jmp \\function@PLT
    #else
    #error "Unsupported NaCl architecture"
    #endif
#else  // defined(__native_client__)
    #if defined(__i386__)
    jmp \\function
    #elif defined(__arm__)
    b \\function
    #else
    #error "Unsupported architecture"
    #endif
#endif
.endm

.macro define_wrap_function_to_call_original_function function
.globl __wrap_\\function
.type __wrap_\\function, function
#if defined(__native_client__)
.balign 32
#endif  // defined(__native_client__)
__wrap_\\function:
    trampoline_to_original_libc_call \\function
.endm

'''

    for name in wrapped_functions.get_wrapped_functions():
        print 'define_wrap_function_to_call_original_function %s' % name
Example #6
0
def main():
    OPTIONS.parse_configure_file()

    if len(sys.argv) < 3:
        print 'Usage: %s libposix_translation.so libc.so...'
        return 1

    libpt_so = sys.argv[1]
    libc_libraries = sys.argv[2:]
    functions = set(wrapped_functions.get_wrapped_functions())

    ok = _check_wrapper_functions_are_defined(functions, libpt_so)
    ok = ok & _check_wrapped_functions_are_defined(functions, libc_libraries)
    if not ok:
        print 'FAILED'
        return 1
    print 'OK'
    return 0