Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add llvm_sizeof command #803

Closed
andreistefanescu opened this issue Aug 4, 2020 · 1 comment · Fixed by #808
Closed

Add llvm_sizeof command #803

andreistefanescu opened this issue Aug 4, 2020 · 1 comment · Fixed by #808
Assignees

Comments

@andreistefanescu
Copy link
Contributor

Let's add a llvm_sizeof command that returns the size (in bytes) of the given LLVMType. This should mirror the sizeof from C. The existing code that does that calculation in crucible_alloc is around https://github.com/GaloisInc/saw-script/blob/master/src/SAWScript/Crucible/LLVM/Builtins.hs#L1709.

@brianhuffman
Copy link
Contributor

In #808 I implemented llvm_sizeof as a function that takes an LLVMModule argument. I'm not sure if this is exactly what you want; the alternative would have been a monadic function that runs in the CrucibleSetup monad: llvm_sizeof : LLVMType -> CrucibleSetup Int.

In any case, a simple pure type LLVMType -> Int is not possible, as we need an LLVM type context to know how to interpret alias types, struct padding, and alignment; and there is no such LLVM type context available in the saw-script TopLevel monad.

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 a pull request may close this issue.

2 participants