This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Allow the entry symbol to be dynamically bound
ClosedPublic

Authored by int3 on Sep 17 2020, 12:53 PM.

Details

Reviewers
smeenai
Group Reviewers
Restricted Project
Commits
rGc7c9776f7771: [lld-macho] Allow the entry symbol to be dynamically bound
Summary

Apparently this is used in real programs. I've handled this by reusing
the logic we already have for branch (function call) relocations.

Diff Detail

Event Timeline

int3 created this revision.Sep 17 2020, 12:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2020, 12:53 PM
int3 requested review of this revision.Sep 17 2020, 12:53 PM
smeenai accepted this revision.Sep 22 2020, 12:52 PM
smeenai added a subscriber: smeenai.

LGTM. It's interesting that this is a thing.

lld/MachO/Writer.cpp
200

Possible follow-up: I think this calculation is done in a bunch of places. Is there a nice place where a function for this calculation could live?

This revision is now accepted and ready to land.Sep 22 2020, 12:52 PM
int3 added inline comments.Sep 22 2020, 2:23 PM
lld/MachO/Writer.cpp
200

it's not really identical with anything else -- I mean, there's another place where we do addr + stubsIndex * stubSize, but here we are calculating the file offset and not the address. There are also a bunch of other places where we multiply by WordSize (to index into __la_symbol_ptrs) instead of by stubSize.

smeenai added inline comments.Sep 22 2020, 2:24 PM
lld/MachO/Writer.cpp
200

You're right; I didn't pay attention to the VA vs the file offset.

This revision was landed with ongoing or failed builds.Sep 25 2020, 11:29 AM
This revision was automatically updated to reflect the committed changes.