<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 3, 2017 at 7:58 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><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-">Sriraman Tallam <<a href="mailto:tmsriram@google.com">tmsriram@google.com</a>> writes:<br>
<br>
> On Thu, Nov 2, 2017 at 5:43 PM, Rafael Avila de Espindola<br>
> <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
>> Why force a call via the got when a direct one could be used?<br>
>><br>
>> With -fno-plt -fPIC gcc compiles<br>
>><br>
>> __attribute__((visibility("<wbr>hidden"))) void foo(void);<br>
>> void bar(void);<br>
>> void zed(void) {<br>
>>   foo();<br>
>>   bar();<br>
>> }<br>
>><br>
>> to<br>
>><br>
>>         call    foo<br>
>>         call    *bar@GOTPCREL(%rip)<br>
>><br>
>> But this patch will use the got for both calls, no?<br>
><br>
> I did not test this case and if it is true that foo can never be<br>
> external in this case then I got it wrong.  But what if foo was not<br>
> defined by the DSO?<br>
<br>
</span>It would be a bug in the program as it is hidden.<br></blockquote><div><br></div><div>Right.</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">
<br>
The check for plt versus got should at the very least be after the<br>
shouldAssumeDSOLocal call.<br></blockquote><div><br></div><div>I tried doing this after shouldAssumeDSOLocal and this does not work well non-PIC binaries.  The external call will be considered local and generated without the @PLT but the linker will convert the call to PLT. This is the reason why I did it before "shouldAssumeDSOLocal". Let me take another look and see what I can do here.</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">
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>