[PATCH] D39392: Do not add weak undefined symbols to .dynsym unless -pic or -shared are given.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 19:02:11 PST 2017
I'm not sure if you understand the problem I'm trying to resolve.
IIUC, what https://bugs.llvm.org/show_bug.cgi?id=34301#c5 claims as a bug
is not a bug.
Weak external symbols that were not compiled with -fPIC are fundamentally
not representable when they are resolved to other DSOs. Assume that
weak_func is provided by some DSO. As I wrote in the comment, simple code
like
if (weak_func)
weak_fun();
doesn't work if the code is not compiled with -fPIC, because otherwise,
weak_func has an address of its PLT entry which is always non-zero. As a
result, if weak_func doesn't exist at runtime, it crashes when it executes
weak_func(). That's bad, and my patch is to address the issue.
I don't know what else I need to explain, as I wrote all the reasoning of
doing it as a comment in this patch. Which part of the comment is confusing
to you?
On Fri, Dec 1, 2017 at 6:42 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:
> Rui Ueyama <ruiu at google.com> writes:
>
> > No, I don't think this is related to PR34301. Why do you think so? This
> is
> > not also related to whether a symbol is a local or not.
>
> I just tested the patch and it does break the test in
>
> https://bugs.llvm.org/show_bug.cgi?id=34301#c5
>
> As such, I don't think it should be applied.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171201/32f6c218/attachment.html>
More information about the llvm-commits
mailing list