aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-mcore.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-03-22 09:06:48 +1030
committerAlan Modra <amodra@gmail.com>2023-03-22 09:06:48 +1030
commit4d5b27b30b06cbe3fb8103a323c35970925ccffd (patch)
tree159a6eed042c6a04de3022b7d70a203cbe82cf65 /bfd/coff-mcore.c
parent317e47ee5e7c539807d6cd16bde5c274025e8ee1 (diff)
downloadgdb-4d5b27b30b06cbe3fb8103a323c35970925ccffd.zip
gdb-4d5b27b30b06cbe3fb8103a323c35970925ccffd.tar.gz
gdb-4d5b27b30b06cbe3fb8103a323c35970925ccffd.tar.bz2
Sanity check coff-sh and coff-mcore sym string offset
* coff-mcore.c (coff_mcore_relocate_section): Sanity check sym string offset when setting up name for use by error messages. * coff-sh.c (sh_relocate_section): Likewise.
Diffstat (limited to 'bfd/coff-mcore.c')
-rw-r--r--bfd/coff-mcore.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
index e360d5e..96a1c9d 100644
--- a/bfd/coff-mcore.c
+++ b/bfd/coff-mcore.c
@@ -434,7 +434,13 @@ coff_mcore_relocate_section (bfd * output_bfd,
my_name = "*unknown*";
else if ( sym->_n._n_n._n_zeroes == 0
&& sym->_n._n_n._n_offset != 0)
- my_name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
+ {
+ if (sym->_n._n_n._n_offset < obj_coff_strings_len (input_bfd))
+ my_name = (obj_coff_strings (input_bfd)
+ + sym->_n._n_n._n_offset);
+ else
+ my_name = "?";
+ }
else
{
strncpy (buf, sym->_n._n_name, SYMNMLEN);