<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Dec 12, 2016 at 7:12 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">
But as a quick experiment, a single file with just<br class="gmail_msg">
<br class="gmail_msg">
.global a<br class="gmail_msg">
.hidden a<br class="gmail_msg">
a = 42<br class="gmail_msg">
.quad a<br class="gmail_msg">
<br class="gmail_msg">
has no relocations at all, with both mc and gas. That means that the<br class="gmail_msg">
.quad is always 42. On the other hand, the file has<br class="gmail_msg">
<br class="gmail_msg">
 000000000000002a     0 NOTYPE  GLOBAL HIDDEN   ABS a<br class="gmail_msg">
<br class="gmail_msg">
which is contradictory if ABS means image relative. Is that a bug in gas<br class="gmail_msg">
and mc?<br class="gmail_msg">
<br class="gmail_msg">
If we now use two files, one with<br class="gmail_msg">
<br class="gmail_msg">
        .quad a<br class="gmail_msg">
<br class="gmail_msg">
and another with<br class="gmail_msg">
<br class="gmail_msg">
        .global a<br class="gmail_msg">
        .hidden a<br class="gmail_msg">
        a = 42<br class="gmail_msg">
<br class="gmail_msg">
gold will produce a file with no relocations. BFD will produce a<br class="gmail_msg">
R_X86_64_RELATIVE, but it is the odd one here.<br class="gmail_msg"></blockquote><div><br></div><div>You don't need a dynamic relocation in this case because the symbol is hidden (which is the same as if it was local) as the address can be can be computed statically at link time (relative to the image base). If you remove .hidden, then both gas and mc generate relocation as expected because now the address cannot be determined at link time.</div></div></div>