<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thank you for the input.<div class=""><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">But I don't think that's a particularly good solution long term.<br class=""><br class=""></div><div class="">Maybe someone else has a better idea... <br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>Yeah maybe someone else will have an idea :-)</div><div><br class=""></div><div>Johan </div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class="">--<br class=""></div><div class="">Mats<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="">How are you dealing with the fact that code gets relocated during loading?<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">You talk about the loading phase during the link? If yes, this is why a do the post-processing after the link.</div><div class=""><br class=""></div><div class="">If you talk about something like the -fpie parameter, I used a small trick.</div><div class=""><br class=""></div><div class="">The function who will call isModified will calculate the offset dynamically.</div><div class=""><br class=""></div><div class="">To do this, you get the address in IR (in C++ this is like <b class="">(uint64_t)std::addressof(main);</b>) and I remove a constant value.</div><div class=""><br class=""></div><div class="">During the post-processing (again) I will update this constant value with the address into the binary.</div><div class=""><br class=""></div><div class="">This will give you an offset and you used it to update the addresses.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">[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?].<br class=""></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">For now, I store it into an special place.</div><div class=""><br class=""></div><div class="">My first solution for my problem was to used some temporary file but this is highly impractical.</div><div class=""><br class=""></div><div class="">Maybe I can create a temporary section into the binary but I didn’t find a lot of information about it.</div><span class=""></span><span class=""><div class=""><span class=""><br class=""></span></div>Thanks,</span></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">Johan<br class=""></span><div class=""><div class="h5"><span class=""><br class=""></span><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">--<br class=""></div>Mats<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 22 February 2016 at 14:45, Wehrli Johan <span dir="ltr" class=""><<a href="mailto:johan.wehrli@heig-vd.ch" target="_blank" class="">johan.wehrli@heig-vd.ch</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">I will try to explain better what I do.</div><div class=""><br class=""></div><div class="">The main goal behind this is to verify that a part of code is not modified by someone else (it is an integrity check).</div><div class=""><br class=""></div><div class="">To do this, I create in IR a function who take 2 parameters, a begin and an end value.</div><div class=""><br class=""></div><div class="">This function perform an hash over the code area (from begin to end) and return it.</div><div class=""><br class=""></div><div class="">At first, I don’t know the addresses and the hash value so I put random value (it is an integer 64 bits).</div><div class=""><br class=""></div><div class="">The function look like<b class=""> uint32_t isModified(uint64_t* begin, uint64_t* end). </b></div><div class=""><br class=""></div><div class="">Once the compilation is over, I need to update the begin address, end address and the hash value.</div><div class=""><br class=""></div><div class="">When I say the compilation is over, I mean the clang driver has finished all of his action (compiling, linking, etc.).</div><div class=""><br class=""></div><div class="">Greetings,</div><div class=""><br class=""></div><div class="">Johan</div><div class=""><div class=""><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 22 Feb 2016, at 15:04, mats petersson <<a href="mailto:mats@planetcatfish.com" target="_blank" class="">mats@planetcatfish.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">What kind of constant: type, value and how is it created?<br class=""><br class=""></div>You can make public symbols that you can extract in a linker script to a special section.<br class=""><br class=""></div>Or perhaps you want some metadata that a special late state (machine instr) pass is extracting and adding. <br class=""><br class=""></div><div class="">The "best" solution really depends on what you are trying to achieve overall and what kind of data you are working with.<br class=""></div><div class=""><br class="">--<br class=""></div>Mats<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 22 February 2016 at 13:04, Wehrli Johan via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="">
<br class="">
I want to know if it is possible to pass information from IR to the final binary (like a constant value)?<br class="">
<br class="">
I have a module pass in IR who make some transformation and, once the compilation is finished, I need to apply a post-processing.<br class="">
<br class="">
The post-processing need information from the IR part.<br class="">
<br class="">
Greetings,<br class="">
<br class="">
Johan<br class="">
<br class="">
<br class="">
<br class="">_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div></div></div><br class=""></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>