From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7867) id 4F99138708DC; Tue, 4 Jun 2024 11:48:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F99138708DC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1717501686; bh=eU9iavZMeGdLg1ZEYM5vqDCDzlLCKUrW0+PUFkaXu1Y=; h=From:To:Subject:Date:From; b=k2CjWBQWSXJTqPGw6dQ3g46/hJqZ+IyUWBQbW//l1l9aCKu6UWFPEEeukyEOGljB0 JJqptC4PEf62IjDnde74v8CNOT+6fy1xQ+rQTzsqupoRgQh0kKfQnHzGIGZZPx84+E LklcdZzcH9yICFfoEDXRpOVU4RKLCd0OYRkmWbcA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: liu & zhensong To: binutils-cvs@sourceware.org Subject: [binutils-gdb] LoongArch: Disable linker relaxation if set the address of section or segment X-Act-Checkin: binutils-gdb X-Git-Author: mengqinggang X-Git-Refname: refs/heads/master X-Git-Oldrev: 5f4fa40e4def33ed428b2d72aeb2bf24b50a664e X-Git-Newrev: 07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d Message-Id: <20240604114806.4F99138708DC@sourceware.org> Date: Tue, 4 Jun 2024 11:48:06 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D07284e5ee02c= 51f3df2ea8fe2370ca3d1d42d84d commit 07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d Author: mengqinggang Date: Thu May 30 19:52:34 2024 +0800 LoongArch: Disable linker relaxation if set the address of section or s= egment =20 If set the address of section or segment, the offset from pc to symbol may become bigger and cause overflow. Diff: --- ld/emultempl/loongarchelf.em | 16 ++++++++++++++++ ld/testsuite/ld-loongarch-elf/relax-ttext.s | 13 +++++++++++++ ld/testsuite/ld-loongarch-elf/relax.exp | 12 ++++++++++++ 3 files changed, 41 insertions(+) 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 <=3D 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-loon= garch-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 =20 + 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 \