Hi, How can I obtain the upper bound of a pointer in the code? For example, I have a pointer Ptr which points to a block of memory that is allocated by malloc, say, Ptr = malloc(size); Then what should I do if I am going to get the upper bound of the memory block that is pointed to by Ptr in the runtime? Thanks, Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131216/fbea92ae/attachment.html>
This is rather off-topic for LLVM, it's a C programming question and the C answer is: you can't. C doesn't expose any way to find the upper limit of 'Ptr' you just have to keep track of what size you used yourself. On Sun, Dec 15, 2013 at 6:22 PM, 李永超 <lyc364 at gmail.com> wrote:> Hi, > How can I obtain the upper bound of a pointer in the code? For example, I > have > a pointer Ptr which points to a block of memory that is allocated by > malloc, say, > > Ptr = malloc(size); > > > Then what should I do if I am going to get the upper bound of the memory > block > that is pointed to by Ptr in the runtime? > > Thanks, > Ben > > _______________________________________________ > 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/20131215/197fcd06/attachment.html>
Henrique Santos
2013-Dec-16 13:34 UTC
[LLVMdev] How can I obtain upper bound of a pointer?
If you want an exact "upper bound", you'll have to use something like SoftBound (acg.cis.upenn.edu/softbound), which keeps track of the size of each allocated region at runtime. H. On Mon, Dec 16, 2013 at 4:26 AM, David Blaikie <dblaikie at gmail.com> wrote:> This is rather off-topic for LLVM, it's a C programming question and the C > answer is: you can't. C doesn't expose any way to find the upper limit of > 'Ptr' you just have to keep track of what size you used yourself. > > > On Sun, Dec 15, 2013 at 6:22 PM, 李永超 <lyc364 at gmail.com> wrote: > >> Hi, >> How can I obtain the upper bound of a pointer in the code? For example, I >> have >> a pointer Ptr which points to a block of memory that is allocated by >> malloc, say, >> >> Ptr = malloc(size); >> >> >> Then what should I do if I am going to get the upper bound of the memory >> block >> that is pointed to by Ptr in the runtime? >> >> Thanks, >> Ben >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > > _______________________________________________ > 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/20131216/ed56ef87/attachment.html>
On 12/15/13 8:22 PM, 李永超 wrote:> Hi, > How can I obtain the upper bound of a pointer in the code? For > example, I have > a pointer Ptr which points to a block of memory that is allocated by > malloc, say, > > Ptr = malloc(size); > > > Then what should I do if I am going to get the upper bound of the > memory block > that is pointed to by Ptr in the runtime?Both SAFECode (http://safecode.cs.illinois.edu) and SoftBound (http://acg.cis.upenn.edu/softbound) have run-time support for finding the bounds of an object given a pointer into the object. SAFECode and SoftBound are combined into a single tool available in the SAFECode source code repository (see the SAFECode website for directions on how to download and compile the software). You can play with both of them and see which will suite your needs better. -- John T.> > Thanks, > Ben > > > _______________________________________________ > 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/20131216/5892d40c/attachment.html>
Maybe Matching Threads
- [LLVMdev] How can I obtain upper bound of a pointer?
- [LLVMdev] getMetadata(“dbg”) returns NULL
- [LLVMdev] project based in trusted computing
- [LLVMdev] How to obtain CFG using llvm-gcc?
- [LLVMdev] Google Summer of Code proposal: Adding memory safety checks to the LLVM bitcodes