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

Which Apple Clang versions have a non-standard LLVM bitcode format? #7216

Open
RyanGlScott opened this issue Aug 14, 2023 · 0 comments
Open

Comments

@RyanGlScott
Copy link

I recently discovered that Apple Clang version 14.0.3 (clang-1403.0.22.14.1), which is shipped with recent versions of Xcode, uses a somewhat non-standard LLVM bitcode format when compared to the upstream Clang. This is because this pointer-authentication–related commit (which is exclusive to Apple LLVM) introduces a new record type into METADATA_DERIVED_TYPE, meaning that there are now 15 records instead of 14.

I maintain a library for parsing LLVM bitcode files, and this poses something of a challenge for us. By default, we try to match the conventions of the upstream LLVM, and upstream LLVM says that METADATA_DERIVED_TYPE shall have no more than 14 records. This assumption breaks when our library tries to load recent Apple Clang–compiled bitcode files that use pointer authentication, however. See this issue.

In order to handle this robustly, it would be helpful to know precisely which versions of Apple Clang diverge from the upstream LLVM bitcode format so that we can handle things accordingly in our library. Here is what I know:

  • This commit, which introduces the 15th record type in METADATA_DERIVED_TYPE, is present in Apple Clang 14.
  • However, it's not clear to me if this is the only major Apple Clang release in which the two bitcode formats diverge. There are several git tags of the form swift-DEVELOPMENT-SNAPSHOT-yyyy-mm-dd-a associated with that commit, but that doesn't make it clear if they correspond to particular Clang releases.
  • Moreover, the pointer authentication–related record type was actually introduced in an earlier commit here, which uses 14 records instead of 15 records for METADATA_DERIVED_TYPE. I am guessing that this commit predates the upstream LLVM 14 release, which added another record type to bring the upstream total to 14. However, it's not clear to me if this commit ever made it into a released version of Apple Clang. If it did, this would mean that the metadata record associated with pointer authentication would be different depending on which Apple Clang version was used!
  • Going forward, will Apple Clang guarantee that METADATA_DERIVED_TYPE's record for pointer authentication will always be in the same record type, or could this change?
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

1 participant