[PATCH] D53753: [Windows] Define generic arguments registers for Windows x64

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 05:17:15 PDT 2019


labath added a comment.

In D53753#1504539 <https://reviews.llvm.org/D53753#1504539>, @aleksandr.urakov wrote:

> In D53753#1504361 <https://reviews.llvm.org/D53753#1504361>, @labath wrote:
>
> > I'm not sure what exactly are the consequences of not using the correct ABI definition here. I think the case where the difference may start to become obvious is if you try to get argument values of a function for which you don't have debug info for.
>
>
> It sounds strange to me... If we don't have symbols for a function, then we can't even know amount of its arguments, so how can we retrieve them? Also e.g. on Windows x86 both stdcall, ccall, thiscall and fastcall are commonly used, so it would be strange to use some "default" ABI...


That's good point. I may be misremembering things here. I never dealt with these things directly, and I'm just relaying what I remember from past discussions.

I had a brief look at the source code, and it looks like there's only a handful of callers to the `GetArgumentValues` method. The main use case seems to be when you already have some external knowledge that a certain function has some signature, but you may not have debug info for it (e.g. because it's a system function, and you don't have debug info for system libraries). AppleObjCRuntime seems to use that to extract some information about the exception being thrown..

So it's quite possible that this function is never actually called on windows..

> 
> 
>> (Also, we use the abi plugin to call mmap, and mmap takes 6 arguments).
> 
> Can you explain me, please, when does such mmap being called? Just for the purpose of general education :)

When we evaluate an expression, we jit a bunch of opcodes into the inferior memory and then have it execute them. For that to work, we need to allocate some memory in order to store the opcodes. We cannot use the general expression engine to jit that expression, as we would be back to square one, so we manually set the PC to the entry point of the mmap function, and set the argument values as if it was being called. Then we just let the inferior loose and have it  allocate the memory for us and return it. For this to work, we need abi knowledge both to correctly set the arguments of mmap, and to retrieve its result.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53753/new/

https://reviews.llvm.org/D53753





More information about the llvm-commits mailing list