Closed compnerd closed 3 years ago
I don't have a problem with this patch, but I also don't think this is the end of the story. LLVM's assembler seems deficient in this respect. It won't be able to assemble code emitted by GCC unless it fixes this limitation.
I'm afraid that you are correct about that. The LLVM assembler does need to be enhanced to support this relocation. In general, use of LLVM currently requires that you build your code with -mno-relax
, which has no impact on assembly though.
I'd argue GNU as is wrong here. If I write bltu
I should get bltu
not bgeu
+j
. RISC-V GNU as is the outlier here, on other architectures this kind of code is not accepted.
This is an equivalent rewrite of the existing code. When building with gas, the
bltu
would implicitly get relaxed to thebgeu
+j
. This relaxation is required as theinit_other_hart
is not guaranteed to be addressable in 12-bits. When building with the LLVM IAS instead of gas we fail to link as the branch is not relaxed. This change enables LLVM to build and link this code with the LLVM IAS and lld.