From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15224 invoked by alias); 15 May 2008 00:54:17 -0000 Received: (qmail 15215 invoked by uid 22791); 15 May 2008 00:54:16 -0000 X-Spam-Check-By: sourceware.org Received: from nskntmtas05p.mx.bigpond.com (HELO nskntmtas05p.mx.bigpond.com) (61.9.168.149) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 15 May 2008 00:53:56 +0000 Received: from nskntotgx01p.mx.bigpond.com ([58.174.193.185]) by nskntmtas05p.mx.bigpond.com with ESMTP id <20080515005353.SVEB3571.nskntmtas05p.mx.bigpond.com@nskntotgx01p.mx.bigpond.com> for ; Thu, 15 May 2008 00:53:53 +0000 Received: from bubble.grove.modra.org ([58.174.193.185]) by nskntotgx01p.mx.bigpond.com with ESMTP id <20080515005352.RBHO14647.nskntotgx01p.mx.bigpond.com@bubble.grove.modra.org> for ; Thu, 15 May 2008 00:53:52 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 7498E2C8B47; Thu, 15 May 2008 10:23:52 +0930 (CST) Date: Thu, 15 May 2008 16:06:00 -0000 From: Alan Modra To: gdb-patches@sourceware.org Subject: dbxread.c warning fix Message-ID: <20080515005352.GC11328@bubble.grove.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i X-RPD-ScanID: Class unknown; VirusThreatLevel unknown, RefID str=0001.0A150202.482B89A1.0074,ss=1,fgs=0 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00459.txt.bz2 Some recent versions of gcc warn that passing nlist to set_namestring results in uninitialised memory access. The warning is correct since n_other isn't initialised and the whole struct is passed by copying to set_namestring. This belts and braces patch corrects INTERNALIZE_SYMBOL to init n_other, and changes set_namestring to take a pointer arg. OK to apply? * dbxread.c: Formatting. (INTERNALIZE_SYMBOL): Init n_other. (set_namestring): Take pointer to nlist arg rather than struct copy. Update all callers. Index: gdb/dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.95 diff -u -p -r1.95 dbxread.c --- gdb/dbxread.c 26 Mar 2008 14:53:28 -0000 1.95 +++ gdb/dbxread.c 15 May 2008 00:03:38 -0000 @@ -850,8 +850,9 @@ stabs_seek (int sym_offset) #define INTERNALIZE_SYMBOL(intern, extern, abfd) \ { \ - (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \ (intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx); \ + (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \ + (intern).n_other = 0; \ (intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc); \ if (bfd_get_sign_extend_vma (abfd)) \ (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value); \ @@ -959,20 +960,20 @@ make_cleanup_free_bincl_list (struct obj rather than abort the symbol reading or flood the user with messages. */ static char * -set_namestring (struct objfile *objfile, struct internal_nlist nlist) +set_namestring (struct objfile *objfile, const struct internal_nlist *nlist) { char *namestring; - if (((unsigned) nlist.n_strx + file_string_table_offset) >= - DBX_STRINGTAB_SIZE (objfile)) + if (((unsigned) nlist->n_strx + file_string_table_offset) + >= DBX_STRINGTAB_SIZE (objfile)) { complaint (&symfile_complaints, _("bad string table offset in symbol %d"), symnum); namestring = ""; } else - namestring = nlist.n_strx + file_string_table_offset + - DBX_STRINGTAB (objfile); + namestring = (nlist->n_strx + file_string_table_offset + + DBX_STRINGTAB (objfile)); return namestring; } @@ -1339,7 +1340,7 @@ read_dbx_symtab (struct objfile *objfile case N_ABS | N_EXT: record_it: - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); bss_ext_symbol: record_minimal_symbol (namestring, nlist.n_value, @@ -1360,7 +1361,7 @@ read_dbx_symtab (struct objfile *objfile case N_TEXT: nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); if ((namestring[0] == '-' && namestring[1] == 'l') || (namestring[(nsl = strlen (namestring)) - 1] == 'o' @@ -1402,7 +1403,7 @@ read_dbx_symtab (struct objfile *objfile CORE_ADDR reladdr; - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); if (target_lookup_symbol (namestring, &reladdr)) { continue; /* Error in lookup; ignore symbol for now. */ @@ -1511,7 +1512,7 @@ read_dbx_symtab (struct objfile *objfile /* End the current partial symtab and start a new one */ - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); /* Null name means end of .o file. Don't start a new one. */ if (*namestring == '\000') @@ -1555,7 +1556,7 @@ read_dbx_symtab (struct objfile *objfile need to save the string; it'll be around until read_dbx_symtab function returns */ - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); tmp_language = deduce_language_from_filename (namestring); /* Only change the psymtab's language if we've learned @@ -1589,7 +1590,7 @@ pos %d"), enum language tmp_language; /* Mark down an include file in the current psymtab */ - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); tmp_language = deduce_language_from_filename (namestring); /* Only change the psymtab's language if we've learned @@ -1633,8 +1634,7 @@ pos %d"), char **orig = psymtab_include_list; psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * - sizeof (char *)); + alloca ((includes_allocated *= 2) * sizeof (char *)); memcpy (psymtab_include_list, orig, includes_used * sizeof (char *)); } @@ -1660,7 +1660,7 @@ pos %d"), { char *p; - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); /* See if this is an end of function stab. */ if (pst && nlist.n_type == N_FUN && *namestring == '\000') @@ -2015,7 +2015,7 @@ pos %d"), case N_EXCL: - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); /* Find the corresponding bincl and mark that psymtab on the psymtab dependency list */ @@ -2292,7 +2292,7 @@ end_psymtab (struct partial_symtab *pst, { pst->dependencies = (struct partial_symtab **) obstack_alloc (&objfile->objfile_obstack, - number_dependencies * sizeof (struct partial_symtab *)); + number_dependencies * sizeof (struct partial_symtab *)); memcpy (pst->dependencies, dependency_list, number_dependencies * sizeof (struct partial_symtab *)); } @@ -2530,7 +2530,7 @@ read_ofile_symtab (struct partial_symtab INTERNALIZE_SYMBOL (nlist, bufp, abfd); OBJSTAT (objfile, n_stabs++); - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); processing_gcc_compilation = 0; if (nlist.n_type == N_TEXT) @@ -2592,7 +2592,7 @@ read_ofile_symtab (struct partial_symtab type = bfd_h_get_8 (abfd, bufp->e_type); - namestring = set_namestring (objfile, nlist); + namestring = set_namestring (objfile, &nlist); if (type & N_STAB) { -- Alan Modra Australia Development Lab, IBM