<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Binaries generated with objcopy don't work correctly"
   href="https://bugs.llvm.org/show_bug.cgi?id=47563">47563</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Binaries generated with objcopy don't work correctly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>llvm-objcopy/strip
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alistair@alistair23.me
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>alexander.v.shaposhnikov@gmail.com, jake.h.ehrlich@gmail.com, jh7370.2008@my.bristol.ac.uk, llvm-bugs@lists.llvm.org, rupprecht@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When generating a Tock binary for RV32 with objcopy the LLVM version of objcopy
doesn't work.

Unfortunately I don't have a lot more information then that. The produced
binary fails to run when generated with LLVM objcopy. When generating the
binary with LLVM objcopy the OpenTitan boot ROM fails to load the binary with
this error:

```
E01067 bootstrap.c:146] Bootstrap error: 0xc
E01068 boot_rom.c:39] Bootstrap failed with status code: 12
I01069 test_status.c:31] FAIL!
```

To reproduce the binaries, follow these steps. Two objcopy calls are required.

The first objcopy always uses the GCC version, as LLVM doesn't have
`--update-section` support.

```
riscv64-elf-objcopy --update-section .apps=rv32imc.tbf
target/riscv32imc-unknown-none-elf/release/opentitan.target/riscv32imc-unknown-none-elf/release/opentitan-app.elf
```

```
riscv64-elf-objcopy --version
GNU objcopy (GNU Binutils) 2.34
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
```

The next step is done with both GCC and LLVM versions. The GCC one runs on the
target correctly, while the LLVM version doesn't.

```
riscv64-elf-objcopy --output-target=binary
target/riscv32imc-unknown-none-elf/release/opentitan-app.elf
target/riscv32imc-unknown-none-elf/release/opentitan-app.bin
```

```
llvm-objcopy --output-target=binary
target/riscv32imc-unknown-none-elf/release/opentitan-app.elf
target/riscv32imc-unknown-none-elf/release/opentitan-app.bin
```

```
llvm-objcopy --version
llvm-objcopy, compatible with GNU objcopy
LLVM (<a href="http://llvm.org/">http://llvm.org/</a>):
  LLVM version 10.0.1-rust-1.45.0-nightly
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake-avx512
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>