From: Hui Li <lihui@loongson.cn>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb/elfread.c: Add plt symbol check for _PROCEDURE_LINKAGE_TABLE_
Date: Thu, 23 Mar 2023 15:59:08 +0800 [thread overview]
Message-ID: <20230323075908.23013-1-lihui@loongson.cn> (raw)
In the current code, when execute the following test on LoongArch:
$ make check-gdb TESTS="gdb.base/gnu-ifunc.exp"
=== gdb Summary ===
# of expected passes 111
# of unexpected failures 62
This is because some architectures such as LoongArch define the symbol
_PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section. Add plt
symbol check for _PROCEDURE_LINKAGE_TABLE_ to improved the judgment of
plt symbol and to get correct target function address of STT_GNU_IFUNC.
```
loongson@bogon:~$ cat test.c
int main(int argc, char const *argv[])
{
printf("hello world\n");
return 0;
}
loongson@bogon:~$ gcc test.c -o test
loongson@bogon:~$ objdump -d test
test: file format elf64-loongarch
Disassembly of section .plt:
0000000120004000 <_PROCEDURE_LINKAGE_TABLE_>:
120004000: 8e 01 00 1c ad bd 11 00 cf 01 c0 28 ad 51 ff 02 ...........(.Q..
120004010: cc 01 c0 02 ad 05 45 00 8c 21 c0 28 e0 01 00 4c ......E..!.(...L
0000000120004020 <__libc_start_main@plt>:
120004020: 1c00018f pcaddu12i $t3, 12(0xc)
120004024: 28ffc1ef ld.d $t3, $t3, -16(0xff0)
120004028: 4c0001ed jirl $t1, $t3, 0
12000402c: 03400000 andi $zero, $zero, 0x0
0000000120004030 <abort@plt>:
120004030: 1c00018f pcaddu12i $t3, 12(0xc)
120004034: 28ffa1ef ld.d $t3, $t3, -24(0xfe8)
120004038: 4c0001ed jirl $t1, $t3, 0
12000403c: 03400000 andi $zero, $zero, 0x0
0000000120004040 <puts@plt>:
120004040: 1c00018f pcaddu12i $t3, 12(0xc)
120004044: 28ff81ef ld.d $t3, $t3, -32(0xfe0)
120004048: 4c0001ed jirl $t1, $t3, 0
12000404c: 03400000 andi $zero, $zero, 0x0
...
```
With this patch:
$ make check-gdb TESTS="gdb.base/gnu-ifunc.exp"
=== gdb Summary ===
#of expected passes 173
Signed-off-by: Hui Li <lihui@loongson.cn>
---
gdb/elfread.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/elfread.c b/gdb/elfread.c
index b414da9ed21..1e606783c33 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -722,6 +722,9 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr)
if (len > 4 && strcmp (target_name + len - 4, "@plt") == 0)
return 0;
+ if (strcmp (target_name, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+ return 0;
+
htab = elf_objfile_gnu_ifunc_cache_data.get (objfile);
if (htab == NULL)
{
--
2.38.1
next reply other threads:[~2023-03-23 7:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 7:59 Hui Li [this message]
2023-03-24 16:16 ` Tom Tromey
2023-03-27 9:39 ` Hui Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230323075908.23013-1-lihui@loongson.cn \
--to=lihui@loongson.cn \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).