On macOS, the read and pread calls return EINVAL when the number of bytes exceeds INT32_MAX: https://github.com/apple/darwin-xnu/blob/a449c6a3b8014d9406c2ddbdc81795da24aa7443/bsd/kern/sys_generic.c#L355
I found out when passing a 2.5G Mach-O to llvm-dwarfdump. Normally we would mmap the file, but this particular file happens to be the exact multiple of the page size (2628505600 bytes) in which case llvm prefers not to mmap (as to not waste a whole page for the terminating NULL byte).
rdar://68751407
Actually, is this also affected?