Avoid introducing unnecessary indirection for weak-external references.
We only need to introduce ".weak.<SYMBOL>.default" when referencing a
symbol that is defined, but not external.
Differential D88305
[COFF] Aliases resolve directly to defined external targets epastor on Sep 25 2020, 7:36 AM. Authored by
Details Avoid introducing unnecessary indirection for weak-external references. We only need to introduce ".weak.<SYMBOL>.default" when referencing a
Diff Detail
Event TimelineComment Actions This does seem to produce the right results for all the cases that I can come to think of right now, so I guess it's good, but I'd like to think about it for another day or two, if that's ok. Comment Actions I tested this with an input file like this here: .globl uniquename uniquename: ret .globl weakundef .globl func func: call weakundef ret .weak aliasname aliasname = func .weak secondalias secondalias = aliasname .weak weakundef .weak weakfunc .globl weakfunc weakfunc: ret .weak undefalias undefalias = undefsym Maybe it'd be good to add more testcases out of these, in addition to the one added here (with verbose comments in the testcase about what's tested and what the expected outcome is), if some of the cases aren't exercised by the current tests. At least the second-level alias and alias against an undefined symbol (undefalias) are untested I think, and I don't see a case that really matches the weakfunc case either - so it'd be good to have those covered as well.
Comment Actions I've added a new test file covering (I think) all of your proposed cases except the weakfunc case. That one, I added to the weak.s test file instead.
Comment Actions LGTM Awesome, thanks for finding all the relevant cases here. I've tested it with my own testsuite for GNU style weak symbols, and it seems to still be working.
|
Can you come up with a scenario where you hit this else/return nullptr? Because in all of my testcases, I either hit the "return GetOr...", or return early at the first check (!Symbol.isVariable()).
I.e. it's hard to get a feel for whether this is the right condition here, as long as one could just as well remove the if statement altogether.