Get rid of underscore.c
Zack Weinberg
zack@codesourcery.com
Wed Sep 4 22:23:00 GMT 2002
On Wed, Sep 04, 2002 at 06:25:25PM -0700, Zack Weinberg wrote:
> The sole function of underscore.c is to get the definition of
> USER_LABEL_PREFIX into collect2 and c++filt. For collect2, this can
> be done just as easily by having collect2.c and tlink.c refer directly
> to USER_LABEL_PREFIX. Both files already use information from tm.h,
> so no additional dependencies are created. collect2 does not honor
> -f(no-)leading-underscore, but it never has; that could be fixed in a
> follow-up.
Argh. That version had a classic error in it, strncmp returns 0 for
equality. Corrected version of collect2.c and tlink.c patches follow.
zw
===================================================================
Index: collect2.c
--- collect2.c 4 Aug 2002 22:45:18 -0000 1.140
+++ collect2.c 5 Sep 2002 05:23:28 -0000
@@ -236,9 +236,6 @@ char * temporary_firstobj;
/* Holds the return value of pexecute. */
int pexecute_pid;
-/* Defined in the automatically-generated underscore.c. */
-extern int prepends_underscore;
-
/* Structure to hold all the directories in which to search for files to
execute. */
@@ -515,8 +512,8 @@ dump_file (name)
if (*word == '.')
++word, putc ('.', stderr);
p = word;
- if (*p == '_' && prepends_underscore)
- ++p;
+ if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)))
+ p += strlen (USER_LABEL_PREFIX);
if (no_demangle)
result = 0;
===================================================================
Index: tlink.c
--- tlink.c 4 Aug 2002 22:45:20 -0000 1.44
+++ tlink.c 5 Sep 2002 05:23:28 -0000
@@ -595,8 +595,8 @@ scan_linker_output (fname)
/* Try the first word on the line. */
if (*p == '.')
++p;
- if (*p == '_' && prepends_underscore)
- ++p;
+ if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)))
+ p += strlen (USER_LABEL_PREFIX);
end = ! *q;
*q = 0;
@@ -611,8 +611,8 @@ scan_linker_output (fname)
p++;
if (*p == '.')
p++;
- if (*p == '_' && prepends_underscore)
- p++;
+ if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)))
+ p += strlen (USER_LABEL_PREFIX);
sym = symbol_hash_lookup (p, false);
}
@@ -649,8 +649,9 @@ scan_linker_output (fname)
sym = symbol_hash_lookup (dem->mangled, false);
else
{
- if (*p == '_' && prepends_underscore)
- ++p;
+ if (!strncmp (p, USER_LABEL_PREFIX,
+ strlen (USER_LABEL_PREFIX)))
+ p += strlen (USER_LABEL_PREFIX);
sym = symbol_hash_lookup (p, false);
}
}
More information about the Gcc-patches
mailing list