This patch allows symbols followed by an expression for an offset to be parsed as bare symbols.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Should this only support constant offsets to a symbol? It seems sensible to only support offsets to the symbol, IE add/sub rather than more complex expressions, but the RHS could be any expression at the moment.
Is this being used in the wild and does it work sensibly with binutils? I'm seeing that binutils seems to be associating the addend with both the emitted R_RISCV_PCREL_HI20 relocation and R_RISCV_RELAX relocation. Maybe this is just a binutils bug and the addend is ignored by the linker but this does seem surprising...
$ cat t.s lla a5, a_symbol + (0xFF << 3) $ ./riscv32-unknown-elf-as t.s $ ./riscv32-unknown-elf-readelf -r a.out Relocation section '.rela.text' at offset 0xec contains 4 entries: Offset Info Type Sym.Value Sym. Name + Addend 00000000 00000617 R_RISCV_PCREL_HI2 00000000 a_symbol + 7f8 00000000 00000033 R_RISCV_RELAX 7f8 00000004 00000418 R_RISCV_PCREL_LO1 00000000 .L0 + 0 00000004 00000033 R_RISCV_RELAX 0
Yes, FreeRTOS at least uses it, and we've had to manually patch the source to refer to just the bare symbol and follow it with an addi in order to support LLVM. The RELAX addend is probably a bug but I don't think it actually ever gets read.
@asb are we happy for this to land? You were happy with it without explicitly approving it.