<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Dec 12, 2016 at 5:02 PM Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Not sure I follow why you cannot assign to '.'. If that is a limitation<br class="gmail_msg">
that we have, that might be what we want to change.<br class="gmail_msg"></blockquote><div><br></div><div>It's not a limitation, linker script input file is an additional input to the linker which doesn't replace the default linker script. It should only contains symbol definitions, INPUT, GROUP and VERSION commands (see <a href="https://sourceware.org/binutils/docs/ld/Implicit-Linker-Scripts.html#Implicit-Linker-Scripts">https://sourceware.org/binutils/docs/ld/Implicit-Linker-Scripts.html#Implicit-Linker-Scripts</a> for more details)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That should fail. That .o file has an ABS symbol, no?<br class="gmail_msg"></blockquote><div><br></div><div>No, because SHN_ABS symbol doesn't mean absolute symbol, it's the representation for image-relative symbols in ELF. I checked this with Roland Mcgrath (who also happened to found this bug) and this is verbatim of what he said. I double checked this with Binutils and it's indeed how SHN_ABS is interpreted by ld.bfd and ld.gold.<br></div><div><br></div><div>With the patch I have uploaded, lld generates the correct code:</div><div><br></div><div>1000:       48 8d 05 f9 ef ff ff    lea    -0x1007(%rip),%rax        # 0 <_BASE><br></div><div><br></div><div>So this is not really a problem with the implementation, it's really the error message that's incorrect, or more precisely the check is stricter than it should be (which was pointed out by Roland as well).</div></div></div>