]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
BFD: Fix the bug of R_LARCH_AGLIN caused by discard section
authormengqinggang <mengqinggang@loongson.cn>
Wed, 24 Jan 2024 06:34:26 +0000 (14:34 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Sun, 31 Mar 2024 06:21:00 +0000 (14:21 +0800)
commitdaeda14191c1710ce967259a47ef4e0a3fb6eebf
treed812149875b5903fde600bb0e71a17f112b81df2
parentc7a5bea4c62f286df830418de694821c7617cccd
BFD: Fix the bug of R_LARCH_AGLIN caused by discard section

To represent the first and third expression of .align, R_LARCH_ALIGN need to
associate with a symbol. We define a local symbol for R_LARCH_AGLIN.
But if the section of the local symbol is discarded, it may result in
a undefined symbol error.

Instead, we use the section name symbols, and this does not need to
add extra symbols.

During partial linking (ld -r), if the symbol associated with a relocation is
STT_SECTION type, the addend of relocation needs to add the section output
offset. We prevent it for R_LARCH_ALIGN.

The elf_backend_data.rela_normal only can set all relocations of a target to
rela_normal. Add a new function is_rela_normal to elf_backend_data, it can
set part of relocations to rela_normal.
bfd/elf-bfd.h
bfd/elflink.c
bfd/elfnn-loongarch.c
bfd/elfxx-target.h
gas/config/tc-loongarch.c
gas/testsuite/gas/loongarch/relax_align.d
ld/testsuite/ld-loongarch-elf/relax-align-discard.lds [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax-align-discard.s [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/relax.exp