This is an archive of the discontinued LLVM Phabricator instance.

[lld/mac] Set ordinal on dynamic undefined symbols in symbol table
ClosedPublic

Authored by thakis on Dec 15 2020, 10:40 AM.

Details

Summary

This lets nm -m print "(from libfoo)" in its output, which is more
accessible than dumping the bind table.

See https://reviews.llvm.org/D57190#2455761 for the somewhat
surprising AltEntry that appears in symtab.s.

Diff Detail

Event Timeline

thakis requested review of this revision.Dec 15 2020, 10:40 AM
thakis created this revision.
int3 accepted this revision.Dec 15 2020, 11:10 AM
int3 added a subscriber: int3.

lgtm

lld/MachO/SyntheticSections.cpp
757–759

why not just pass nList->n_desc into SET_LIBRARY_ORDINAL? I suppose this is a bit more explicit about the fact that we're modifying n_desc, but I think it's already pretty obvious from the SET_ in the name...

This revision is now accepted and ready to land.Dec 15 2020, 11:10 AM

Thanks!

lld/MachO/SyntheticSections.cpp
757–759

Because SET_LIBRARY_ORDINAL wants a uint16_t& but nList->n_desc is a llvm::support::ulittle16_t. I suppose we could templatize SET_LIBRARY_ORDINAL instead, but I could see us wanting to reaad n_desk once at the top of the loop, then modify it in the body, and then write it once at the end anyways, so that's a step in that direction.

Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2020, 11:40 AM
thakis edited the summary of this revision. (Show Details)Dec 15 2020, 11:46 AM