<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74081>74081</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] Cannot generate RISCV executable binary from RISCV assembly code with Clang/LLVM
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Alexix24
</td>
</tr>
</table>
<pre>
Hi,
I'm trying to generate an executable riscv binary (kernel.bin) from a riscv assembly code (kernel.s).
- Using the riscv-none-embed-gcc toolchain, the binary is succesfully generated and I can run it on my device:
```sh
riscv-none-embed-as kernel.s -o kernel.o
riscv-none-embed-ld kernel.o -o kernel.elf
riscv-none-embed-objcopy -O binary kernel.elf kernel.bin
```
- But when I try to do the same process with Clang/LLVM (v17.0.5), the binary is not executed on my device:
```sh
clang -c -target riscv32 -march=rv32ia kernel.s -o kernel.elf
llvm-objcopy kernel.elf -O binary kernel.bin
```
Maybe I'm using the wrong Clang/LLVM commands, or with the wrong arguments? I see that the two .elf files are different.
Thanks !
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlE9vozoUxT-N2VyBwIQSFizaRNGL1OpJ78107z8XcGvsyDZJ-fYjIE0TZTrSSFESyQfu8e8eHea9ag1iTYonUmwjNoTOuvpR44f6oKuIWznW_yhCNyTdkvRxT2jZQ3CjMi0ECy0adCwgMAP4gWIIjGsEp7w4AleGuREIXb-jM6gTrgyhFTTO9sDOIuY99lyPIKzEK60ntEpgmbp8x_DTz2O784DYWIMx9hxl3AoBwVotOjYN2cyqswHlwQ9CoG8GrceLZwnMSNiDYAbcYEAFsAb6ESQelUCSn-eSh3T5-O7azp0F5uHTO8T287_9Rq3lRXGlRt18o7f8TdjDCPG_n9f6egSu-F45vBi_pfg0BDh1aGA_LXLaorQzLs96hIOzAr2HkwodbDQzLaG75-fXl2k3x6xM0qQgtLpHbGw4RwDlX4EU0xCIBcSBuRbDstycQtwzJzqSb90xp4r9ju6Fl9bH_sLoiswdrj8zemEjR1hSPlzSdnLWtLcwhO17ZqSfOFi30PqSMtcOPZrgSb6DPXhECB0LsyKcLMzWGqXRA3MIUjUNOjThNvA_OmbePRCaRbLOZZVXLMI6K9NslVdllkddXRYpbyrKKyy4rJq8aNKS5wUvGEVZUYxUTVOaZzTNslW6puuEr7NyTaV4KJp1I0tOVin2TOlkIphY10bK-wHrcpWus0gzjtrP7UCpWADQqShcPRPnQ-vJKtXKB__1hqCCnivlv_3_m1dSbGHDzJSPS13MB9eNcV7SXA3L4W0x3MUxGpyuuxAOfsoX3RG6a1XoBp4I2xO6m8ycf-KDs28oAqG7-W6e0N18vV8BAAD__3QbmZU">