Currently, all data buffers are assumed to be writable. This is a problem on macOS where it's not allowed to load unsigned binaries in memory as writable. To be more precise, MAP_RESILIENT_CODESIGN and MAP_RESILIENT_MEDIA need to be set for mapped (unsigned) binaries on our platform.
Binaries are loaded through FileSystem::CreateDataBuffer which returns a DataBufferLLVM. The latter is backed by a llvm::WritableMemoryBuffer because every DataBuffer is considered to be writable. In order to use a read-only llvm::MemoryBuffer I had to split DataBuffer into DataBuffer (read-only) and WritableDataBuffer (read-write).
rdar://74890607
Are you sure this should be public?