This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Use LOCAL_LABEL_PREFIX when creating local labels
- To: binutils at sources dot redhat dot com
- Subject: Use LOCAL_LABEL_PREFIX when creating local labels
- From: Nick Clifton <nickc at redhat dot com>
- Date: Wed, 10 Jan 2001 17:39:35 -0800
Hi Guys,
Whilst working on another problem I noticed that the local label
code in gas/symbol.c was not always taking LOCAL_LABEL_PREFIX into
account. This patch fixes that, and also replaces the use of
numerical constants with symbolic constants in order to make the
code easier to read.
Cheers
Nick
2001-01-10 Nick Clifton <nickc@redhat.com>
* symbols.c (DOLLAR_LABEL_CHAR): New constant - the magic
character used to dollar local symbols.
(LOCAL_LABEL_CHAR): New constant - the magic character used to
local label symbols.
(dollar_label_name): Use DOLLAR_LABEL_CHAR.
(fb_label_name): Prefix local labels with LOCAL_LABEL_PREFIX,
if defined.
Use LOCAL_LABEL_CHAR.
(decode_local_label_name): Skip LOCAL_LABEL_PREFIX.
Use DOLLAR_LABEL_CHAR and LOCAL_LABEL_CHAR.
(S_IS_LOCAL): Use DOLLAR_LABEL_CHAR and LOCAL_LABEL_CHAR.
Index: symbols.c
===================================================================
RCS file: /cvs/src//src/gas/symbols.c,v
retrieving revision 1.14
diff -p -r1.14 symbols.c
*** symbols.c 2000/08/10 19:00:08 1.14
- --- symbols.c 2001/01/11 01:11:16
*************** symbolS abs_symbol;
*** 55,60 ****
- --- 55,63 ----
#define debug_verify_symchain(root, last) ((void) 0)
#endif
+ #define DOLLAR_LABEL_CHAR '\001'
+ #define LOCAL_LABEL_CHAR '\002'
+
struct obstack notes;
static void fb_label_init PARAMS ((void));
*************** dollar_label_name (n, augend)
*** 1329,1335 ****
while ((*p = *--q) != '\0')
++p;
! *p++ = 1; /* ^A */
/* Instance number. */
q = symbol_name_temporary;
- --- 1332,1338 ----
while ((*p = *--q) != '\0')
++p;
! *p++ = DOLLAR_LABEL_CHAR; /* ^A */
/* Instance number. */
q = symbol_name_temporary;
*************** fb_label_name (n, augend)
*** 1483,1488 ****
- --- 1486,1494 ----
know (n >= 0);
know (augend == 0 || augend == 1);
p = symbol_name_build;
+ #ifdef LOCAL_LABEL_PREFIX
+ *p++ = LOCAL_LABEL_PREFIX;
+ #endif
*p++ = 'L';
/* Next code just does sprintf( {}, "%d", n); */
*************** fb_label_name (n, augend)
*** 1496,1502 ****
while ((*p = *--q) != '\0')
++p;
! *p++ = 2; /* ^B */
/* Instance number. */
q = symbol_name_temporary;
- --- 1502,1508 ----
while ((*p = *--q) != '\0')
++p;
! *p++ = LOCAL_LABEL_CHAR; /* ^B */
/* Instance number. */
q = symbol_name_temporary;
*************** decode_local_label_name (s)
*** 1525,1540 ****
int instance_number;
char *type;
const char *message_format = _("\"%d\" (instance number %d of a %s label)");
!
! if (s[0] != 'L')
return s;
! for (label_number = 0, p = s + 1; isdigit ((unsigned char) *p); ++p)
label_number = (10 * label_number) + *p - '0';
! if (*p == 1)
type = "dollar";
! else if (*p == 2)
type = "fb";
else
return s;
- --- 1531,1552 ----
int instance_number;
char *type;
const char *message_format = _("\"%d\" (instance number %d of a %s label)");
! int index = 0;
!
! #ifdef LOCAL_LABEL_PREFIX
! if (s[index] == LOCAL_LABEL_PREFIX)
! ++index;
! #endif
!
! if (s[index] != 'L')
return s;
! for (label_number = 0, p = s + index + 1; isdigit ((unsigned char) *p); ++p)
label_number = (10 * label_number) + *p - '0';
! if (*p == DOLLAR_LABEL_CHAR)
type = "dollar";
! else if (*p == LOCAL_LABEL_CHAR)
type = "fb";
else
return s;
*************** S_IS_LOCAL (s)
*** 1721,1728 ****
name = S_GET_NAME (s);
return (name != NULL
&& ! S_IS_DEBUG (s)
! && (strchr (name, '\001')
! || strchr (name, '\002')
|| (! flag_keep_locals
&& (bfd_is_local_label (stdoutput, s->bsym)
|| (flag_mri
- --- 1733,1740 ----
name = S_GET_NAME (s);
return (name != NULL
&& ! S_IS_DEBUG (s)
! && (strchr (name, DOLLAR_LABEL_CHAR)
! || strchr (name, LOCAL_LABEL_CHAR)
|| (! flag_keep_locals
&& (bfd_is_local_label (stdoutput, s->bsym)
|| (flag_mri