[PATCH] D145539: [llvm/Target] Add Windows COFF support for RISC-V

Philip Craig via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 8 03:39:24 PST 2023


philipc added a comment.

In D145539#4176834 <https://reviews.llvm.org/D145539#4176834>, @luojia wrote:

> If I am correct, PE/COFF specification has definitions of machine architecture in headers. In this part PE/COFF included RISC-V architecture types. It does not provide relocation types on RISC-V, so for now PE/COFF specification allows us to emit RISC-V COFF binaries without any relocations. This could be a use case for RISC-V UEFI applications where it's mainly statically linked without any relocations.

It's not true that the resulting UEFI application has no relocations. For example, when compiling to ELF and converting to PE/COFF, I had to convert a number of ELF relocations into PE base relocations: https://github.com/gimli-rs/object/blob/39e1bb37c613fd360a3b9b91c31d2d305945a5c4/crates/examples/src/bin/elftoefi.rs#L230-L268.

In D145539#4176837 <https://reviews.llvm.org/D145539#4176837>, @jrtc27 wrote:

> Well, you can't produce intermediate object files without relocations, and LLD can't read in an ELF and produce a PE/COFF, so I'm still not sure how static linking helps avoid the need for llvm-objcopy...

What they are trying to do is add a RISCV UEFI target to the rust compiler that compiles to COFF intermediate object files and links to a PE/COFF UEFI application, similar to existing x86 and aarch64 UEFI targets, but this can't currently work because it would require defining RISCV relocations for the COFF intermediate object files.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145539/new/

https://reviews.llvm.org/D145539



More information about the llvm-commits mailing list