This is the mail archive of the
mailing list for the binutils project.
Re: [Patch]: fix bfd/targets.c build failure on AIX
On Wed, Nov 18, 2009 at 12:58:23AM +1030, Alan Modra wrote:
> On Tue, Nov 17, 2009 at 02:00:48PM +0100, Tristan Gingold wrote:
> > So, do we accept alloca in targets.c ?
> I think we could easily use a fixed size buffer, since the code in
> bfd_get_target_info is using alloca for (part of) target_vec->name.
> The largest target_vec->name is currently 24 chars. A buffer twice
> that size should be ample.
> > Maybe we should also clearly document in alloca-conf.h that this
> > file must be the first include.
> We do have a comment that says in part: "Some versions of AIX require
> this to be the first thing in the file except for comments and
> preprocessor directives."
> s/in the file/seen by the compiler/ would be clearer.
* alloca-conf.h: Clarify comment.
* targets.c: Don't include alloca-conf.h.
(bfd_get_target_info): Don't use alloca.
RCS file: /cvs/src/src/include/alloca-conf.h,v
retrieving revision 1.2
diff -u -p -r1.2 alloca-conf.h
--- include/alloca-conf.h 18 Mar 2009 11:27:16 -0000 1.2
+++ include/alloca-conf.h 17 Nov 2009 23:08:45 -0000
@@ -15,7 +15,8 @@
# if defined _AIX
/* Indented so that pre-ansi C compilers will ignore it, rather than
choke on it. Some versions of AIX require this to be the first
- thing in the file except for comments and preprocessor directives. */
+ thing seen by the compiler except for comments and preprocessor
+ directives. */
# if defined _MSC_VER && !defined C_ALLOCA
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.181
diff -u -p -r1.181 targets.c
--- bfd/targets.c 17 Nov 2009 10:54:20 -0000 1.181
+++ bfd/targets.c 17 Nov 2009 23:07:47 -0000
@@ -25,7 +25,6 @@
It's okay to see some:
@@ -1523,7 +1522,8 @@ bfd_get_target_info (const char *target_
for triplets like "pe-arm-wince-little". */
if (!_bfd_find_arch_match (tname, arches, def_target_arch))
- char *new_tname = (char *) alloca (strlen (hyp) + 1);
+ char new_tname;
strcpy (new_tname, hyp);
while ((hyp = strrchr (new_tname, '-')) != NULL)
Australia Development Lab, IBM