bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ld 2.11.2 hang


From: Nick Clifton
Subject: Re: ld 2.11.2 hang
Date: 17 Sep 2001 17:01:34 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi Per,

> FYI ld 2.11.2 hangs when presented with certain options followed by
> a number such as :
> 
> >ld -n1
> 
> This causes binutils configure to hang under Irix when using the
> MIPSPro compiler if/when it tries to run gnu-ld with the -n32 flag.
> Tried with gcc 2.96 on Linux 2.2.16-22 and MIPSPro 7.3.1.1 on Irix
> 6.5.8.

It also appears to happen for other configurations including the
native x86 Linux configuration.

The bug appears to be a fault in the getopt() implementation, but I
have not been able to track this down, since I cannot find out which
implementation of getopt() my copy of ld is using.  (It does not
appear to be the one in libiberty.a from the same source tree...)

Anyway I found that the patch below would act as a workaround for this
problem.  I am not sure if it should be checked in however, since I
would prefer to fix getopt().  (If indeed that is the location of the 
problem, and if it is not in a system library that cannot be fixed).

Cheers
        Nick

Index: ld/lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.39
diff -p -r1.39 lexsup.c
*** lexsup.c    2001/08/23 15:14:18     1.39
--- lexsup.c    2001/09/17 16:01:56
*************** parse_args (argc, argv)
*** 460,475 ****
        {
          shortopts[is] = ld_options[i].shortopt;
          ++is;
!         if (ld_options[i].opt.has_arg == required_argument
!             || ld_options[i].opt.has_arg == optional_argument)
            {
              shortopts[is] = ':';
              ++is;
!             if (ld_options[i].opt.has_arg == optional_argument)
!               {
!                 shortopts[is] = ':';
!                 ++is;
!               }
            }
        }
        if (ld_options[i].opt.name != NULL)
--- 460,489 ----
        {
          shortopts[is] = ld_options[i].shortopt;
          ++is;
!         switch (ld_options[i].opt.has_arg)
            {
+           case no_argument:
+ #if 0
+             /* FIXME: We should 'break' here so that no colons are added
+                after the short option's letter.  But certain implementations
+                of getopt() are broken and can loop indefinitely if a
+                short option which takes no arguments is actually given
+                an argument.  (eg -n1 instead of -n).  Treating such
+                options as optional_argument is a workaround for this bug.  */
+             break;
+ #else
+             /* Fall through.  */
+ #endif
+           case optional_argument:
              shortopts[is] = ':';
              ++is;
!             /* Fall through.  */
!           case required_argument:
!             shortopts[is] = ':';
!             ++is;
!             break;
!           default:
!             abort ();
            }
        }
        if (ld_options[i].opt.name != NULL)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]