Skip to content

Commit 5df7ab8

Browse files
committed
[tools] Update how we encode AOT symbols according to upstream changes.
Ref: dotnet/runtime#101681.
1 parent 999a1d7 commit 5df7ab8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/common/Target.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,19 +933,26 @@ void GenerateIOSMain (StringWriter sw, Abi abi)
933933
sw.WriteLine ("}");
934934
}
935935

936+
static readonly char[] charsToReplaceAot = new[] { '.', '-', '+', '<', '>' };
936937
static string EncodeAotSymbol (string symbol)
937938
{
938939
var sb = new StringBuilder ();
939940
/* This mimics what the aot-compiler does */
941+
// https://github.com/dotnet/runtime/blob/2f08fcbfece0c09319f237a6aee6f74c4a9e14e8/src/mono/mono/metadata/native-library.c#L1265-L1284
942+
// https://github.com/dotnet/runtime/blob/2f08fcbfece0c09319f237a6aee6f74c4a9e14e8/src/tasks/Common/Utils.cs#L419-L445
940943
foreach (var b in System.Text.Encoding.UTF8.GetBytes (symbol)) {
941944
char c = (char) b;
942945
if ((c >= '0' && c <= '9') ||
943946
(c >= 'a' && c <= 'z') ||
944947
(c >= 'A' && c <= 'Z')) {
945948
sb.Append (c);
946949
continue;
950+
} else if (charsToReplaceAot.Contains (c)) {
951+
sb.Append ('_');
952+
} else {
953+
// Append the hex representation of b between underscores
954+
sb.Append ($"_{b:X}_");
947955
}
948-
sb.Append ('_');
949956
}
950957
return sb.ToString ();
951958
}

0 commit comments

Comments
 (0)