We already support instrumentation based profiling, but some clients
like Rust still use GCDA so we need to support it as well.
This big chunk of platform specific code reduces readability. Perhaps wrap it into a helper function. You can even add new file and put all platform specific code in there (starting from Fuchia -- other platforms can follow later).
This looks ok to me. In the longer term, I think compiler-rt would benefit from borrowing/extending llvm's generic file interface to abstract over platform differences. It doesn't seem ideal to me that libprofile/xray etc. have lots of platform-specific file I/O code.