From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10909 invoked by alias); 27 Sep 2005 14:51:43 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 10862 invoked by uid 22791); 27 Sep 2005 14:51:30 -0000 Received: from dumbledore.codesourcery.com (HELO sethra.codesourcery.com) (65.74.133.11) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 27 Sep 2005 14:51:30 +0000 Received: from sethra.codesourcery.com (localhost.localdomain [127.0.0.1]) by sethra.codesourcery.com (8.12.11/8.12.11) with ESMTP id j8REpKnq029829; Tue, 27 Sep 2005 07:51:20 -0700 Received: (from mitchell@localhost) by sethra.codesourcery.com (8.12.11/8.12.11/Submit) id j8REpKeg029702; Tue, 27 Sep 2005 07:51:20 -0700 Date: Tue, 27 Sep 2005 14:51:00 -0000 Message-Id: <200509271451.j8REpKeg029702@sethra.codesourcery.com> From: Mark Mitchell To: gdb@sources.redhat.com, gdb-patches@sources.redhat.com Cc: ian@airs.com, dj@redhat.com Subject: PATCH: Do not call xmalloc_failed in expandargv Reply-to: mark@codesourcery.com X-SW-Source: 2005-09/txt/msg00212.txt.bz2 This patch fixes the link error when compiling GDB. The cause of the failure is that GDB's utils.c defines xmalloc, but not xmalloc_failed; therefore, expandargv pulls in xmalloc.c to get xmalloc_failed, which causes a duplicate symbol error for xmalloc. Arguably, GDB should define xmalloc_failed, so as to completely replace the interface. (In fact, GDB provides "nomem", which has almost the same signature.) However, this patch to libiberty will be more robust if there are other similar programs out there that, like GDB, replace only some of the interface. We could also split xmalloc_failed into its own file, so as to decouple it from xmalloc. In any case, is this patch OK, to get GDB back to linking? -- Mark Mitchell CodeSourcery, LLC mark@codesourcery.com 2005-09-27 Mark Mitchell * argv.c (expandargv): Do not use xmalloc_failed. Index: argv.c =================================================================== RCS file: /cvs/src/src/libiberty/argv.c,v retrieving revision 1.14 diff -c -5 -p -r1.14 argv.c *** argv.c 26 Sep 2005 21:02:59 -0000 1.14 --- argv.c 27 Sep 2005 14:45:31 -0000 *************** expandargv (argcp, argvp) *** 363,375 **** /* If *ARGVP is not already dynamically allocated, copy it. */ if (!argv_dynamic) { *argvp = dupargv (*argvp); if (!*argvp) ! /* We do not know exactly many bytes dupargv tried to ! allocate, so make a guess. */ ! xmalloc_failed (*argcp * 32); } /* Count the number of arguments. */ file_argc = 0; while (file_argv[file_argc] && *file_argv[file_argc]) ++file_argc; --- 363,376 ---- /* If *ARGVP is not already dynamically allocated, copy it. */ if (!argv_dynamic) { *argvp = dupargv (*argvp); if (!*argvp) ! { ! fprintf (stderr, "\n%sout of memory\n"); ! xexit (1); ! } } /* Count the number of arguments. */ file_argc = 0; while (file_argv[file_argc] && *file_argv[file_argc]) ++file_argc;