[llvm] MC: Refine ALIGN relocation conditions (PR #150816)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 29 09:48:32 PDT 2025
lenary wrote:
> @SixWeining reminded me that we have a large problem when mixing -mrelax and -mno-relax object files in relocatable links (-r). Since we don't generate ALIGN relocations for the -mno-relax relocatable files, their alignment can be lost. Since we can use a linker script with relocatable links, we should either force ALIGN for all text sections regardless of -mrelax or make linker synthesize ALIGN relocations at input section starts.
>
> ```shell
> cat > x0.s <<e
> .globl _start
> _start:
> call foo
> e
> cat > x1.s <<e
> .option push
> .option norelax
> .balign 8
> l2:
> .word 0x12345678
> .option pop
>
> .section .text1,"ax"
> .globl foo
> foo:
> e
> clang --target=riscv64 -mrelax -c x0.s x1.s
> ld.lld -r x0.o x1.o -o x01.o
> ld.lld x01.o -o x01
> ```
I think "make linker synthesize ALIGN relocations at input section starts" would be my preference, otherwise `-mno-relax` objects will require relaxation support in the linker, which seems a bit odd (yes most linkers have support right now, but it still feels strange to require it)
https://github.com/llvm/llvm-project/pull/150816
More information about the llvm-commits
mailing list