This is an archive of the discontinued LLVM Phabricator instance.

[ELF2] Add -wrap switch
AbandonedPublic

Authored by ikudrin on Oct 7 2015, 2:40 AM.

Details

Reviewers
ruiu
rafael
Summary

If the '-wrap' switch is used, all undefined references to 'symbol' will be resolved to '_ _wrap_symbol'.
Similarly, undefined references to '_ _real_symbol' will be resolved to 'symbol'.

Diff Detail

Event Timeline

ikudrin updated this revision to Diff 36717.Oct 7 2015, 2:40 AM
ikudrin retitled this revision from to [ELF2] Add -wrap switch.
ikudrin updated this object.
ikudrin added reviewers: rafael, ruiu.
ikudrin added a project: lld.
ikudrin added a subscriber: llvm-commits.
ikudrin updated this object.Oct 7 2015, 2:47 AM
ikudrin updated this revision to Diff 36728.Oct 7 2015, 5:21 AM
  • Updated test
ruiu edited edge metadata.Oct 7 2015, 6:38 AM

This patch needs redesigning because we don't want to look up hash tables more than once for each symbol. In this patch, names for undefined symbols are looked up twice -- once in the InputFile.cpp and the other in SymbolTable.cpp.

In D13501#261600, @ruiu wrote:

This patch needs redesigning because we don't want to look up hash tables more than once for each symbol. In this patch, names for undefined symbols are looked up twice -- once in the InputFile.cpp and the other in SymbolTable.cpp.

We have to look up for different names for defined and undefined symbols, so we can't use just one hash map.

In most cases, when the -wrap switch is not used and UndefSymNameReplacement is empty, addition lookup will be very cheap, without calculating a hash value at all. On the other hand, we can use just std::map which expected to work really quick in our case.

ikudrin abandoned this revision.Oct 9 2015, 8:14 AM
ikudrin added a parent revision: D13528: --wrap.