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

    <tr>
        <th>Summary</th>
        <td>
            (MachO/Darwin) llvm-objcopy processed BSD ar archive seems broken for LLDB debugger
        </td>
    </tr>

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

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

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

<pre>
    Platform: macOS 12.4 / Darwin
LLVM Version: 13

### Issue description

`llvm-objcopy` can use without any args. I just use that to strip some sections if need. However, when I just use the command below

```
llvm-objcopy input.a output.a
```

When use the output.a as a debug OSO on Darwin platform, the LLDB debugger seems can no longer parse the current ar archive format.

### Screenshot

See the comparation, the `ar(1)` command can succeesfully extract the object files.

![image](https://user-images.githubusercontent.com/6919743/186148419-c644e749-a8d0-4a64-a3bc-f89d6ed38f08.png)

However, seems LLDB can no longer extract the processed one.

The code in [ObjectContainerBSDArchive.cpp](https://lldb.llvm.org/cpp_reference/ObjectContainerBSDArchive_8cpp.html) shows that there are only 2 object in the archive.

```
Printing description of this->m_objects:
(std::vector<ObjectContainerBSDArchive::Object, std::allocator<ObjectContainerBSDArchive::Object> >) m_objects = size=3 {
  [0] = {
    ar_name = (m_string = "__.SYMDEF")
    modification_time = 0
    uid = 0
    gid = 0
    mode = 0
    size = 1948
    file_offset = 80
    file_size = 1936
  }
  [1] = {
    ar_name = (m_string = "AppDelegate.o")
    modification_time = 0
    uid = 0
    gid = 0
    mode = 420
    size = 103812
    file_offset = 2096
    file_size = 103792
  }
  [2] = {
    ar_name = (m_string = "AwemeMain.o")
    modification_time = 0
    uid = 0
    gid = 0
    mode = 420
    size = 14229
    file_offset = 105960
    file_size = 14217
  }
}
```

### Comparation and attachment

[archive.zip](https://github.com/llvm/llvm-project/files/9402166/archive.zip)


origin one:

```
➜  test ar -tlv origin/libAwemeCore_lib.a
rw-r--r--       0/0          1936 Jan  1 08:00 1970 __.SYMDEF SORTED
rw-r--r--       0/0        103792 Jan  1 08:00 1970 AppDelegate.o
rw-r--r--       0/0         14224 Jan  1 08:00 1970 AwemeMain.o
rw-r--r--       0/0          6888 Jan  1 08:00 1970 DebugLog.o
rw-r--r--       0/0          2112 Jan  1 08:00 1970 AwemeCore.o
rw-r--r--       0/0         16040 Jan  1 08:00 1970 NSBundle+AwemeCore.o
rw-r--r--       0/0         15696 Jan  1 08:00 1970 AWEFriendsActivityWidgetConfigurationIntent.o
rw-r--r--       0/0          8048 Jan  1 08:00 1970 AWEFriendsActivityWidgetLandingPage.o
rw-r--r--       0/0          7896 Jan  1 08:00 1970 AWEFriendsWidgetsColorScheme.o
```

modified one(using `llvm-objcopy`):

```
➜  test ar -tlv modified/libAwemeCore_lib.a
rw-r--r--     501/20         1936 Aug 23 19:40 2022 __.SYMDEF SORTED
rw-r--r--       0/0        103792 Jan  1 08:00 1970 AppDelegate.o
rw-r--r--       0/0         14224 Jan  1 08:00 1970 AwemeMain.o
rw-r--r--       0/0          6888 Jan  1 08:00 1970 DebugLog.o
rw-r--r--       0/0          2112 Jan  1 08:00 1970 AwemeCore.o
rw-r--r--       0/0         16040 Jan  1 08:00 1970 NSBundle+AwemeCore.o
rw-r--r--       0/0         15696 Jan  1 08:00 1970 AWEFriendsActivityWidgetConfigurationIntent.o
rw-r--r--       0/0          8048 Jan  1 08:00 1970 AWEFriendsActivityWidgetLandingPage.o
rw-r--r--       0/0          7896 Jan  1 08:00 1970 AWEFriendsWidgetsColorScheme.o
```

Is this because of the llvm-objcopy does not run some of `runlib(1)` tool ? I'm not really familiar with these archive format details.

Anyone who works on either LLDB or llvm-objcopy can answer this question ?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWN1v2zYQ_2vkl4MF6sOy9OAHJ06wDMlSzEWLPRm0dJLZSqJHUvHSv75HyY5lV97cAsOAoYb8QfJ4vPvdB--8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