<div dir="ltr"><div>Again, what are you trying to do, at a "big picture" level? What would be the purpose of object layout randomisation?<br><br>And for sure, you have to be VERY sure that this doesn't break compatibility with other code compiled separately from this TU. <br><br>In other words, don't break stdio.h's FILE structures, some kind of OS data structures (or network protocols, file-system structures, xml-parser, Open{CL,GL,GLES,VX,CV,VG} packages, binary data stored in files, etc, etc). You can't just modify struct/class content without understanding how it affects the rest of the system - so blindly adding something inside LLVM is highly unlikely to work. You need some way to understand WHAT data structures are "yours" and which ones are system/binary compatibility-dependent and can't be changed without also changing things elsewhere.<br><br>Also consider if there is a user-defined struct T that is declared in a header file T.h and included in A.cpp that goes into LibA, and then included by B.cpp that makes LibB, and then main.cpp also uses T.h and links with LibA and LibB - the resulting struct T needs to be identical in layout in all three places, or bad things will happen.<br><br></div><div>If I was doing this, I would probably try to either modify the files in the project through some suitable script and/or using libclang/libtooling to parse the relevant code and output modified source, avoiding modification of system-files and out-of-project modules.<br></div><div><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 16 July 2015 at 22:37, Mohit Mishra <span dir="ltr"><<a href="mailto:mmishra23@gmail.com" target="_blank">mmishra23@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>HI Mats,<br><br></div>Thanks for getting back to me.<br><div class="gmail_extra"><br><div class="gmail_quote"><span class=""><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>I take it you mean that you want to add a field to all classes COMPILED by LLVM, and not all classes that LLVM consists of?<br></div></div></div></div></blockquote></span><div>YES! <br></div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><br></div></div><div>Also, unless I'm terribly misinformed, adding something to an ArrayRef is not going to work. ArrayRef, StringRef and such are "references to the original data in the calling code", which means you have no right to modify it.<br></div></div></div></blockquote><div><br></div></span><div> What I want is to be able to randomize object layout; and hence adding of integer fields to the classes might be a good option. While I did think so about ArrayRef, I thought about to substitute that with vector something like this:<br><div dir="ltr">vector<Type*> vecType = Elements.vec ();</div><div dir="ltr">vecType.insert (Type::getInt32Ty (Context))</div>ST->setBody(vecType, isPacked);<br></div><div><br></div><div>and modify the setBody function parameters replacing ArrayRef with the vector. However, I'm still skeptical about this.<br></div><div> </div>What do you propose to have a fairly good object layout randomization?<br><br></div><div class="gmail_quote">Best,<br></div><div class="gmail_quote">Mohit.<br></div></div></div>
</blockquote></div><br></div>