<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>​<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">​I will look a</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">t</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> relocation
 relaxations closer tomorrow, may be will be able to </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">suggest</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> something</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> to
 reduce complexity a bit</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">.</span>​<br>
</p>
<p><br>
</p>
<div id="Signature">
<div class="BodyFragment"><font size="2">
<div class="PlainText">Best regards,<br>
George.</div>
</font></div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> Rui Ueyama <ruiu@google.com><br>
<b>Отправлено:</b> 21 января 2016 г. 12:11<br>
<b>Кому:</b> llvm-dev; Rafael Ávila de Espíndola; George Rimar; Simon Atanasyan; Davide Italiano<br>
<b>Тема:</b> Need to refactor relocation handlers in ELF LLD</font>
<div> </div>
</div>
<div>
<div dir="ltr">We have fairly large and complex code to handle relocations in Writer.cpp, Target.cpp, OutputSections.cpp and InputSections.cpp. They started with simple code, but because each patch added a small piece of code to the existing one, it is becoming
 out of control now. For example, we have lots of entangled boolean flags in the functions that interfere with each other in an obscure fashion. Even I don't understand all these interactions.
<div>
<div><br>
</div>
<div>We need to clean this up to get it back to be manageable. The code in SymbolTable.cpp is for example pretty much readable and in my opinion beautiful. I want the relocation handlers to be as readable as that is.</div>
<div><br>
</div>
<div>I think there are a few things we can to do to fix the problem.</div>
<div><br>
</div>
<div>1. I'd like everybody to not add any more complexity to the relocation handler until we clean this up because as we add more code, it gets harder to refactor. Any patch to reduce complexity is welcome.</div>
</div>
<div><br>
</div>
<div>2. The fact that we don't create SymbolBodies for local symbols is one of the major factors to contribute that complexity. I experimented on creating them, and the performance penalty seemed to be within a few percent, so that's a good trade-off. I'll
 try that. We can offset that degradation with optimizations in other places.</div>
<div><br>
</div>
<div>3. We probably want to separate relocation relaxation from relocation application. Currently it is a unified pass, but theoretically we can split it up into two, so that we do relaxation and then apply remaining relocations.</div>
<div><br>
</div>
<div>4. Last but not least, any code that is not obvious needs explanation in comment, so that first-time readers who have basic knowledge on ELF can read and understand the code. Even if code is very simple, comment may be needed, because readers may want
 to know not only what is to be done but also why we want to do that for what.</div>
<div><br>
</div>
<div>My bar for readability may be a little bit high, but I strongly believe that that will eventually increase overall productivity. I really need help from LLD developers to keep it readable and hackable. I'd greatly appreciate any patch to reduce complexity.
 Thanks!</div>
</div>
</div>
</div>
</body>
</html>