Open dramforever opened 1 year ago
I ended up filing this here rather than say binutils, because this feels like a specification oversight for me, rather than a problem with any particular assembler. It seems that the assembler is generating code/relaxation correctly as specified. Both binutils and llvm-as seems to behave this way.
That's nice. I hadn't noticed the pull request to psABI before, but it does seem that it would fix this for good.
This is critically important for cases of building jump or vector tables on 4-byte boundaries, where each table element must be the full (uncompressed) form of a 'j' instruction.
For the jump table case, you can also use .balign 4 on every entry. It’s annoying but is functionally correct.
@psherman42 My understanding is that if you also have .option norelax
in effect this would not be a problem.
Currently, even if
.option norvc
is in effect, the assembler still generates relaxable instructions andR_RISCV_RELAX
relocations, which may end up getting turned into compressed instructions by the linker anyway:If we assemble and link it:
The generated relaxations can be seen in the intermediate object file:
I'm not sure how big of a deal this is. It is certainly unexpected at first glance, but it this even worth doing anything about?
I'm also not sure whether to post it here or post it at https://github.com/riscv-non-isa/riscv-elf-psabi-doc (where linker relaxation is specified), but my idea is that this kind of temporary
.option norvc
is probably rare enough that this case might not be worth the trouble getting the linker to handle this.