[llvm-dev] Transfer information IR to binary

mats petersson via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 22 07:48:34 PST 2016


And you want this for only SOME bits of code, and that's why you need to
have the IR report what sections are "sensitive"?

It would be fairly easy if the code you want to check is a normal
functions, just store the start address of the function, and the length
should be doable too at machine code level, but not IR level. If you want
to check only the middle of the function, it's a bit harder.

How are you dealing with the fact that code gets relocated during loading?

[I'm always curious as to how these type of designs cope with someone
modifying the checksumming code itself, but that's another problem - or is
this one of these things where the checksum is stored in special
hardwareprotected memory?].

--
Mats

On 22 February 2016 at 14:45, Wehrli Johan <johan.wehrli at heig-vd.ch> wrote:

> I will try to explain better what I do.
>
> The main goal behind this is to verify that a part of code is not modified
> by someone else (it is an integrity check).
>
> To do this, I create in IR a function who take 2 parameters, a begin and
> an end value.
>
> This function perform an hash over the code area (from begin to end) and
> return it.
>
> At first, I don’t know the addresses and the hash value so I put random
> value (it is an integer 64 bits).
>
> The function look like* uint32_t isModified(uint64_t* begin, uint64_t*
> end). *
>
> Once the compilation is over, I need to update the begin address, end
> address and the hash value.
>
> When I say the compilation is over, I mean the clang driver has finished
> all of his action (compiling, linking, etc.).
>
> Greetings,
>
> Johan
>
>
> On 22 Feb 2016, at 15:04, mats petersson <mats at planetcatfish.com> wrote:
>
> What kind of constant: type, value and how is it created?
>
> You can make public symbols that you can extract in a linker script to a
> special section.
>
> Or perhaps you want some metadata that a special late state (machine
> instr) pass is extracting and adding.
>
> The "best" solution really depends on what you are trying to achieve
> overall and what kind of data you are working with.
>
> --
> Mats
>
> On 22 February 2016 at 13:04, Wehrli Johan via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Hi,
>>
>> I want to know if it is possible to pass information from IR to the final
>> binary (like a constant value)?
>>
>> I have a module pass in IR who make some transformation and, once the
>> compilation is finished, I need to apply a post-processing.
>>
>> The post-processing need information from the IR part.
>>
>> Greetings,
>>
>> Johan
>>
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160222/5d5b3ac6/attachment.html>


More information about the llvm-dev mailing list