This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Implement weak bindings for GOT/TLV
ClosedPublic

Authored by int3 on Aug 25 2020, 1:21 PM.

Details

Reviewers
smeenai
Group Reviewers
Restricted Project
Commits
rGcbe27316efce: [lld-macho] Implement weak bindings for GOT/TLV
Summary

Previously, we were only emitting regular bindings to weak
dynamic symbols; this diff adds support for the weak bindings too, which
can overwrite the regular bindings at runtime. We also treat weak
defined global symbols similarly -- since they can also be interposed at
runtime, they need to be treated as potentially dynamic symbols.

Note that weak bindings differ from regular bindings in that they do not
specify the dylib to do the lookup in (i.e. weak symbol lookup happens
in a flat namespace.)

Diff Detail

Event Timeline

int3 created this revision.Aug 25 2020, 1:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 1:21 PM
int3 requested review of this revision.Aug 25 2020, 1:21 PM
smeenai accepted this revision.Aug 26 2020, 4:54 PM
smeenai added a subscriber: smeenai.

LGTM

lld/MachO/Symbols.h
78

How much more work would it be to have this not have a default value, and instead set it explicitly for each constructor call? I'd like to explicit with this if it's not too onerous.

86

The terminology used by Mach-O for this appears to be external/non-external, vs. global/local (as ELF does it). I'd prefer using that terminology in the linker as well.

lld/MachO/SyntheticSections.cpp
224

Nit: put this in the header?

lld/MachO/SyntheticSections.h
217

Typo: neeed -> need

lld/test/MachO/weak-binding.s
83

Mind adding a test for a weak local TLV symbol as well?

This revision is now accepted and ready to land.Aug 26 2020, 4:54 PM
int3 updated this revision to Diff 288154.Aug 26 2020, 6:51 PM
int3 marked 5 inline comments as done.

address comments

This revision was landed with ongoing or failed builds.Aug 26 2020, 7:27 PM
This revision was automatically updated to reflect the committed changes.