From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v4 2/3] scripts/localplt.awk: Handle DT_JMPREL with empty PLT (for C-SKY)
Date: Mon, 29 Aug 2022 14:26:57 +0200 [thread overview]
Message-ID: <b9db8689f75c8225800e006655764134e4185663.1661775887.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1661775887.git.fweimer@redhat.com>
On csky-linux-gnuabiv2, binutils 2.33 produces a DT_JMPREL entry
for the dynamic loader if it does not contain any PLT relocations:
Dynamic section at offset 0x1df48 contains 19 entries:
Tag Type Name/Value
0x0000000e (SONAME) Library soname: [ld-linux-cskyv2-hf.so.1]
0x00000004 (HASH) 0xd4
0x6ffffef5 (GNU_HASH) 0x1a8
0x00000005 (STRTAB) 0x4ac
0x00000006 (SYMTAB) 0x28c
0x0000000a (STRSZ) 527 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000003 (PLTGOT) 0x1f000
0x00000002 (PLTRELSZ) 0 (bytes)
0x00000014 (PLTREL) RELA
0x00000017 (JMPREL) 0xaa4
0x00000007 (RELA) 0x75c
0x00000008 (RELASZ) 840 (bytes)
0x00000009 (RELAENT) 12 (bytes)
0x6ffffffc (VERDEF) 0x700
0x6ffffffd (VERDEFNUM) 3
0x6ffffff0 (VERSYM) 0x6bc
0x6ffffff9 (RELACOUNT) 68
0x00000000 (NULL) 0x0
This confuses the script:
Unexpected output from check-localplt: …/elf/ld.so.jmprel:
*** DT_JMPREL does not match any section's address
This commit changes the script to record the DT_PLTRELSZ value and
reject DT_JMPREL values not a section boundary only if DT_PLTRELSZ
is present with a non-zero value.
---
scripts/localplt.awk | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/scripts/localplt.awk b/scripts/localplt.awk
index beaa342922..fe79ca01ab 100644
--- a/scripts/localplt.awk
+++ b/scripts/localplt.awk
@@ -4,17 +4,25 @@
# It writes "NAME: SYMBOL" for each PLT entry in NAME that refers to a
# symbol defined in the same object.
-BEGIN { result = 0 }
+BEGIN {
+ result = 0;
+ pltrelsize = -1;
+}
FILENAME != lastfile {
if (lastfile && jmprel_offset == 0 && rela_offset == 0 && rel_offset == 0) {
print FILENAME ": *** failed to find expected output (readelf -WSdr)";
result = 2;
}
+ if (pltrelsz > 0 && jmprel_offset == -1) {
+ print FILENAME ": Could not find section for DT_JMPREL";
+ result = 2;
+ }
lastfile = FILENAME;
jmprel_offset = 0;
rela_offset = 0;
rel_offset = 0;
+ pltrelsz = -1;
delete section_offset_by_address;
}
@@ -82,12 +90,16 @@ $2 == "(JMPREL)" {
if (jmprel_addr in section_offset_by_address) {
jmprel_offset = section_offset_by_address[jmprel_addr];
} else {
- print FILENAME ": *** DT_JMPREL does not match any section's address";
- result = 2;
+ jmprel_offset = -1
}
next
}
+$2 == "(PLTRELSZ)" {
+ pltrelsz = strtonum($3);
+ next
+}
+
$2 == "(RELA)" {
rela_addr = strtonum($3);
if (rela_addr in section_offset_by_address) {
--
2.37.2
next prev parent reply other threads:[~2022-08-29 12:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 12:26 [PATCH v4 0/3] Rework exception handling in the dynamic loader [BZ #25486] Florian Weimer
2022-08-29 12:26 ` [PATCH v4 1/3] ld.so: Export tls_init_tp_called as __rtld_tls_init_tp_called Florian Weimer
2022-10-26 20:34 ` Siddhesh Poyarekar
2022-08-29 12:26 ` Florian Weimer [this message]
2022-10-26 20:34 ` [PATCH v4 2/3] scripts/localplt.awk: Handle DT_JMPREL with empty PLT (for C-SKY) Siddhesh Poyarekar
2022-08-29 12:27 ` [PATCH v4 3/3] elf: Rework exception handling in the dynamic loader [BZ #25486] Florian Weimer
2022-10-26 20:34 ` Siddhesh Poyarekar
2022-10-27 9:46 ` Florian Weimer
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=b9db8689f75c8225800e006655764134e4185663.1661775887.git.fweimer@redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@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).