delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/01/02/19:13:32

Date: Fri, 03 Jan 2003 00:14:20 +0000
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
Subject: mkstubs: How many underscores would you like, sir? [PATCH]
Message-Id: <E18UFSl-0000SB-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

I assumed that mkstubs analysed <libc/stubs.h> to get
the stub & real names from the #defines. It turns out it only looks
at the stub names and assumes the real names are double-underscore
prefixed.

Unfortunately this is not the case with strtold -> _strtold.
bash 2.05b uses strtold and it fails to link, because there
is no real code to resolve the undefined reference in the stub
strtold for __strtold.

Below is a patch that makes mkstubs work how I thought it did.
I tested it and compared the stubs before and after. There are
no regressions and it does the right thing for strtold.

I've also made the comment about the gcc bug fit in 80 columns.

OK to commit?

Thanks, bye, Rich =]

Index: src/libc/stubs/mkstubs.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/stubs/mkstubs.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 mkstubs.c
--- src/libc/stubs/mkstubs.c	17 Oct 2002 23:00:25 -0000	1.3
+++ src/libc/stubs/mkstubs.c	3 Jan 2003 00:10:41 -0000
@@ -11,6 +11,7 @@ main(int argc, char **argv)
 {
   char buf[1000];
   char fn[1000];
+  char stubname[1000], realname[1000];
   int i;
   FILE *stubs, *as, *mk, *oh;
 
@@ -32,16 +33,20 @@ main(int argc, char **argv)
   {
     if (strncmp(buf, "#define", 7))
       continue;
-    sscanf(buf, "%*s %s", buf);
-    if (strncmp(buf, "__dj_include", 10) == 0)
+    sscanf(buf, "%*s %s %s", stubname, realname);
+    if (strncmp(stubname, "__dj_include", 10) == 0)
       continue;
 
     sprintf(fn, "stub%04d.S", i);
     as = fopen(fn, "w");
-    /* Blank line at start of output file is added to workaround gcc-3.0 preprocessor bug  */
-    /* See  http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3081&database=gcc for details  */
-    fprintf(as, "\n\t.file \"%s.stub\"\n\t.global _%s\n_%s:\n\tjmp ___%s\n",
-	    buf, buf, buf, buf);
+    /* Blank line at start of output file is added to work around
+     * gcc-3.0 preprocessor bug. See:
+     *
+     * http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3081&database=gcc
+     *
+     * for details. */
+    fprintf(as, "\n\t.file \"%s.stub\"\n\t.global _%s\n_%s:\n\tjmp _%s\n",
+	    stubname, stubname, stubname, realname);
     fclose(as);
 
     fprintf(mk, "SRC += %s\n", fn);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019