diff options
author | Lulu Cai <cailulu@loongson.cn> | 2025-01-31 10:37:00 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2025-01-31 10:37:00 +0000 |
commit | 21980e5a6c2a4875c585bf5724e2cc4bb3f4d7f7 (patch) | |
tree | 1a929455d505161a734230c20f9c0ebb2d39434a | |
parent | 61dfe866790f0b3a757782240369db29dfe1ac7b (diff) | |
download | binutils-binutils-2_44-branch.zip binutils-binutils-2_44-branch.tar.gz binutils-binutils-2_44-branch.tar.bz2 |
LoongArch: Do not relax against __[start|stop]_SECNAME symbolbinutils-2_44-branch
-rw-r--r-- | bfd/elfnn-loongarch.c | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/relax.exp | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/start_stop.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/start_stop.s | 10 |
5 files changed, 31 insertions, 1 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index fc1cbbe..a04f00d 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -5634,10 +5634,13 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec, } else { + /* Do not relax __[start|stop]_SECNAME, since the symbol value + is not set yet. */ if (h != NULL && ((h->type == STT_GNU_IFUNC && r_type != R_LARCH_CALL36) - || bfd_is_abs_section (h->root.u.def.section))) + || bfd_is_abs_section (h->root.u.def.section) + || h->start_stop)) continue; /* The GOT entry of tls symbols must in current execute file or diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp index 0295be8..7e5fdfa 100644 --- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp +++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp @@ -154,6 +154,7 @@ if [istarget "loongarch64-*-*"] { ] \ ] + if [check_pie_support] { # Using DESC and IE to access the same tls symbol but with # -mno-relax requires allocating GOT entries for both DESC and IE, # not just IE @@ -169,6 +170,7 @@ if [istarget "loongarch64-*-*"] { "desc-ie-norelax" \ ] \ ] \ + } } if [istarget "loongarch64-*-*"] { diff --git a/ld/testsuite/ld-loongarch-elf/relax.exp b/ld/testsuite/ld-loongarch-elf/relax.exp index 81924cd..98504cf 100644 --- a/ld/testsuite/ld-loongarch-elf/relax.exp +++ b/ld/testsuite/ld-loongarch-elf/relax.exp @@ -412,6 +412,8 @@ if [istarget loongarch64-*-*] { "relax-segment-max" \ ] \ ] + + run_dump_test "start_stop" } run_ld_link_tests \ diff --git a/ld/testsuite/ld-loongarch-elf/start_stop.d b/ld/testsuite/ld-loongarch-elf/start_stop.d new file mode 100644 index 0000000..b887dcc --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/start_stop.d @@ -0,0 +1,13 @@ +#ld: -z norelro -pie -e0 +#objdump: -d + +.*: file format .* + + +Disassembly of section sec1: + +[0-9a-f]+ <_start>: + [0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .* + [0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .* + [0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .* + [0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .* diff --git a/ld/testsuite/ld-loongarch-elf/start_stop.s b/ld/testsuite/ld-loongarch-elf/start_stop.s new file mode 100644 index 0000000..f50bc60 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/start_stop.s @@ -0,0 +1,10 @@ + .section sec1,"ax",@progbits + .globl _start + .type _start, @function +_start: + la.got $a0,__start_sec1 + la.got $a0,__stop_sec1 + .size _start, .-_start + + .hidden __start_sec1 + .hidden __stop_sec1 |