[Top][All Lists]

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

Re: ld goes into endless loop

From: Nick Clifton
Subject: Re: ld goes into endless loop
Date: 31 Oct 2001 15:40:28 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1

Hi Erik,

> You can reproduce the erroneous ld behaviour by saying
>       ld -rpath,a
> Note the comma between "-rpath" and "a".  I guess this should be flagged as 
> error by ld.  ltrace shows that ld hangs processing its command line options.

Mmm, yes this has happened before.  Time for a fix.  I am applying the
patch below to catch this case.


2001-10-31  Nick Clifton  <address@hidden>

        * lexsup.c (parse_args): Prevent infinite parsing loop when
        "-rpath.a" is specified on the command line.

Index: ld/lexsup.c
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.42
diff -p -r1.42 lexsup.c
*** lexsup.c    2001/10/02 06:04:23     1.42
--- lexsup.c    2001/10/31 15:36:07
*************** parse_args (argc, argv)
*** 798,803 ****
--- 795,811 ----
        case 'i':
        case 'r':
+         if (optind == last_optind)
+           /* This can happen if the user put "-rpath,a" on the command
+              line.  (Or something similar.  The comma is important).
+              Getopt becomes confused and thinks that this is a -r option
+              but it cannot parse the text after the -r so it refuses to
+              increment the optind counter.  Detect this case and issue
+              an error message here.  We cannot just make this a warning,
+              increment optind, and continue because getopt is too confused
+              and will seg-fault the next time around.  */
+           einfo(_("%P%F: bad -rpath option\n"));
          link_info.relocateable = true;
          config.build_constructors = false;
          config.magic_demand_paged = false;

reply via email to

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