Latest blog content:
  • Site Changed

    Date Thu 20 August 2015 Tags Life

    Since the blog was migrated (in fact, the entire server), I was wondering what to do with the previous content (especially the redmine installation, and the public git).

    I don’t like the idea of installing a new redmine server (and dynamic content), so I’ve decided to throw away all the previous content and public only the new, static, content. This also makes the installation easier, because the LXC containing the web server is read-only :)

    Some of the active projects are now published on github:

    The change may break all of the previous links - I’m sorry for that, if something was important please contact me.

    Comments may be re-added soon, maybe using Isso, allowing self-hosted comments, and no need for Disqus and others.

    read more
  • OCaml LLVM bindings tutorial, part 4

    See also:

    In the previous examples, we’ve seen how to build OCaml applications to read, manipulate and write LLVM bitcode.

    To be able to generate realistic code, we now need to add a few more things. This part explains how to create bitcode with a correctly specified target triple, how to verify bitcode, and write a hello world application.

    Target Triple and Data Layout

    While LLVM IR is (or should be) target independent, there are a few things that are not. For example, the support for some instructions, the padding and alignment inside structures, the endianness, the size of pointers, etc. All these things are specified in two attributes of modules: the target triple, and the data layout.

    In the current (3.5) version of LLVM, these two attributes are optional. However, they could become mandatory in the future, so it is best specifying them.

    Note: in my personal opinion, specifying that inside the module is clearly redundant with the -march= option of llc. Most of this could have been handled by compiler flags, instead of creating situations where one can ...

    read more
  • OCaml LLVM bindings tutorial, part 3

    See also:

    The previous articles explain how to build applications using the OCaml-LLVM bindings, and how to use the API to manipulate the LLVM objects. This was the “read-only” part of the tutorial, which can be used to analyze LLVM IR.

    This part explains how to create LLVM IR, and write a simple application from scratch, and see how to build and run it.


    As in the previous tutorial, we need to create a context and a module:

    let llctx = global_context () in
    let llm = create_module llctx "mymodule" in


    There are two actions that can be done on functions:

    • declare_function to give only a declaration of the prototype,
    • define_function to give both the declaration and the implementation.

    In both cases, we need to give the signature (return type, number and type of arguments) of the function.

    This is pretty similar to C. We’ll use this to declare the function int main(void).

    The int type is a bit problematic in LLVM (and in C, but for other reasons): integer types must have a known size in LLVM. While this does not change the architecture-independent property ...

    read more
  • Other articles

    Please go to the Blog index