<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 22, 2017 at 10:33 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
<br>
On February 22, 2017 1:20:44 PM EST, Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br>
>On Wed, Feb 22, 2017 at 9:43 AM, Rafael Avila de Espindola <<br>
><a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
><br>
>> I am looking at <a href="https://bugs.llvm.org/show_bug.cgi?id=32031" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=32031</a> and there<br>
>> are a couple of ways to interpret it.<br>
>><br>
>> One way is that we are just computing symbol values too early. When<br>
>we<br>
>> do it some output sections still don't have their address set and<br>
>some<br>
>> input sections still don't know what output section they will be in.<br>
>><br>
>> The other way to look at it is just that our representation of symbol<br>
>> values in the linker script is wrong. I started experimenting with<br>
>using<br>
>> a ExprValue struct that is similar in idea to a MCValue. It is what<br>
>Expr<br>
>> returns and it contains a PointerUnion of an input or output section<br>
>and<br>
>> the offset. This allows us to avoid having to check the OutSec field<br>
>> before it is set and solves the problem.<br>
>><br>
>> But that got me thinking, can we remove DefinedSynthetic completely?<br>
>> With the addition of a few dummy input sections and potentially a<br>
>couple<br>
>> more conversions to SyntheticSection I think we can.<br>
>><br>
><br>
>Regular Defined symbols are defined relative to input sections because<br>
>they<br>
>are both read from input files. Regular symbols get their addresses<br>
>when<br>
>the associated input sections get addresses.<br>
><br>
>DefinedSynthetic is being used to define linker-synthesized symbols<br>
>that<br>
>are relative to output sections. _end or _edata are a few examples.<br>
><br>
>So, if you remove DefinedSynthetic, how do you represent _end, for<br>
>example?<br>
<br>
</div></div>By attaching it to a empty synthetic section at the end of the corresponding output section.<br></blockquote><div><br></div><div>Not 100% sure, but it should work. The number of places we are using DefinedSynthetic is limited, so it shouldn't be hard to rewrite it.</div><div><br></div><div>But you can update LinkerScript.cpp to verify that your idea works first, right? Then you can update Writer.cpp to remove DefinedSynthetic if it works.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Cheers,<br>
Rafael<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
--<br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.<br>
</font></span></blockquote></div><br></div></div>