diff options
-rw-r--r-- | build-aux/measurestack/analyze.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/build-aux/measurestack/analyze.py b/build-aux/measurestack/analyze.py index d4ca721..b7b8b08 100644 --- a/build-aux/measurestack/analyze.py +++ b/build-aux/measurestack/analyze.py @@ -172,27 +172,29 @@ re_node_label = re.compile( class _Graph: graph: dict[QName, Node] - qualified: dict[BaseName, set[QName]] + qualified: dict[BaseName, QName] def resolve_funcname(self, funcname: QName) -> QName | None: + s = str(funcname) + is_qualified = ":" in s + # Handle `ld --wrap` functions - if QName(f"__wrap_{str(funcname)}") in self.graph: - return QName(f"__wrap_{str(funcname)}") - if ( - str(funcname).startswith("__real_") - and QName(str(funcname)[len("__real_") :]) in self.graph - ): - funcname = QName(str(funcname)[len("__real_") :]) + if not is_qualified: + with_wrap = QName(f"__wrap_{s}") + if with_wrap in self.graph: + return with_wrap + if s.startswith("__real_"): + without_real = QName(s[len("__real_") :]) + if without_real in self.graph: + funcname = without_real # Usual case if funcname in self.graph: return funcname - # Handle `__weak` functions - if ":" not in str(funcname): - qnames = self.qualified.get(BaseName(str(funcname)), set()) - if len(qnames) == 1: - return next(name for name in qnames) + # Handle `__weak`/`[[gnu::weak]]` functions + if not is_qualified: + return self.qualified.get(BaseName(s)) return None @@ -279,7 +281,10 @@ def _make_graph( ret = _Graph() ret.graph = graph - ret.qualified = qualified + ret.qualified = {} + for bname, qnames in qualified.items(): + if len(qnames) == 1: + ret.qualified[bname] = next(name for name in qnames) return ret |