From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 442 invoked by alias); 26 Jul 2007 22:17:04 -0000 Received: (qmail 434 invoked by uid 22791); 26 Jul 2007 22:17:03 -0000 X-Spam-Check-By: sourceware.org Received: from b.mail.sonic.net (HELO b.mail.sonic.net) (64.142.19.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 26 Jul 2007 22:16:56 +0000 Received: from webmail.sonic.net (b.webmail.sonic.net [64.142.100.148]) by b.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id l6QMGjOJ029127 for ; Thu, 26 Jul 2007 15:16:45 -0700 Received: from 12.7.175.2 (SquirrelMail authenticated user msnyder) by webmail.sonic.net with HTTP; Thu, 26 Jul 2007 15:16:45 -0700 (PDT) Message-ID: <5873.12.7.175.2.1185488205.squirrel@webmail.sonic.net> In-Reply-To: <20070726140711.GN11649@bubble.grove.modra.org> References: <6375.12.7.175.2.1185415194.squirrel@webmail.sonic.net> <20070726140711.GN11649@bubble.grove.modra.org> Date: Thu, 26 Jul 2007 23:24:00 -0000 Subject: Re: [PATCH] linker.c, check for null return from bfd_hash_allocate From: msnyder@sonic.net To: binutils@sourceware.org User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070726151645_97487" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00472.txt.bz2 ------=_20070726151645_97487 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-length: 328 > The proper fix is to change bfd_section_already_linked_table_insert to > return a pass/fail status. Check the status in > _bfd_elf_section_already_linked, _bfd_generic_section_already_linked, > and on failure call info->einfo with a fatal error message. OK. How about the attached? > This part is OK. Committed, thanks. ------=_20070726151645_97487 Content-Type: text/plain; name="fatal.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="fatal.txt" Content-length: 6032 2007-07-26 Michael Snyder * linker.c (bfd_section_already_linked_table_insert): Change return type from void to boolean. Return FALSE on failure. (_bfd_generic_section_already_linked): Test return value of bfd_section_already_linked_table_insert, call fatal on error. * elflink.c (_bfd_elf_section_already_linked): Test return value of bfd_section_already_linked_table_insert, call fatal on error. * libbfd-in.h (bfd_section_already_linked_table_insert): Update return type to bfd_boolean. * libbfd.h: Regenerate. Index: linker.c =================================================================== RCS file: /cvs/src/src/bfd/linker.c,v retrieving revision 1.62 diff -p -r1.62 linker.c *** linker.c 26 Jul 2007 21:58:44 -0000 1.62 --- linker.c 26 Jul 2007 22:15:58 -0000 *************** bfd_section_already_linked_table_lookup *** 2923,2929 **** TRUE, FALSE)); } ! void bfd_section_already_linked_table_insert (struct bfd_section_already_linked_hash_entry *already_linked_list, asection *sec) --- 2923,2929 ---- TRUE, FALSE)); } ! bfd_boolean bfd_section_already_linked_table_insert (struct bfd_section_already_linked_hash_entry *already_linked_list, asection *sec) *************** bfd_section_already_linked_table_insert *** 2933,2941 **** --- 2933,2944 ---- /* Allocate the memory from the same obstack as the hash table is kept in. */ l = bfd_hash_allocate (&_bfd_section_already_linked_table, sizeof *l); + if (l == NULL) + return FALSE; l->sec = sec; l->next = already_linked_list->entry; already_linked_list->entry = l; + return TRUE; } static struct bfd_hash_entry * *************** already_linked_newfunc (struct bfd_hash_ *** 2947,2953 **** bfd_hash_allocate (table, sizeof *ret); if (ret == NULL) ! return ret; ret->entry = NULL; --- 2950,2956 ---- bfd_hash_allocate (table, sizeof *ret); if (ret == NULL) ! return NULL; ret->entry = NULL; *************** bfd_section_already_linked_table_free (v *** 2973,2979 **** void _bfd_generic_section_already_linked (bfd *abfd, asection *sec, ! struct bfd_link_info *info ATTRIBUTE_UNUSED) { flagword flags; const char *name; --- 2976,2982 ---- void _bfd_generic_section_already_linked (bfd *abfd, asection *sec, ! struct bfd_link_info *info) { flagword flags; const char *name; *************** _bfd_generic_section_already_linked (bfd *** 3074,3080 **** } /* This is the first section with this name. Record it. */ ! bfd_section_already_linked_table_insert (already_linked_list, sec); } /* Convert symbols in excluded output sections to use a kept section. */ --- 3077,3084 ---- } /* This is the first section with this name. Record it. */ ! if (! bfd_section_already_linked_table_insert (already_linked_list, sec)) ! info->callbacks->einfo (_("%F%P: internal error at %D")); } /* Convert symbols in excluded output sections to use a kept section. */ Index: elflink.c =================================================================== RCS file: /cvs/src/src/bfd/elflink.c,v retrieving revision 1.273 diff -p -r1.273 elflink.c *** elflink.c 26 Jul 2007 13:45:59 -0000 1.273 --- elflink.c 26 Jul 2007 22:15:59 -0000 *************** _bfd_elf_section_already_linked (bfd *ab *** 12235,12241 **** } /* This is the first section with this name. Record it. */ ! bfd_section_already_linked_table_insert (already_linked_list, sec); } bfd_boolean --- 12235,12242 ---- } /* This is the first section with this name. Record it. */ ! if (! bfd_section_already_linked_table_insert (already_linked_list, sec)) ! info->callbacks->einfo (_("%F%P: internal error at %D")); } bfd_boolean Index: libbfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd-in.h,v retrieving revision 1.71 diff -p -r1.71 libbfd-in.h *** libbfd-in.h 3 Jul 2007 14:26:42 -0000 1.71 --- libbfd-in.h 26 Jul 2007 22:15:59 -0000 *************** struct bfd_section_already_linked *** 726,732 **** extern struct bfd_section_already_linked_hash_entry * bfd_section_already_linked_table_lookup (const char *); ! extern void bfd_section_already_linked_table_insert (struct bfd_section_already_linked_hash_entry *, asection *); extern void bfd_section_already_linked_table_traverse (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *, --- 726,732 ---- extern struct bfd_section_already_linked_hash_entry * bfd_section_already_linked_table_lookup (const char *); ! extern bfd_boolean bfd_section_already_linked_table_insert (struct bfd_section_already_linked_hash_entry *, asection *); extern void bfd_section_already_linked_table_traverse (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *, Index: libbfd.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd.h,v retrieving revision 1.195 diff -p -r1.195 libbfd.h *** libbfd.h 3 Jul 2007 14:26:42 -0000 1.195 --- libbfd.h 26 Jul 2007 22:15:59 -0000 *************** struct bfd_section_already_linked *** 731,737 **** extern struct bfd_section_already_linked_hash_entry * bfd_section_already_linked_table_lookup (const char *); ! extern void bfd_section_already_linked_table_insert (struct bfd_section_already_linked_hash_entry *, asection *); extern void bfd_section_already_linked_table_traverse (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *, --- 731,737 ---- extern struct bfd_section_already_linked_hash_entry * bfd_section_already_linked_table_lookup (const char *); ! extern bfd_boolean bfd_section_already_linked_table_insert (struct bfd_section_already_linked_hash_entry *, asection *); extern void bfd_section_already_linked_table_traverse (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *, ------=_20070726151645_97487--