From: mengqinggang Date: Thu, 30 May 2024 11:52:34 +0000 (+0800) Subject: LoongArch: Disable linker relaxation if set the address of section or segment X-Git-Tag: binutils-2_43~554 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d;p=thirdparty%2Fbinutils-gdb.git LoongArch: Disable linker relaxation if set the address of section or segment If set the address of section or segment, the offset from pc to symbol may become bigger and cause overflow. --- diff --git a/ld/emultempl/loongarchelf.em b/ld/emultempl/loongarchelf.em index 3bb5ddf0db4..2da40582008 100644 --- a/ld/emultempl/loongarchelf.em +++ b/ld/emultempl/loongarchelf.em @@ -25,6 +25,22 @@ fragment <= 0x200000, overflow +.text +.align 14 # delete at relax pass 1 +.fill 0x4000 +.align 14 # delete at relax pass 1 +la.local $t2, a # relax to pcaddi at relax pass 0 + +.section ".text1", "ax" + .fill 0x4000 +a: # 0x120204000 + ret diff --git a/ld/testsuite/ld-loongarch-elf/relax.exp b/ld/testsuite/ld-loongarch-elf/relax.exp index 35caa73c11d..4771f1eb429 100644 --- a/ld/testsuite/ld-loongarch-elf/relax.exp +++ b/ld/testsuite/ld-loongarch-elf/relax.exp @@ -51,6 +51,18 @@ if [istarget loongarch64-*-*] { run_dump_test "relax-align-ignore-start" run_partial_linking_align_test + run_ld_link_tests \ + [list \ + [list \ + "loongarch relax ttext" \ + "" "" \ + "" \ + {relax-ttext.s} \ + {} \ + "relax-ttext" \ + ] \ + ] + set testname "loongarch relax .exe build" set pre_builds [list \ [list \