From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH 6/6] bfd: strip symbols not representable in COFF/PE symbol table
Date: Tue, 2 Mar 2021 10:50:59 +0100 [thread overview]
Message-ID: <2a211c01-1509-4310-38b0-6997a20e5f01@suse.com> (raw)
In-Reply-To: <67c184ec-e370-46ee-46d3-bd001ef80445@suse.com>
The offset-within-section field in the symbol table entry is only 32
bits wide, so rather than emitting bogus entries omit them, and issue
a diagnostic identifying the issue.
This requires adjusting the PR/22267 test to no longer produce symbols
with out of range values on 64-bit BFD. This also depends on
adjustments to testsuite/ld-scripts/map-address.* made by an earlier
patch. The purpose of the test can very well be achieved nevertheless.
bfd/
2021-02-XX Jan Beulich <jbeulich@suse.com>
* cofflink.c (_bfd_coff_write_global_sym): Range-check symbol
offset.
ld/
2021-02-XX Jan Beulich <jbeulich@suse.com>
* testsuite/ld-scripts/pr22267.t: Avoid symbol value with more
than 32 set bits.
* testsuite/ld-scripts/pr22267.d: Adjust expectation and drop
comment.
---
RFC: There are likely more (target specific) testsuite changes needed,
as I've only run Cygwin and MingW target tests so far.
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -2602,6 +2602,16 @@ _bfd_coff_write_global_sym (struct bfd_h
+ h->root.u.def.section->output_offset);
if (! obj_pe (flaginfo->output_bfd))
isym.n_value += sec->vma;
+#ifdef BFD64
+ if (isym.n_value > (bfd_vma)0xffffffff)
+ {
+ if (! h->root.linker_def)
+ _bfd_error_handler
+ (_("%pB: stripping non-representable symbol '%s' (value %"BFD_VMA_FMT"x)"),
+ output_bfd, h->root.root.string, isym.n_value);
+ return TRUE;
+ }
+#endif
}
break;
--- a/ld/testsuite/ld-scripts/pr22267.d
+++ b/ld/testsuite/ld-scripts/pr22267.d
@@ -2,7 +2,6 @@
#nm: -n
#xfail: bfin-*-linux* frv-*-linux*
-# Some targets may zero-extend 32-bit address to 64 bits.
#...
-0*f+00 A foo
+0*ff A foo
#pass
--- a/ld/testsuite/ld-scripts/pr22267.t
+++ b/ld/testsuite/ld-scripts/pr22267.t
@@ -1,4 +1,4 @@
SECTIONS
{
- foo = ~0xFF;
+ foo = ~~0xFF;
}
next prev parent reply other threads:[~2021-03-02 9:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 9:46 [PATCH 0/6] PE/COFF linking adjustments Jan Beulich
2021-03-02 9:47 ` [PATCH 1/6] ld: don't generate base relocations in PE output for absolute symbols Jan Beulich
2021-03-02 13:30 ` Jan Beulich
2021-03-04 4:46 ` Alan Modra
2021-03-04 8:52 ` Jan Beulich
2021-03-04 13:16 ` Alan Modra
2021-03-05 12:49 ` Alan Modra
2021-03-05 13:38 ` Jan Beulich
2021-03-05 13:59 ` Alan Modra
2021-03-02 9:47 ` [PATCH 2/6] bfd: prune COFF/PE section flags setting Jan Beulich
2021-03-04 4:47 ` Alan Modra
2021-03-02 9:48 ` [PATCH 3/6] bfd: refine handling of relocations between debugging sections Jan Beulich
2021-03-04 6:10 ` Alan Modra
2021-03-04 9:00 ` Jan Beulich
2021-03-05 12:00 ` Alan Modra
2021-03-08 14:17 ` Jan Beulich
2021-03-09 2:24 ` Alan Modra
2021-03-09 7:46 ` Jan Beulich
2021-03-09 11:23 ` Alan Modra
2021-03-09 12:49 ` Jan Beulich
2021-03-02 9:49 ` [PATCH 4/6] ld: adjust ld-scripts/map-address.* Jan Beulich
2021-03-04 6:10 ` Alan Modra
2021-03-02 9:49 ` [PATCH 5/6] bfd: don't silently wrap or truncate PE image section RVAs Jan Beulich
2021-03-04 6:13 ` Alan Modra
2021-03-02 9:50 ` Jan Beulich [this message]
2021-03-04 6:15 ` [PATCH 6/6] bfd: strip symbols not representable in COFF/PE symbol table Alan Modra
2021-03-04 9:06 ` Jan Beulich
2021-03-04 13:27 ` Alan Modra
2021-03-08 15:05 ` Jan Beulich
2021-03-08 16:11 ` Jan Beulich
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=2a211c01-1509-4310-38b0-6997a20e5f01@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@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).