]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
LoongArch: Fix relaxation alignment with ld -r (PR 33236)
authormengqinggang <mengqinggang@loongson.cn>
Fri, 22 May 2026 01:38:49 +0000 (09:38 +0800)
committermengqinggang <mengqinggang@loongson.cn>
Sun, 5 Jul 2026 18:26:54 +0000 (02:26 +0800)
commit8bf4b69718d406abc99dd9cdc4c9cef79d7344cf
tree3e39d74192333fd811653acb41b752690793fead
parent7858cadd335b3ffbc8e0250c0c180253d9f09489
LoongArch: Fix relaxation alignment with ld -r (PR 33236)

LoongArch has the same issue as RISC-V for PR 33236 [1].

Section alignment can't be adjusted for objects generated by ld -r.
If previous sections are relaxed, the subsequent section maybe misaligned.

To fix this, add an align section and an align relocation before each
section when ld -r. And change the section alignment to 4 to disable
the default section start address calculation.

ld.lld has fixed this issue in the following two patches [2] [3].

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=33236
[2] https://github.com/llvm/llvm-project/pull/151639
[3] https://github.com/llvm/llvm-project/pull/198147
bfd/elfnn-loongarch.c
bfd/elfxx-loongarch.h
ld/emultempl/loongarchelf.em
ld/testsuite/ld-loongarch-elf/relax-align-ld-r.d [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax-align-ld-r.s [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax.exp