1 Star 0 Fork 13

油屋/binutils-opencloudos

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LoongArch-TLS-IE-needs-only-one-dynamic-reloc.patch 8.21 KB
一键复制 编辑 原始数据 按行查看 历史
油屋 提交于 2024-11-07 15:00 +08:00 . sync from upstream
From 35938863d51f469f5bc715b3a7aa6f2a0eb150a6 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao <[email protected]>
Date: Wed, 19 Jun 2024 14:04:18 +0800
Subject: [PATCH 092/123] LoongArch: TLS IE needs only one dynamic reloc
As the comment in the code says, TLS_IE needs only one dynamic reloc.
But commit b67a17aa7c0c ("LoongArch: Fix the issue of excessive
relocation generated by GD and IE") has incorrectly allocated the space
for two dynamic relocs, causing libc.so to contain 8 R_LARCH_NONE.
Adjust tlsdesc-dso.d for the offset changes and add two tests to ensure
there are no R_LARCH_NONE with TLS.
Signed-off-by: Xi Ruoyao <[email protected]>
---
bfd/elfnn-loongarch.c | 2 +-
ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d | 9 ++
ld/testsuite/ld-loongarch-elf/desc-ie.d | 8 +-
.../ld-loongarch-elf/ld-loongarch-elf.exp | 2 +
.../ld-loongarch-elf/tlsdesc-dso-reloc.d | 9 ++
ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d | 86 +++++++++----------
6 files changed, 68 insertions(+), 48 deletions(-)
create mode 100644 ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d
create mode 100644 ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 9eaad7f4..51e3d311 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -1353,7 +1353,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
s->size += GOT_ENTRY_SIZE;
if (need_reloc)
- htab->elf.srelgot->size += 2 * sizeof (ElfNN_External_Rela);
+ htab->elf.srelgot->size += sizeof (ElfNN_External_Rela);
}
/* TLS_DESC needs one dynamic reloc and two GOT slot. */
diff --git a/ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d b/ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d
new file mode 100644
index 00000000..c7a2f8ed
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d
@@ -0,0 +1,9 @@
+#source: desc-ie.s
+#as:
+#ld: -shared -z norelro --hash-style=both
+#readelf: -Wr
+
+#failif
+#...
+.* +R_LARCH_NONE +.*
+#...
diff --git a/ld/testsuite/ld-loongarch-elf/desc-ie.d b/ld/testsuite/ld-loongarch-elf/desc-ie.d
index c833b233..0759404b 100644
--- a/ld/testsuite/ld-loongarch-elf/desc-ie.d
+++ b/ld/testsuite/ld-loongarch-elf/desc-ie.d
@@ -8,7 +8,7 @@
Disassembly of section .text:
[0-9a-f]+ <fn1>:
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, .*
- +[0-9a-f]+: 28cd0084 ld.d \$a0, \$a0, .*
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, .*
- +[0-9a-f]+: 28cd0084 ld.d \$a0, \$a0, .*
+ +[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/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index 3c8e9195..5d109a4d 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -130,7 +130,9 @@ if [istarget "loongarch64-*-*"] {
if [istarget "loongarch64-*-*"] {
if [check_shared_lib_support] {
run_dump_test "desc-ie"
+ run_dump_test "desc-ie-reloc"
run_dump_test "tlsdesc-dso"
+ run_dump_test "tlsdesc-dso-reloc"
run_dump_test "desc-norelax"
run_dump_test "desc-relax"
run_dump_test "data-got"
diff --git a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d
new file mode 100644
index 00000000..d5afa7c3
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d
@@ -0,0 +1,9 @@
+#source: tlsdesc-dso.s
+#as:
+#ld: -shared -z norelro --hash-style=both
+#readelf: -Wr
+
+#failif
+#...
+.* +R_LARCH_NONE +.*
+#...
diff --git a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d
index 8f66302f..d6997ec9 100644
--- a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d
+++ b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d
@@ -9,52 +9,52 @@
Disassembly of section .text:
[0-9a-f]+ <fun_gl1>:
- +[0-9a-f]+: 18021584 pcaddi \$a0, 4268
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dd4084 ld.d \$a0, \$a0, 1872
- +[0-9a-f]+: 18021364 pcaddi \$a0, 4251
- +[0-9a-f]+: 180213c4 pcaddi \$a0, 4254
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dc0084 ld.d \$a0, \$a0, 1792
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dc0084 ld.d \$a0, \$a0, 1792
- +[0-9a-f]+: 18021364 pcaddi \$a0, 4251
- +[0-9a-f]+: 180213c4 pcaddi \$a0, 4254
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dce084 ld.d \$a0, \$a0, 1848
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[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, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
[0-9a-f]+ <fun_lo>:
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28daa084 ld.d \$a0, \$a0, 1704
- +[0-9a-f]+: 18020de4 pcaddi \$a0, 4207
- +[0-9a-f]+: 18020f04 pcaddi \$a0, 4216
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 18020e24 pcaddi \$a0, 4209
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28db4084 ld.d \$a0, \$a0, 1744
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28db4084 ld.d \$a0, \$a0, 1744
- +[0-9a-f]+: 18020f44 pcaddi \$a0, 4218
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 18020e64 pcaddi \$a0, 4211
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dba084 ld.d \$a0, \$a0, 1768
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[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, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
[0-9a-f]+ <fun_external>:
- +[0-9a-f]+: 18020ec4 pcaddi \$a0, 4214
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
[0-9a-f]+ <fun_hidden>:
- +[0-9a-f]+: 18021224 pcaddi \$a0, 4241
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 18021144 pcaddi \$a0, 4234
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oil-house/binutils-opencloudos.git
[email protected]:oil-house/binutils-opencloudos.git
oil-house
binutils-opencloudos
binutils-opencloudos
master

搜索帮助