Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demangle Swift support #16

Open
blacktop opened this issue Apr 1, 2022 · 7 comments
Open

demangle Swift support #16

blacktop opened this issue Apr 1, 2022 · 7 comments

Comments

@blacktop
Copy link

blacktop commented Apr 1, 2022

Would it be possible to add pure Go Swift demangle support?

@ianlancetaylor
Copy link
Owner

Where is SWIFT mangling documented? Thanks.

@blacktop
Copy link
Author

blacktop commented Apr 2, 2022

❯ cat greet.swift
func greet() {
  print("Hello World!")
}

greet()
❯ swiftc greet.swift # compile
❯ nm greet
0000000100003db4 t _$s5greetAAyyF
                 U _$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC
                 U _$sSSN
0000000100003f34 t _$sSa12_endMutationyyF
                 U _$sSaMa
                 U _$ss27_allocateUninitializedArrayySayxG_BptBwlF
0000000100003e80 t _$ss27_finalizeUninitializedArrayySayxGABnlF
                 U _$ss5print_9separator10terminatoryypd_S2StF
0000000100003edc t _$ss5print_9separator10terminatoryypd_S2StFfA0_
0000000100003f08 t _$ss5print_9separator10terminatoryypd_S2StFfA1_
                 U _$sypN
0000000100003fa0 s ___swift_reflection_version
0000000100000000 T __mh_execute_header
0000000100003d9c T _main
                 U _swift_bridgeObjectRelease
                 U _swift_bridgeObjectRetain
❯ nm greet | xcrun swift-demangle
0000000100003db4 t greet.greet() -> ()
                 U Swift.String.init(_builtinStringLiteral: Builtin.RawPointer, utf8CodeUnitCount: Builtin.Word, isASCII: Builtin.Int1) -> Swift.String
                 U type metadata for Swift.String
0000000100003f34 t Swift.Array._endMutation() -> ()
                 U type metadata accessor for Swift.Array
                 U Swift._allocateUninitializedArray<A>(Builtin.Word) -> ([A], Builtin.RawPointer)
0000000100003e80 t Swift._finalizeUninitializedArray<A>(__owned [A]) -> [A]
                 U Swift.print(_: Any..., separator: Swift.String, terminator: Swift.String) -> ()
0000000100003edc t default argument 1 of Swift.print(_: Any..., separator: Swift.String, terminator: Swift.String) -> ()
0000000100003f08 t default argument 2 of Swift.print(_: Any..., separator: Swift.String, terminator: Swift.String) -> ()
                 U type metadata for Any
0000000100003fa0 s ___swift_reflection_version
0000000100000000 T __mh_execute_header
0000000100003d9c T _main
                 U _swift_bridgeObjectRelease
                 U _swift_bridgeObjectRetain

@ianlancetaylor
Copy link
Owner

Thanks. That appears to be code that implements demangling. Is there any written documentation separate from code? For example, C++ mangling is defined at https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling.

@blacktop
Copy link
Author

blacktop commented Apr 3, 2022

@blacktop
Copy link
Author

Do you need any more info? Thanks!

@ianlancetaylor
Copy link
Owner

I'm sorry, I don't know when I'll have time to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants