LLVM Discussion Forums

Calculate the function hash at IR time

I want to insert the check function which verify the function hash and ensure the function integrity.

My scheme is

  1. get the function start&end address
  2. insert the function which calculates the function hash from the start to end address.

So far, I find the way to get function addres at iR time using llvm::blockaddress
However, I get into trouble when get the function hash.
Can I insert a function which calc the hash and verify the hash?

I’ve watch the 2017 LLVM Developers’ Meeting: "Challenges when building an LLVM bitcode Obfuscator"

But the lecture said using JIT to generate the hash, but not mention how to insert the function which read the assemble text and calc hash.

I’m new to this, and wonder how to achieve the hash function. Is there any LLVM util helps?

(BTW, even if calc hash bring problems, it doesn’t matter

Thanks a lot in advance.

This looks like it’s in the wrong forum category… @joker-eph is it possible to move topics?

Done @ftynse, thanks for noticing!