This is an archive of the discontinued LLVM Phabricator instance.

Make replaceSymbol a member function of Symbol.
ClosedPublic

Authored by ruiu on May 19 2019, 7:24 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.May 19 2019, 7:24 PM
MaskRay accepted this revision.May 19 2019, 7:33 PM
This revision is now accepted and ready to land.May 19 2019, 7:33 PM
MaskRay added inline comments.May 19 2019, 7:34 PM
lld/ELF/Symbols.h
434 ↗(On Diff #200197)

Consider renaming this since it is now a member function.

ruiu marked an inline comment as done.May 19 2019, 8:31 PM
ruiu added inline comments.
lld/ELF/Symbols.h
434 ↗(On Diff #200197)

I considered that but unfortunately we already have getSize function to return a size attribute of a symbol.

This revision was automatically updated to reflect the committed changes.
smeenai added inline comments.
lld/trunk/ELF/Symbols.h
86

Sorry for commenting on an old diff.

I'm trying to understand this comment and if it's still true. As far as I can tell, [replace()](https://github.com/llvm/llvm-project/blob/204d301bb1921431a853c0bfba32007c018df1d5/lld/ELF/Symbols.h#L529) is just doing a memcpy from the new symbol into the old symbol, and the binding field isn't restored afterwards, so replace will in fact overwrite the binding, right?

I imagine this comment is from a time when the behavior was different (particularly when SymbolBody used to be distinct from Symbol and the binding was part of Symbol and not SymbolBody), but it doesn't seem to be accurate anymore, as far as I can tell.

MaskRay added inline comments.Oct 7 2021, 2:24 PM
lld/trunk/ELF/Symbols.h
86

This is not overwritten by replace() is indeed misleading. replace overrides the binding. The only weird place is undefined weak + un-extracted archive member which is represented as a weak lazy symbol which is considered isUndefWeak.

An undefined weak is still weak when it resolves to a shared library. is normal rule which probably doesn't deserve a dedicated comment here.