diff options
author | Jan Beulich <jbeulich@suse.com> | 2021-03-10 08:12:37 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2021-03-10 08:12:37 +0100 |
commit | 67b0f684803f5bec9b801c43fe1559bc88c15bb6 (patch) | |
tree | 6430680e12759db6270ac8b4ffde38bab1756605 /bfd | |
parent | 3044062c34f2372f4ecf81b69d9e63685cd5e995 (diff) | |
download | gdb-67b0f684803f5bec9b801c43fe1559bc88c15bb6.zip gdb-67b0f684803f5bec9b801c43fe1559bc88c15bb6.tar.gz gdb-67b0f684803f5bec9b801c43fe1559bc88c15bb6.tar.bz2 |
bfd: strip symbols not representable in COFF/PE symbol table
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/cofflink.c | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index fe38085..d3c1d40 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2021-03-10 Jan Beulich <jbeulich@suse.com> + + * cofflink.c (_bfd_coff_write_global_sym): Range-check symbol + offset. + 2021-03-10 Alan Modra <amodra@gmail.com> Jan Beulich <jbeulich@suse.com> diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 4b0aab2..874354a 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -2602,6 +2602,17 @@ _bfd_coff_write_global_sym (struct bfd_hash_entry *bh, void *data) + 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; |