[llvm] r317292 - Avoid PLT for external calls when attribute nonlazybind is used.

Sriraman Tallam via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 10:08:28 PDT 2017


On Fri, Nov 3, 2017 at 7:58 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Sriraman Tallam <tmsriram at google.com> writes:
>
> > On Thu, Nov 2, 2017 at 5:43 PM, Rafael Avila de Espindola
> > <rafael.espindola at gmail.com> wrote:
> >> Why force a call via the got when a direct one could be used?
> >>
> >> With -fno-plt -fPIC gcc compiles
> >>
> >> __attribute__((visibility("hidden"))) void foo(void);
> >> void bar(void);
> >> void zed(void) {
> >>   foo();
> >>   bar();
> >> }
> >>
> >> to
> >>
> >>         call    foo
> >>         call    *bar at GOTPCREL(%rip)
> >>
> >> But this patch will use the got for both calls, no?
> >
> > I did not test this case and if it is true that foo can never be
> > external in this case then I got it wrong.  But what if foo was not
> > defined by the DSO?
>
> It would be a bug in the program as it is hidden.
>

Right.


>
> The check for plt versus got should at the very least be after the
> shouldAssumeDSOLocal call.
>

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.


>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171103/dee81e80/attachment.html>


More information about the llvm-commits mailing list