Skip to content

Conversation

@truls
Copy link
Contributor

@truls truls commented May 12, 2017

This PR contains support for:

  • More than 6 function parameters
  • Changing function parameter state dynamic -> static upon function invocation (I'm not sure this should be included)
  • A new and more flexible API for specifying static-ness and role of function parameters (I'm not sure if I like my actual implementation for several reasons)
  • Special call handling including: Executing a function outside of DBrew and getting it's return value in DBrew and keeping a function call unchanged.

These features has a lot of cross-dependencies. Thus the combined PR.

truls added 21 commits May 11, 2017 21:26
Preliminary support for marking parameters of arbitrary functions static. The
added interface enables the known-ness of parameters of arbitrary functions to
be specified. The implementation builds on the memory range functionality and
generalizes the function configuration interface such that the handling of
rewriting entry functions and all other functions are unified.
Add configuration options for configuring that at a function should not be
entered by the emulator. The function call can either be passed through (static
parameter values are loaded before the call) or executed optionally mark its
return value as static.
Useful for e.g. specialized handling of libc functions. Currently only implemented for memcpy

Refactor call instruction handling (move bypassEmu stuff in sep. fun)
@aengelke
Copy link
Contributor

Some comments (not just about this MR but partly more general):

  • I'm worried about calling an arbitrary function at emulation time, this can have unintended effects including memory access (we should maintain a hashmap for emulating memory access, s.t. the real memory is never modified) and will "fail" (crash) for functions like call $; pop rax; .... (Yes, probably no compiler will emit this and it is the user's fault if the flag is enabled, but we can't be sure.)
  • There are (currently?) three pools of parameters: GP regs, SSE regs, stack. These should be handled correctly. (Ideally, we would model the stack as another STATIC2 memory region, but I guess no one will ever implement this.)
  • What is the purpose of FC_SetReturnDynamic?
  • I'm still not too convinced about handling libc functions with pseudo-instructions.
  • The build in Travis fails (unused function, missing field returnOrigOnFail).

@truls
Copy link
Contributor Author

truls commented May 13, 2017 via email

@truls
Copy link
Contributor Author

truls commented May 13, 2017

Btw, usage examples of these new config interfaces are found in https://github.com/truls/dbrew-ddtbench/blob/master/src_c/utilities.c

@weidendo
Copy link
Contributor

weidendo commented May 14, 2017 via email

@aengelke
Copy link
Contributor

How would this be possible? The stack can be written to with non-static data...

I meant that any fixed parameter region on the stack should be marked as STATIC2, not the whole stack.

LLVM has attributes for readnone, readonly, argmemonly and even speculatable, maybe a scheme like this might be useful?

@truls
Copy link
Contributor Author

truls commented May 14, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants