Skip to content

Commit

Permalink
Fix #23110 - Improve the swift demangler to handle more constructions…
Browse files Browse the repository at this point in the history
… ##bin

* s9CryptoKit8Curve448O7SigningO9PublicKeyV16isValidSignature_3forSbx_q_t10Foundation12DataProtocolRzAjKR_r0_lF
* s9CryptoKit8Curve448O7SigningO9PublicKeyV17rawRepresentation10Foundation4DataVvg
* s9CryptoKit8Curve448O7SigningO10PrivateKeyV06publicF0AE06PublicF0VvpMV
* ...
  • Loading branch information
radare committed Jul 17, 2024
1 parent 8a58808 commit 8427cd5
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion libr/bin/mangling/swift-sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,44 @@ static char *my_swift_demangler(const char *s) {
break;
case 'V':
p = resolve (types, q + 1, &attr); // type
if (!p) {
int n = 0;
repeat:;
const char *Q = getnum (q + 1, &n);
const char *res = getstring (Q, n);
if (res) {
r_strbuf_append (out, ".");
r_strbuf_append (out, res);
}
q = Q + n;
if (q >= q_end) {
eprintf ("end\n");
continue;
}
if (!isdigit (*q)) {
while (*q) {
if (isdigit (*q)) {
break;
}
q++;
}
}
if (isdigit (*q)) {
q--;
goto repeat;
#if 0
int n = 0;
const char *Q = getnum (q, &n);
const char *res = getstring (Q, n);
if (res) {
r_strbuf_append (out, ".");
r_strbuf_append (out, res);
}
q = Q + n;
#endif
}
}
q++;
break;
case '_':
// it's return value time!
Expand Down Expand Up @@ -887,7 +925,8 @@ R_API char *r_bin_demangle_swift(const char *s, bool syscmd, bool trylib) {
}
break;
}
return NULL;
s--;
// return NULL;
}
} else {
// TIFF ones found on COFF binaries, swift-unrelated, return early to avoid FP
Expand Down

0 comments on commit 8427cd5

Please # to comment.