This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Allow collect2 to work with some linkers


Marc Espie wrote:
This happens very infrequently.
- on some systems, collect2 is called to compile extra files to handle
constructors/destructors. This doesn't happen too often.
- it then tries to insert that extra object file on the linker file.
- on OpenBSD-sparc, that linker line happens to begin with -dynamic-linker /usr/libexec/ld.so
- ld.so is mistaken for an object file.
- we end up with -dynamic-linker /tmp/ccxadad.o /usr/libexec/ld.so


The resulting error message is thoroughly confusing...

The fix is to explicitly parse -dynamic-linker, so that /usr/libexec/ld.so
stays with it:

OK, but:


2005-01-08 Marc Espie <espie@openbsd.org>

* collect2.c (main): Explicitly parse -dynamic-linker option.

*** collect2.c.orig	Mon Jan 10 01:44:29 2005
--- collect2.c	Mon Jan 10 01:44:01 2005
*************** main (int argc, char **argv)
*** 1097,1102 ****
--- 1097,1107 ----
  		  ld1--;
  		  ld2--;
  		}
+ 	      if (!strcmp (arg, "-dynamic-linker") && argv[1] != (char *) 0)
+ 	        {
+ 		  ++argv;
+ 		  *ld1++ = *ld2++ = *argv;
+ 		}

Please write the condition as:


strcmp (...) == 0 && argv[1]

Thanks,

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]