Skip to content

Commit 1dbe7eb

Browse files
committed
docs: attribute the vendored third-party code
src/smda/common/labelprovider/rust_demangler/ is vendored third-party code and carries no attribution. The commit that introduced it says so directly -- it vendors the rust_demangler package by Team bi0s, MIT licensed, with robustness behaviour reimplemented from Ghidra, which is Apache-2.0. Neither is recorded: LICENSE covers only this project's own BSD 2-Clause, there is no NOTICE, and the package has no header. The MIT licence asks that its copyright and permission notice travel with copies and substantial portions, and this code is redistributed in the wheel published to PyPI. Add a NOTICE carrying the MIT copyright line and permission text and a pointer to Apache-2.0 for the Ghidra-derived parts, a docstring on the vendored package pointing at it, and a line in the README credits. The in-code comments this attribution was drawn from named "Ghidra's rust-demangle.c", and no such file exists: Ghidra's Rust demanglers are Java, at Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/ analysis/rust/demangler/RustDemanglerV0.java and RustDemanglerLegacy.java. Name those instead, in the NOTICE and in the two comments that were the source of the error, and record that Ghidra's own V0 demangler is a port of the rustc-demangle crate, which is the real upstream of the behaviour. The NOTICE lists every vendored component rather than only the one that prompted it, so Tarjan.py and DominatorTree.py -- both already credited in the README paragraph the new line joins -- appear alongside it. No pyproject change is needed: setuptools' default license-file glob already matches NOTICE*, and a build confirms it reaches both the wheel (dist-info/licenses/NOTICE) and the sdist.
1 parent db88261 commit 1dbe7eb

5 files changed

Lines changed: 71 additions & 2 deletions

File tree

NOTICE

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
SMDA
2+
Copyright (c) 2018-2020, Daniel Plohmann and Steffen Enders
3+
4+
This product is licensed under the BSD 2-Clause License; see LICENSE.
5+
6+
It includes third-party code, listed below with the notices its license
7+
requires.
8+
9+
================================================================================
10+
rust_demangler
11+
--------------------------------------------------------------------------------
12+
src/smda/common/labelprovider/rust_demangler/ is derived from the rust_demangler
13+
package by Team bi0s (https://github.com/teambi0s/rust_demangler), used under the
14+
MIT License and modified for use here.
15+
16+
MIT License
17+
18+
Copyright (c) 2021 Team bi0s
19+
20+
Permission is hereby granted, free of charge, to any person obtaining a copy
21+
of this software and associated documentation files (the "Software"), to deal
22+
in the Software without restriction, including without limitation the rights
23+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24+
copies of the Software, and to permit persons to whom the Software is
25+
furnished to do so, subject to the following conditions:
26+
27+
The above copyright notice and this permission notice shall be included in all
28+
copies or substantial portions of the Software.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
SOFTWARE.
37+
38+
================================================================================
39+
Ghidra
40+
--------------------------------------------------------------------------------
41+
Parts of the same directory reimplement behaviour from Ghidra's Rust demanglers
42+
(https://github.com/NationalSecurityAgency/ghidra), specifically
43+
Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/
44+
RustDemanglerV0.java and RustDemanglerLegacy.java: the recursion bound in the v0
45+
demangler and the strict hash handling in the legacy demangler. Ghidra is
46+
licensed under the Apache License, Version 2.0, available at
47+
48+
http://www.apache.org/licenses/LICENSE-2.0
49+
50+
Ghidra's own V0 demangler is a port of the rustc-demangle crate
51+
(https://github.com/rust-lang/rustc-demangle), dual-licensed Apache-2.0 OR MIT.
52+
53+
================================================================================
54+
Tarjan's algorithm
55+
--------------------------------------------------------------------------------
56+
src/smda/common/Tarjan.py is based on the implementation by Bas Westerbaan
57+
(https://github.com/bwesterb/py-tarjan), refactored into a class for pooled
58+
computation.
59+
60+
================================================================================
61+
Lengauer-Tarjan dominator tree
62+
--------------------------------------------------------------------------------
63+
src/smda/common/DominatorTree.py is based on the implementation by Armin Rigo
64+
(https://bitbucket.org/arigo/arigo/src/default/hack/pypy-hack/heapstats/dominator.py).

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ Thanks to Jonathan Crussell for helping me to beef up SMDA enough to make it a d
197197
Thanks to Willi Ballenthin for improving the handling of ELF files, including properly handling API usage!
198198
Thanks to Daniel Enders for his contributions to the parsing of the Golang function registry and label information!
199199
The project uses the implementation of Tarjan's Algorithm by Bas Westerbaan and the implementation of Lengauer-Tarjan's Algorithm for the DominatorTree by Armin Rigo.
200+
Rust symbol demangling is derived from the rust_demangler package by Team bi0s (MIT), with behaviour reimplemented from Ghidra's Rust demanglers (Apache-2.0); see [NOTICE](NOTICE) for the full list of third-party components.
200201
Thanks to r0ny123 for his major code quality improvements via ruff and various contributions for several aspects of this project!
201202

202203
Pull requests welcome! :)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""Rust symbol demangling, derived from Team bi0s' rust_demangler (MIT) with
2+
behaviour reimplemented from Ghidra's Rust demanglers. See NOTICE.
3+
"""
4+
15
from .main import demangle
26

37
__all__ = ["demangle"]

src/smda/common/labelprovider/rust_demangler/rust_legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def is_ascii_punctuation(self, c):
146146
return c in string.punctuation
147147

148148
def is_rust_hash(self, s):
149-
# Improved robustness based on Ghidra's rust-demangle.c
149+
# Improved robustness based on Ghidra's RustDemanglerLegacy
150150
# Legacy Rust symbols end with a path segment that encodes a 16 hex digit hash,
151151
# prefixed with "17h", i.e. '17h[a-f0-9]{16}'.
152152
if len(s) == 19 and s.startswith("17h"):

src/smda/common/labelprovider/rust_demangler/rust_v0.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def skip_const(self):
490490

491491

492492
class Printer:
493-
# Based on Ghidra's rust-demangle.c, we limit recursion to prevent stack overflows
493+
# Following Ghidra's RustDemanglerV0, we limit recursion to prevent stack overflows
494494
# or excessive resource usage on malformed inputs.
495495
# Must fire well below CPython's own recursion limit (default 1000), or a
496496
# self-referential backref chain raises RecursionError before this guard.

0 commit comments

Comments
 (0)