[LLVMdev] MallocInst/CallInst bitcast,

Daniel Waterworth da.waterworth at googlemail.com
Fri Oct 16 11:21:28 PDT 2009


Thanks very much. I only have one more question, (hopefully), which is, is
there a better way of finding the direction of stack growth other than:

static bool StackCmp(void *ptr) {
  volatile int a;
  return (void *)&a > ptr;
}

bool FindStackDirection() {
  volatile int a;
  return StackCmp((void *)&a);
}

Preferably one which isn't destroyed by optimization.

Thanks again,

Daniel

2009/10/16 Chris Lattner <clattner at apple.com>

>
> On Oct 16, 2009, at 4:43 AM, Daniel Waterworth wrote:
>
> Never mind, I used ExecutionEngine's InstallLazyFunctionCreator and
> DisableSymbolSearching to cause malloc and free calls to be handled by my
> logging functions. Sorry for the unnecessary list mail.
>
>
> No problem, this is a better way to go.  The MallocInst and FreeInst
> instructions are about to be removed from LLVM IR.  Malloc and free will be
> represented normal 'call' instructions.
>
> Is it possible to find out the size and beginning pointer of the current
> stack frame, from a function operating outside of the virtual machine, but
> called by a function within it?
>
>
> I don't think so.  Typically, applications that need this sort of thing get
> the address of the function and then do a fuzzy disassembly of the prolog.
>
> -Chris
>
>
> Thanks,
>
> Daniel
>
> 2009/10/16 Daniel Waterworth <da.waterworth at googlemail.com>
>
>> Hello,
>>
>> I'm writing a virtual machine that functions as a sandbox based on llvm.
>> In order to prevent programs from accessing memory that has not been
>> allocated to them, I want to replace calls to malloc and free with calls to
>> a logged functions that will record the memory that is being allocated to
>> the program. Is it possible to cast/convert a MallocInst or FreeInst to a
>> CallInst?
>>
>> Thanks,
>>
>> Daniel
>>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091016/4b65f92e/attachment.html>


More information about the llvm-dev mailing list