This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: .comm symbol, 0
On Fri, Nov 11, 2005 at 08:38:58AM +0100, Jan Beulich wrote:
> That is my point. The issue really is if, in order to find out whether
> a symbol is common, one can, short of S_IS_COMMON not always being
> usable, rely on this being in the undefined section (!S_IS_DEFINED) and
> having a non-zero value (S_GET_VALUE or similar), just like write.c does
> to detect them.
At one time, S_GET_VALUE used to resolve the symbol value to a final
value. Thus, S_GET_VALUE used before final frag addresses were
calculated could result in wrong symbol values. That particular problem
should no longer occur, so it would be possible to use
return (bfd_is_com_section (s->bsym->section)
|| (!S_IS_DEFINED (s) && S_GET_VALUE (s) != 0));
is S_IS_COMMON. However, this is not ideal because all assembler
targets are now using BFD, and we should be properly setting the section
on common symbols. If non-ELF formats do not do this, they need fixing.
The write.c test also should disappear since it was really only
necessary for non-BFD assembler. I won't remove that right away, but
I'm applying the following to remove another vestige of non-BFD
assembler support.
* symbols.c (S_GET_VALUE): Remove non-BFD assembler recursion guard.
Index: gas/symbols.c
===================================================================
RCS file: /cvs/src/src/gas/symbols.c,v
retrieving revision 1.69
diff -u -p -r1.69 symbols.c
--- gas/symbols.c 4 Nov 2005 19:45:24 -0000 1.69
+++ gas/symbols.c 14 Nov 2005 22:34:31 -0000
@@ -1782,20 +1782,11 @@ S_GET_VALUE (symbolS *s)
if (s->sy_value.X_op != O_constant)
{
- static symbolS *recur;
-
- /* FIXME: In non BFD assemblers, S_IS_DEFINED and S_IS_COMMON
- may call S_GET_VALUE. We use a static symbol to avoid the
- immediate recursion. */
- if (recur == s)
- return (valueT) s->sy_value.X_add_number;
- recur = s;
if (! s->sy_resolved
|| s->sy_value.X_op != O_symbol
|| (S_IS_DEFINED (s) && ! S_IS_COMMON (s)))
as_bad (_("attempt to get value of unresolved symbol `%s'"),
S_GET_NAME (s));
- recur = NULL;
}
return (valueT) s->sy_value.X_add_number;
}
--
Alan Modra
IBM OzLabs - Linux Technology Centre