This is an archive of the discontinued LLVM Phabricator instance.

[ELF] --warn-backref: don't report backref to weak symbols.
ClosedPublic

Authored by MaskRay on May 8 2018, 8:26 PM.

Details

Summary

Suppose we visit symbols in this order:

  1. weak definition of foo in a lazy object
  2. reference of foo

3 (optional). definition of foo

bfd/gold allows 123 but not 12.

Current --warn-backrefs implementation will report both cases as a backward reference. With this change, both 123 (intended) and 12 (unintended) are allowed. The usage of weak definitions usually imply there are also global definitions, so the trade-off is justified.

Event Timeline

MaskRay created this revision.May 8 2018, 8:26 PM
MaskRay updated this revision to Diff 145854.May 8 2018, 8:28 PM

Add -o %t.exe

A real world example:

https://git.gnome.org/browse/libxml2/tree/threads.c defines weak symbols #pragma weak pthread_self that are intended to be overriden later by (libpthread.a)

ruiu added a comment.May 9 2018, 3:11 PM

I do understand the intent of this change, but it feels like it can be simplified even more. You don't need to keep the existing function, feel free to edit everything to make code clean.

grimar added a subscriber: grimar.May 10 2018, 3:07 AM
MaskRay updated this revision to Diff 146257.May 10 2018, 4:50 PM

Delete checkBackrefs.

ruiu accepted this revision.May 10 2018, 4:55 PM

LGTM

This revision is now accepted and ready to land.May 10 2018, 4:55 PM
This revision was automatically updated to reflect the committed changes.