<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/130472>130472</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            llvm-objcopy regression: Invalid iOS Mach-O: __TEXT segment fileoffset is not zero
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          TimNN
      </td>
    </tr>
</table>

<pre>
    `llvm-objcopy good bad` on an iOS binary produces an output that it considered invalid by dyld.

`dyld_info bad` fails with:

```
bad [arm64]:
   __TEXT segment fileoffset is not zero
```

This regressed in https://github.com/llvm/llvm-project/pull/120995, identified by `git bisect` and verified by reverting https://github.com/llvm/llvm-project/commit/1a830aa1fe1e88749b563fefe18382842e0cff90. cc @drodriguez 

Steps to reproduce (sorry, don't have a version without Rust):

```shell
echo "fn main() {}" >> good.rs

# Rust version doesn't matter for this.
# Tested with the latest nightly & stable.
rustc --target=aarch64-apple-ios good.rs

llvm-objcopy good bad

# This is fine:
dyld_info good

# This fails:
dyld_info bad
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVMuO2zgQ_Br60rBBUQ9LBx08O2NgD5sAGx_2NqDEltQBRQpky4Hz9QvKzgSZ3UMGIPSgSsXq6oeOkUaH2IrySZTPO73y5EN7ofnTp13nza0VlbT2Ou9997X3yw1G7w102ohKgnegHdDnL9CR0-EGS_Bm7TGmbb_ysjLwpBmIofcuksGABshdtSUD3Q3MzZqDkKe0KpneXskN_scBgyYb4RvxJPLTG-yx5KnTBkT5pMNcFaJ8vmMA4PX18vLPBSKOMzqGgSz6YYjIQBGcZ_iOwb_jEvJ0mShCwDFgjJtMmJiXmGjVWajzSDyt3aH3s1DnZMrjtl-C_4o9C3VeVmuFOmdKNk0p1B9ABh3TQLiFKyo5EkNHMcErCdoZuGJ4AwS8YmBy48eP7v08U3rIdJ1LrbMBM6zrY9F0ZZUPOGBW57WqC4WyH4ZGHqDvQRTSBG8CjSt-h7sPXxiXCOwh4COhIFQdfQi3FJLxTqgjw6SvCDrJj-TdliW_Mvy9Rhaq-W_C4oTWCnnCfvIglBoczJqcULVQDYjjkzg-C6VA5C8if9kK7RDig0TlG_HbacZjvMuYNTMGGHwAnigeHugLRkazqQKeEKxmjAyOxontDYSqILLuLKYfwhq5h_2edRiRRf6sdeinqtjrZbG4Jx9_lfP_HfGmdCskijCQw7sPPys7od8htyp_j3sQ_jBvZ9rcNHmjd9hmxyIrZZ6V1W5qOynLrNPKqEZVla6rss7SRQ1YZlLWO2qVVKXMZSOrUuXVwcisarArKlkej7rPRSFx1mQPKaqDD-OOYlyxzXJZHNXO6g5t3AaEUg6_wfZVKJXmRWg3K7p1jKKQliLHnzRMbLH9xatHd5F3Ij_Bn49BkCbIX7qf9p_T7m91724Ntv1wj2zSY-qRe2zXVv0bAAD__9PBlmY">