[binutils-gdb] gas: Internal error in obj_elf_get_vtable_inherit

Alan Modra via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=09af9909dc8bd5b20bda5b0e34cb04c26f84c8f0

commit 09af9909dc8bd5b20bda5b0e34cb04c26f84c8f0
Author: Alan Modra <[email protected]>
Date:   Sat Mar 28 18:40:31 2026 +1030

    gas: Internal error in obj_elf_get_vtable_inherit
    
    oss-fuzz testcase:
    ""=x
    .vtable_inherit,
    
            * config/obj-elf.c (obj_elf_get_vtable_inherit): Replace
            gas_assert with equivalent check resulting in as_bad.

Diff:
---
 gas/config/obj-elf.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 5c44aea0914..f884e577554 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -1949,7 +1949,8 @@ obj_elf_get_vtable_inherit (void)
 {
   char *cname, *pname;
   symbolS *csym, *psym;
-  char c, bad = 0;
+  char c;
+  bool bad = false;
 
   if (*input_line_pointer == '#')
     ++input_line_pointer;
@@ -1961,11 +1962,13 @@ obj_elf_get_vtable_inherit (void)
      the same child symbol.  Also, we can currently only do this if the
      child symbol is already exists and is placed in a fragment.  */
 
-  if (csym == NULL || symbol_get_frag (csym) == NULL)
+  if (csym == NULL
+      || symbol_get_frag (csym) == NULL
+      || symbol_get_value_expression (csym)->X_op != O_constant)
     {
       as_bad (_("expected `%s' to have already been set for .vtable_inherit"),
 	      cname);
-      bad = 1;
+      bad = true;
     }
 
   restore_line_pointer (c);
@@ -2003,7 +2006,6 @@ obj_elf_get_vtable_inherit (void)
   if (bad)
     return NULL;
 
-  gas_assert (symbol_get_value_expression (csym)->X_op == O_constant);
   return fix_new (symbol_get_frag (csym),
 		  symbol_get_value_expression (csym)->X_add_number,
 		  0, psym, 0, 0, BFD_RELOC_VTABLE_INHERIT);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.