<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 12, 2016 at 7:12 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> It's not a limitation, linker script input file is an additional input to<br>
> the linker which doesn't replace the default linker script. It should only<br>
> contains symbol definitions, INPUT, GROUP and VERSION commands (see<br>
> <a href="https://sourceware.org/binutils/docs/ld/Implicit-Linker-Scripts.html#Implicit-Linker-Scripts" rel="noreferrer" target="_blank">https://sourceware.org/<wbr>binutils/docs/ld/Implicit-<wbr>Linker-Scripts.html#Implicit-<wbr>Linker-Scripts</a><br>
> for<br>
> more details)<br>
<br>
</span>In which case we would need some expression to mean the base. That is<br>
just not the same as 0 currently (see below).<br>
<span class="gmail-"><br>
><br>
> That should fail. That .o file has an ABS symbol, no?<br>
>><br>
><br>
> No, because SHN_ABS symbol doesn't mean absolute symbol, it's the<br>
> representation for image-relative symbols in ELF. I checked this with<br>
> Roland Mcgrath (who also happened to found this bug) and this is verbatim<br>
> of what he said. I double checked this with Binutils and it's indeed how<br>
> SHN_ABS is interpreted by ld.bfd and ld.gold.<br>
<br>
</span>All that the spec says is<br>
<br>
SHN_ABS<br>
    The symbol has an absolute value that will not change because of<br>
    relocation.<br>
<br>
But as a quick experiment, a single file with just<br>
<br>
.global a<br>
.hidden a<br>
a = 42<br>
.quad a<br>
<br>
has no relocations at all, with both mc and gas. That means that the<br>
.quad is always 42. On the other hand, the file has<br>
<br>
 000000000000002a     0 NOTYPE  GLOBAL HIDDEN   ABS a<br>
<br>
which is contradictory if ABS means image relative. Is that a bug in gas<br>
and mc?<br>
<br>
If we now use two files, one with<br>
<br>
        .quad a<br>
<br>
and another with<br>
<br>
        .global a<br>
        .hidden a<br>
        a = 42<br>
<br>
gold will produce a file with no relocations. BFD will produce a<br>
R_X86_64_RELATIVE, but it is the odd one here.<br>
<br>
So if SHN_ABS should mean image-relative, we have more than one bug to<br>
fix (and one spec to clarify).<br></blockquote><div><br></div><div>Hi Rafael,</div><div><br></div><div>I found some discussion on the binutils bug tracker and mailing list</div><div><a href="https://sourceware.org/bugzilla/show_bug.cgi?id=14052">https://sourceware.org/bugzilla/show_bug.cgi?id=14052</a><br></div><div><a href="https://sourceware.org/ml/binutils/2012-05/msg00023.html">https://sourceware.org/ml/binutils/2012-05/msg00023.html</a><br></div><div><br></div><div>It looks like the conclusion to be drawn is that BFD's behaviour is wrong.</div><div><br></div><div>Thanks,</div></div>-- <br><div class="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>