This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: RFC: weakref GCC attribute and .weakref assembly directive
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 11 Oct 2005 11:15:54 -0300
- Subject: Re: RFC: weakref GCC attribute and .weakref assembly directive
- References: <orek6tca8g.fsf@livre.oliva.athome.lsd.ic.unicamp.br>
On Oct 10, 2005, Alexandre Oliva <aoliva@redhat.com> wrote:
> I'll probably post a patch for the assembler, that implements this,
> tonight.
Or this morning :-)
Ok to install?
Introduce weakref support in the assembler, as described in
http://people.redhat.com/aoliva/writeups/weakref/weakref.txt
Index: gas/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* read.c (potable): Add weakref.
(s_weakref): New.
* read.h (s_weakref): Declare.
* struc-symbol.h (struct symbol): Add sy_weakrefr and sy_weakrefd.
* symbols.c (colon): Clear weakrefr.
(symbol_find_exact): Rename to, and reimplement in terms of...
(symbol_find_exact_noref): ... new function.
(symbol_find): Likewise...
(symbol_find_noref): ... ditto.
(resolve_symbol_value): Resolve weakrefr without setting their
values.
(S_GET_VALUE): Follow weakref link.
(S_SET_VALUE): Clear weakrefr.
(S_IS_WEAK): Follow weakref link.
(S_IS_WEAKREFR, S_SET_WEAKREFR, S_CLEAR_WEAKREFR): New.
(S_IS_WEAKREFD, S_SET_WEAKREFD, S_CLEAR_WEAKREFD): New.
(symbol_set_value_expression, symbol_set_frag): Clear weakrefr.
(symbol_mark_used): Follow weakref link.
(print_symbol_value_1): Print weak, weakrefr and weakrefd.
* symbols.h (symbol_find_noref, symbol_find_exact_noref): Declare.
(S_IS_WEAKREFR, S_SET_WEAKREFR, S_CLEAR_WEAKREFR): Declare.
(S_IS_WEAKREFD, S_SET_WEAKREFD, S_CLEAR_WEAKREFD): Declare.
* write.c (adust_reloc_syms): Follow weakref link. Do not
complain if target is undefined.
(write_object_file): Likewise. Remove weakrefr symbols.
* doc/as.texinfo: Document weakref.
* doc/internals.texi: Document new struct members and internal
functions.
Index: gas/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* gas/all/weakref1.s,gas/all/weakref1.d: New test.
* gas/all/weakref2.s, gas/all/weakref3.s: New tests.
* gas/all/gas.exp: Run new tests.
Index: gas/read.c
===================================================================
--- gas/read.c.orig 2005-10-11 10:04:20.000000000 -0300
+++ gas/read.c 2005-10-11 10:09:06.000000000 -0300
@@ -434,6 +434,7 @@
{"xref", s_ignore, 0},
{"xstabs", s_xstab, 's'},
{"warning", s_errwarn, 0},
+ {"weakref", s_weakref, 0},
{"word", cons, 2},
{"zero", s_space, 0},
{NULL, NULL, 0} /* End sentinel. */
@@ -3150,6 +3151,124 @@
const_flag &= ~IN_DEFAULT_SECTION;
#endif
}
+
+/* .weakref x, y sets x as an alias to y that, as long as y is not
+ referenced directly, will cause y to become a weak symbol. */
+void
+s_weakref (int ignore ATTRIBUTE_UNUSED)
+{
+ char *name;
+ char delim;
+ char *end_name;
+ symbolS *symbolP;
+ symbolS *symbolP2;
+ expressionS exp;
+
+ name = input_line_pointer;
+ delim = get_symbol_end ();
+ end_name = input_line_pointer;
+
+ if (name == end_name)
+ {
+ as_bad (_("expected symbol name"));
+ *end_name = delim;
+ ignore_rest_of_line ();
+ return;
+ }
+
+ symbolP = symbol_find_or_make (name);
+
+ *end_name = delim;
+
+ SKIP_WHITESPACE ();
+
+ if (*input_line_pointer != ',')
+ {
+ *end_name = 0;
+ as_bad (_("expected comma after \"%s\""), name);
+ *end_name = delim;
+ ignore_rest_of_line ();
+ return;
+ }
+
+ input_line_pointer++;
+
+ SKIP_WHITESPACE ();
+
+ name = input_line_pointer;
+ delim = get_symbol_end ();
+ end_name = input_line_pointer;
+
+ if (name == end_name)
+ {
+ as_bad (_("expected symbol name"));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ if ((symbolP2 = symbol_find_noref (name, 1)) == NULL
+ && (symbolP2 = md_undefined_symbol (name)) == NULL)
+ {
+ symbolP2 = symbol_find_or_make (name);
+ S_SET_WEAKREFD (symbolP2);
+ }
+ else
+ {
+ symbolS *symp = symbolP2;
+
+ while (S_IS_WEAKREFR (symp) && symp != symbolP)
+ {
+ expressionS *expP = symbol_get_value_expression (symp);
+
+ assert (expP->X_op == O_symbol
+ && expP->X_add_number == 0);
+ symp = expP->X_add_symbol;
+ }
+ if (symp == symbolP)
+ {
+ char *loop;
+
+ loop = concat (S_GET_NAME (symbolP),
+ " => ", S_GET_NAME (symbolP2), NULL);
+
+ symp = symbolP2;
+ while (symp != symbolP)
+ {
+ char *old_loop = loop;
+ symp = symbol_get_value_expression (symp)->X_add_symbol;
+ loop = concat (loop, " => ", S_GET_NAME (symp), NULL);
+ free (old_loop);
+ }
+
+ as_bad (_("%s: would close weakref loop: %s"),
+ S_GET_NAME (symbolP), loop);
+
+ free (loop);
+
+ *end_name = delim;
+ ignore_rest_of_line ();
+ return;
+ }
+
+ /* Short-circuiting instead of just checking here might speed
+ things up a tiny little bit, but loop error messages would
+ miss intermediate links. */
+ /* symbolP2 = symp; */
+ }
+
+ *end_name = delim;
+
+ exp.X_op = O_symbol;
+ exp.X_add_number = 0;
+ exp.X_add_symbol = symbolP2;
+
+ S_SET_SEGMENT (symbolP, undefined_section);
+ symbol_set_value_expression (symbolP, &exp);
+ symbol_set_frag (symbolP, &zero_address_frag);
+ S_SET_WEAKREFR (symbolP);
+
+ demand_empty_rest_of_line ();
+}
/* Verify that we are at the end of a line. If not, issue an error and
Index: gas/read.h
===================================================================
--- gas/read.h.orig 2005-10-11 10:00:47.000000000 -0300
+++ gas/read.h 2005-10-11 10:09:06.000000000 -0300
@@ -185,3 +185,4 @@
extern void s_xstab (int what);
extern void s_rva (int);
extern void s_incbin (int);
+extern void s_weakref (int);
Index: gas/struc-symbol.h
===================================================================
--- gas/struc-symbol.h.orig 2005-10-11 10:04:20.000000000 -0300
+++ gas/struc-symbol.h 2005-10-11 10:09:06.000000000 -0300
@@ -72,6 +72,15 @@
routines. */
unsigned int sy_mri_common : 1;
+ /* This is set if the symbol is set with a .weakref directive. */
+ unsigned int sy_weakrefr : 1;
+
+ /* This is set when the symbol is referenced as part of a .weakref
+ directive, but only if the symbol was not in the symbol table
+ before. It is cleared as soon as any direct reference to the
+ symbol is present. */
+ unsigned int sy_weakrefd : 1;
+
#ifdef OBJ_SYMFIELD_TYPE
OBJ_SYMFIELD_TYPE sy_obj;
#endif
Index: gas/symbols.c
===================================================================
--- gas/symbols.c.orig 2005-10-11 10:04:20.000000000 -0300
+++ gas/symbols.c 2005-10-11 10:58:51.000000000 -0300
@@ -309,6 +309,7 @@
if ((symbolP = symbol_find (sym_name)) != 0)
{
+ S_CLEAR_WEAKREFR (symbolP);
#ifdef RESOLVE_SYMBOL_REDEFINITION
if (RESOLVE_SYMBOL_REDEFINITION (symbolP))
return symbolP;
@@ -651,18 +652,41 @@
symbolS *
symbol_find_exact (const char *name)
{
+ return symbol_find_exact_noref (name, 0);
+}
+
+symbolS *
+symbol_find_exact_noref (const char *name, int noref)
+{
struct local_symbol *locsym;
+ symbolS* sym;
locsym = (struct local_symbol *) hash_find (local_hash, name);
if (locsym != NULL)
return (symbolS *) locsym;
- return ((symbolS *) hash_find (sy_hash, name));
+ sym = ((symbolS *) hash_find (sy_hash, name));
+
+ /* Any references to the symbol, except for the reference in
+ .weakref, must clear this flag, such that the symbol does not
+ turn into a weak symbol. Note that we don't have to handle the
+ local_symbol case, since a weakrefd is always promoted out of the
+ local_symbol table when it is turned into a weak symbol. */
+ if (sym && ! noref)
+ S_CLEAR_WEAKREFD (sym);
+
+ return sym;
}
symbolS *
symbol_find (const char *name)
{
+ return symbol_find_noref (name, 0);
+}
+
+symbolS *
+symbol_find_noref (const char *name, int noref)
+{
#ifdef tc_canonicalize_symbol_name
{
char *copy;
@@ -690,7 +714,7 @@
*copy = '\0';
}
- return symbol_find_exact (name);
+ return symbol_find_exact_noref (name, noref);
}
/* Once upon a time, symbols were kept in a singly linked list. At
@@ -970,6 +994,17 @@
symp->sy_value.X_op_symbol = NULL;
do_symbol:
+ if (S_IS_WEAKREFR (symp))
+ {
+ assert (final_val == 0);
+ while (S_IS_WEAKREFR (add_symbol))
+ {
+ assert (add_symbol->sy_value.X_op == O_symbol
+ && add_symbol->sy_value.X_add_number == 0);
+ add_symbol = add_symbol->sy_value.X_add_symbol;
+ }
+ }
+
if (symp->sy_mri_common)
{
/* This is a symbol inside an MRI common section. The
@@ -1039,6 +1074,8 @@
}
resolved = symbol_resolved_p (add_symbol);
+ if (S_IS_WEAKREFR (symp))
+ goto exit_dont_set_value;
break;
case O_uminus:
@@ -1717,6 +1754,9 @@
if (!finalize_syms)
return val;
}
+ if (S_IS_WEAKREFR (s))
+ return S_GET_VALUE (s->sy_value.X_add_symbol);
+
if (s->sy_value.X_op != O_constant)
{
static symbolS *recur;
@@ -1751,6 +1791,7 @@
s->sy_value.X_op = O_constant;
s->sy_value.X_add_number = (offsetT) val;
s->sy_value.X_unsigned = 0;
+ S_CLEAR_WEAKREFR (s);
}
void
@@ -1806,10 +1847,32 @@
{
if (LOCAL_SYMBOL_CHECK (s))
return 0;
+ /* Conceptually, a weakrefr is weak if the referenced symbol is. We
+ could probably handle a WEAKREFR as always weak though. E.g., if
+ the referenced symbol has lost its weak status, there's no reason
+ to keep handling the weakrefr as if it was weak. */
+ if (S_IS_WEAKREFR (s))
+ return S_IS_WEAK (s->sy_value.X_add_symbol);
return (s->bsym->flags & BSF_WEAK) != 0;
}
int
+S_IS_WEAKREFR (symbolS *s)
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+ return s->sy_weakrefr != 0;
+}
+
+int
+S_IS_WEAKREFD (symbolS *s)
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+ return s->sy_weakrefd != 0;
+}
+
+int
S_IS_COMMON (symbolS *s)
{
if (LOCAL_SYMBOL_CHECK (s))
@@ -2013,6 +2076,60 @@
}
void
+S_SET_WEAKREFR (symbolS *s)
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_weakrefr = 1;
+ /* If the alias was already used, make sure we mark the target as
+ used as well, otherwise it might be dropped from the symbol
+ table. This may have unintended side effects if the alias is
+ later redirected to another symbol, such as keeping the unused
+ previous target in the symbol table. Since it will be weak, it's
+ not a big deal. */
+ if (s->sy_used)
+ symbol_mark_used (s->sy_value.X_add_symbol);
+}
+
+void
+S_CLEAR_WEAKREFR (symbolS *s)
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ s->sy_weakrefr = 0;
+}
+
+void
+S_SET_WEAKREFD (symbolS *s)
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_weakrefd = 1;
+ S_SET_WEAK (s);
+}
+
+void
+S_CLEAR_WEAKREFD (symbolS *s)
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ if (s->sy_weakrefd)
+ {
+ s->sy_weakrefd = 0;
+ /* If a weakref target symbol is weak, then it was never
+ referenced directly before, not even in a .global directive,
+ so decay it to local. If it remains undefined, it will be
+ later turned into a global, like any other undefined
+ symbol. */
+ if (s->bsym->flags & BSF_WEAK)
+ {
+ s->bsym->flags &= ~BSF_WEAK;
+ s->bsym->flags |= BSF_LOCAL;
+ }
+ }
+}
+
+void
S_SET_THREAD_LOCAL (symbolS *s)
{
if (LOCAL_SYMBOL_CHECK (s))
@@ -2095,6 +2212,7 @@
if (LOCAL_SYMBOL_CHECK (s))
s = local_symbol_convert ((struct local_symbol *) s);
s->sy_value = *exp;
+ S_CLEAR_WEAKREFR (s);
}
/* Return a pointer to the X_add_number component of a symbol. */
@@ -2129,6 +2247,7 @@
return;
}
s->sy_frag = f;
+ S_CLEAR_WEAKREFR (s);
}
/* Return the frag of a symbol. */
@@ -2149,6 +2268,8 @@
if (LOCAL_SYMBOL_CHECK (s))
return;
s->sy_used = 1;
+ if (S_IS_WEAKREFR (s))
+ symbol_mark_used (s->sy_value.X_add_symbol);
}
/* Clear the mark of whether a symbol has been used. */
@@ -2472,11 +2593,17 @@
fprintf (file, " local");
if (S_IS_EXTERNAL (sym))
fprintf (file, " extern");
+ if (S_IS_WEAK (sym))
+ fprintf (file, " weak");
if (S_IS_DEBUG (sym))
fprintf (file, " debug");
if (S_IS_DEFINED (sym))
fprintf (file, " defined");
}
+ if (S_IS_WEAKREFR (sym))
+ fprintf (file, " weakrefr");
+ if (S_IS_WEAKREFD (sym))
+ fprintf (file, " weakrefd");
fprintf (file, " %s", segment_name (S_GET_SEGMENT (sym)));
if (symbol_resolved_p (sym))
{
Index: gas/symbols.h
===================================================================
--- gas/symbols.h.orig 2005-10-11 10:04:20.000000000 -0300
+++ gas/symbols.h 2005-10-11 10:09:06.000000000 -0300
@@ -37,7 +37,9 @@
char *decode_local_label_name (char *s);
symbolS *symbol_find (const char *name);
+symbolS *symbol_find_noref (const char *name, int noref);
symbolS *symbol_find_exact (const char *name);
+symbolS *symbol_find_exact_noref (const char *name, int noref);
symbolS *symbol_find_or_make (const char *name);
symbolS *symbol_make (const char *name);
symbolS *symbol_new (const char *name, segT segment, valueT value,
@@ -83,6 +85,8 @@
extern int S_IS_FUNCTION (symbolS *);
extern int S_IS_EXTERNAL (symbolS *);
extern int S_IS_WEAK (symbolS *);
+extern int S_IS_WEAKREFR (symbolS *);
+extern int S_IS_WEAKREFD (symbolS *);
extern int S_IS_COMMON (symbolS *);
extern int S_IS_DEFINED (symbolS *);
extern int S_FORCE_RELOC (symbolS *, int);
@@ -98,6 +102,10 @@
extern void S_SET_NAME (symbolS *, const char *);
extern void S_CLEAR_EXTERNAL (symbolS *);
extern void S_SET_WEAK (symbolS *);
+extern void S_SET_WEAKREFR (symbolS *);
+extern void S_CLEAR_WEAKREFR (symbolS *);
+extern void S_SET_WEAKREFD (symbolS *);
+extern void S_CLEAR_WEAKREFD (symbolS *);
extern void S_SET_THREAD_LOCAL (symbolS *);
extern void S_SET_VOLATILE (symbolS *);
extern void S_SET_FORWARD_REF (symbolS *);
Index: gas/write.c
===================================================================
--- gas/write.c.orig 2005-10-11 10:00:47.000000000 -0300
+++ gas/write.c 2005-10-11 10:09:06.000000000 -0300
@@ -678,13 +678,15 @@
/* If this symbol is equated to an undefined or common symbol,
convert the fixup to being against that symbol. */
- if (symbol_equated_reloc_p (sym))
+ if (symbol_equated_reloc_p (sym)
+ || S_IS_WEAKREFR (sym))
{
symbolS *new_sym
= symbol_get_value_expression (sym)->X_add_symbol;
const char *name = S_GET_NAME (sym);
if (!S_IS_COMMON (new_sym)
&& !TC_FAKE_LABEL (name)
+ && !S_IS_WEAKREFR (sym)
&& (!S_IS_EXTERNAL (sym) || S_IS_LOCAL (sym)))
as_bad (_("Local symbol `%s' can't be equated to undefined symbol `%s'"),
name, S_GET_NAME (new_sym));
@@ -1483,11 +1485,13 @@
/* Skip symbols which were equated to undefined or common
symbols. */
- if (symbol_equated_reloc_p (symp))
+ if (symbol_equated_reloc_p (symp)
+ || S_IS_WEAKREFR (symp))
{
const char *name = S_GET_NAME (symp);
if (S_IS_COMMON (symp)
&& !TC_FAKE_LABEL (name)
+ && !S_IS_WEAKREFR (symp)
&& (!S_IS_EXTERNAL (symp) || S_IS_LOCAL (symp)))
{
expressionS *e = symbol_get_value_expression (symp);
Index: gas/doc/as.texinfo
===================================================================
--- gas/doc/as.texinfo.orig 2005-10-11 10:04:21.000000000 -0300
+++ gas/doc/as.texinfo 2005-10-11 10:09:06.000000000 -0300
@@ -3842,6 +3842,7 @@
* Warning:: @code{.warning @var{string}}
* Weak:: @code{.weak @var{names}}
+* Weakref:: @code{.weakref @var{alias}, @var{symbol}}
* Word:: @code{.word @var{expressions}}
* Deprecated:: Deprecated Directives
@end menu
@@ -5989,6 +5990,25 @@
When a weak symbol is created that is not an alias, GAS creates an
alternate symbol to hold the default value.
+@node Weakref
+@section @code{.weakref @var{alias}, @var{target}}
+
+@cindex @code{weakref} directive
+This directive creates an alias to the target symbol that enables the symbol to
+be referenced with weak-symbol semantics, but without actually making it weak.
+If direct references or definitions of the symbol are present, then the symbol
+will not be weak, but if all references to it are through weak references, the
+symbol will be marked as weak in the symbol table.
+
+The effect is equivalent to moving all references to the alias to a separate
+assembly source file, renaming the alias to the symbol in it, declaring the
+symbol as weak there, and running a reloadable link to merge the object files
+resulting from the assembly of the new source file and the old source file that
+had the references to the alias removed.
+
+The alias itself never makes to the symbol table, and is entirely handled
+within the assembler.
+
@node Word
@section @code{.word @var{expressions}}
Index: gas/doc/internals.texi
===================================================================
--- gas/doc/internals.texi.orig 2005-10-11 10:00:47.000000000 -0300
+++ gas/doc/internals.texi 2005-10-11 10:09:06.000000000 -0300
@@ -93,6 +93,13 @@
Whether the symbol is an MRI common symbol created by the @code{COMMON}
pseudo-op when assembling in MRI mode.
+@item sy_weakrefr
+Whether the symbol is a @code{weakref} alias to another symbol.
+
+@item sy_weakrefd
+Whether the symbol is or was referenced by one or more @code{weakref} aliases,
+and has not had any direct references.
+
@item bsym
This points to the BFD @code{asymbol} that
will be used in writing the object file.
@@ -146,7 +153,17 @@
@item S_IS_WEAK
@cindex S_IS_WEAK
-Return non-zero if the symbol is weak.
+Return non-zero if the symbol is weak, or if it is a @code{weakref} alias or
+symbol that has not been strongly referenced.
+
+@item S_IS_WEAKREFR
+@cindex S_IS_WEAKREFR
+Return non-zero if the symbol is a @code{weakref} alias.
+
+@item S_IS_WEAKREFD
+@cindex S_IS_WEAKREFD
+Return non-zero if the symbol was aliased by a @code{weakref} alias and has not
+had any strong references.
@item S_IS_COMMON
@cindex S_IS_COMMON
@@ -182,6 +199,29 @@
@cindex S_SET_WEAK
Mark the symbol as weak.
+@item S_SET_WEAKREFR
+@cindex S_SET_WEAKREFR
+Mark the symbol as the referrer in a @code{weakref} directive. The symbol it
+aliases must have been set to the value expression before this point. If the
+alias has already been used, the symbol is marked as used too.
+
+@item S_CLEAR_WEAKREFR
+@cindex S_CLEAR_WEAKREFR
+Clear the @code{weakref} alias status of a symbol. This is implicitly called
+whenever a symbol is defined or set to a new expression.
+
+@item S_SET_WEAKREFD
+@cindex S_SET_WEAKREFD
+Mark the symbol as the referred symbol in a @code{weakref} directive.
+Implicitly marks the symbol as weak, but see below. It should only be called
+if the referenced symbol has just been added to the symbol table.
+
+@item S_SET_WEAKREFD
+@cindex S_SET_WEAKREFD
+Clear the @code{weakref} aliased status of a symbol. This is implicitly called
+whenever the symbol is looked up, as part of a direct reference or a
+definition, but not as part of a @code{weakref} directive.
+
@item S_GET_TYPE
@item S_GET_DESC
@item S_GET_OTHER
Index: gas/testsuite/gas/all/gas.exp
===================================================================
--- gas/testsuite/gas/all/gas.exp.orig 2005-10-11 10:04:22.000000000 -0300
+++ gas/testsuite/gas/all/gas.exp 2005-10-11 10:09:06.000000000 -0300
@@ -250,6 +250,10 @@
run_dump_test quad
}
+run_dump_test weakref1
+gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
+gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
+
load_lib gas-dg.exp
dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
Index: gas/testsuite/gas/all/weakref1.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gas/testsuite/gas/all/weakref1.d 2005-10-11 10:09:06.000000000 -0300
@@ -0,0 +1,176 @@
+#objdump: -tr
+#name: weakref tests
+
+#...
+SYMBOL TABLE:
+.* \.text
+.* \.data
+.* \.bss
+# the rest of this file is generated with the following script:
+# # script begin
+# sed -n 's,^\(l[^ ]*\) *[:=].*,[0-9a-f]+ l .* \1,p' weakref1.s | uniq
+# sed -n 's:^\.weakref .*, \(\(u\|\(w\)\).*\)$:0+ \3 .* \1:p' weakref1.s | uniq
+# sed -n 's:^\.global \(g.*\):[0-9a-f]+ g .* \1:p' weakref1.s | uniq
+# echo; echo; echo 'RELOCATION RECORDS FOR \[\.text\]:'; echo 'OFFSET +TYPE +VALUE *'
+# sed -n 's:^\.long \(W\|\)\(.*[^a-z]\)[a-z]*\(\| - .*\)$:\2:p' weakref1.s | sed -e 's,^l.*,\\.text,;' | sed 's,^,[0-9a-f]+ R_[^ ]* +,'
+# # script output:
+[0-9a-f]+ l .* l
+[0-9a-f]+ l .* lr1
+[0-9a-f]+ l .* lr2
+[0-9a-f]+ l .* lr6
+[0-9a-f]+ l .* lr7
+[0-9a-f]+ l .* ld1
+[0-9a-f]+ l .* ld2
+[0-9a-f]+ l .* ld3
+[0-9a-f]+ l .* ld4
+[0-9a-f]+ l .* ld8
+[0-9a-f]+ l .* ld9
+0+ w .* wa1
+0+ .* ua2
+0+ .* ua3
+0+ .* ua4
+0+ w .* wb1
+0+ .* ub2
+0+ .* ub3
+0+ .* ub4
+0+ w .* wc1
+0+ .* uc2
+0+ .* uc3
+0+ .* uc4
+0+ .* uc5
+0+ .* uc6
+0+ .* uc7
+0+ .* uc8
+0+ .* uc9
+0+ w .* ww1
+0+ w .* ww2
+0+ w .* ww3
+0+ w .* ww4
+0+ w .* ww5
+0+ w .* ww6
+0+ w .* ww7
+0+ w .* ww8
+0+ w .* ww9
+0+ w .* ww10
+0+ .* um2
+0+ w .* wm3
+0+ .* um5
+0+ w .* wm6
+0+ w .* wm7
+0+ w .* wm8
+0+ w .* wh2
+0+ w .* wh3
+0+ w .* wh4
+0+ w .* wh5
+0+ w .* wh6
+0+ w .* wh7
+0+ .* uh8
+0+ .* uh9
+0+ w .* wr1
+0+ w .* wr2
+0+ w .* wr3
+0+ w .* wr4
+0+ w .* wr5
+0+ .* ur6
+0+ w .* wr7
+0+ .* ud5
+[0-9a-f]+ g .* gd6
+[0-9a-f]+ g .* gd7
+
+
+RELOCATION RECORDS FOR \[\.text\]:
+OFFSET +TYPE +VALUE *
+[0-9a-f]+ R_[^ ]* +wa1
+[0-9a-f]+ R_[^ ]* +ua2
+[0-9a-f]+ R_[^ ]* +ua3
+[0-9a-f]+ R_[^ ]* +ua3
+[0-9a-f]+ R_[^ ]* +ua4
+[0-9a-f]+ R_[^ ]* +ua4
+[0-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^ ]* +\.text
+[0-9a-f]+ R_[^ ]* +\.text
+[0-9a-f]+ R_[^ ]* +\.text
Index: gas/testsuite/gas/all/weakref1.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gas/testsuite/gas/all/weakref1.s 2005-10-11 10:09:06.000000000 -0300
@@ -0,0 +1,278 @@
+l:
+/* a# test references after weakref. */
+.weakref Wwa1, wa1
+.long Wwa1
+
+.weakref Wua2, ua2
+.long ua2
+
+.weakref Wua3, ua3
+.long Wua3
+.long ua3
+
+.weakref Wua4, ua4
+.long ua4
+.long Wua4
+
+.weakref Wna5, na5
+
+/* b# test references before weakref. */
+.long Wwb1
+.weakref Wwb1, wb1
+
+.long ub2
+.weakref Wub2, ub2
+
+.long Wub3
+.long ub3
+.weakref Wub3, ub3
+
+.long ub4
+.long Wub4
+.weakref Wub4, ub4
+
+/* c# test combinations of references before and after weakref. */
+.long Wwc1
+.weakref Wwc1, wc1
+.long Wwc1
+
+.long uc2
+.weakref Wuc2, uc2
+.long uc2
+
+.long Wuc3
+.long uc3
+.weakref Wuc3, uc3
+.long Wuc3
+.long uc3
+
+.long uc4
+.long Wuc4
+.weakref Wuc4, uc4
+.long uc4
+.long Wuc4
+
+.long Wuc5
+.long uc5
+.weakref Wuc5, uc5
+.long uc5
+.long Wuc5
+
+.long uc6
+.long Wuc6
+.weakref Wuc6, uc6
+.long uc6
+.long Wuc6
+
+.long uc7
+.weakref Wuc7, uc7
+.long Wuc7
+
+.long Wuc8
+.weakref Wuc8, uc8
+.long uc8
+
+.long Wuc9
+.weakref Wuc9, uc9
+.long Wuc9
+.long uc9
+
+/* w# test that explicitly weak target don't lose the weak status */
+.weakref Www1, ww1
+.weak ww1
+.long ww1
+
+.weak ww2
+.weakref Www2, ww2
+.long ww2
+
+.weak ww3
+.long ww3
+.weakref Www3, ww3
+.long ww3
+
+.long ww4
+.weakref Www4, ww4
+.weak ww4
+.long ww4
+
+.long ww5
+.weakref Www5, ww5
+.long ww5
+.weak ww5
+
+.weakref Www6, ww6
+.weak ww6
+.long Www6
+
+.weak ww7
+.weakref Www7, ww7
+.long Www7
+
+.weak ww8
+.long Www8
+.weakref Www8, ww8
+.long Www8
+
+.long Www9
+.weakref Www9, ww9
+.weak ww9
+.long Www9
+
+.long Www10
+.weakref Www10, ww10
+.long Www10
+.weak ww10
+
+/* m# test multiple weakrefs */
+.weakref Wnm1, nm1
+.weakref Wnm1, nm1
+
+.weakref Wum2, um2
+.weakref Wum2, um2
+.long um2
+
+.weakref Wwm3, wm3
+.weakref Wwm3, wm3
+.long Wwm3
+
+.weakref Wnm4a, nm4
+.weakref Wnm4b, nm4
+
+.weakref Wum5a, um5
+.weakref Wum5b, um5
+.long um5
+
+.weakref Wwm6a, wm6
+.weakref Wwm6b, wm6
+.long Wwm6a
+
+.weakref Wwm7a, wm7
+.weakref Wwm7b, wm7
+.long Wwm7b
+
+.weakref Wwm8a, wm8
+.long Wwm8b
+.weakref Wwm8b, wm8
+
+/* h# test weakref chain */
+.weakref Wnh1a, nh1
+.weakref Wnh1b, Wnh1a
+.weakref Wnh1c, Wnh1b
+
+.weakref Wwh2a, wh2
+.weakref Wwh2b, Wwh2a
+.long Wwh2b
+
+.weakref Wwh3a, wh3
+.weakref Wwh3b, Wwh3a
+.long Wwh3a
+
+.weakref Wwh4b, Wwh4a
+.weakref Wwh4a, wh4
+.long Wwh4b
+
+.long Wwh5b
+.weakref Wwh5a, wh5
+.weakref Wwh5b, Wwh5a
+
+.long Wwh6b
+.weakref Wwh6b, Wwh6a
+.weakref Wwh6a, wh6
+
+.weakref Wwh7b, Wwh7a
+.long Wwh7b
+.weakref Wwh7a, wh7
+
+.long Wuh8c
+.weakref Wuh8a, uh8
+.weakref Wuh8b, Wuh8a
+.weakref Wuh8c, Wuh8b
+.long uh8
+
+.long Wuh9c
+.weakref Wuh9c, Wuh9b
+.weakref Wuh9b, Wuh9a
+.weakref Wuh9a, uh9
+.long uh9
+
+/* r# weakref redefinitions, to and from */
+.weakref lr1, wr1
+.long lr1
+/* the above marks the target as used immediately, fixme? */
+lr1 = l
+.long lr1
+
+.long lr2
+.weakref lr2, wr2
+/* the above marks the target as used immediately, fixme? */
+lr2 = l
+.long lr2
+
+Wwr3 = l
+.long Wwr3
+.weakref Wwr3, wr3
+.long Wwr3
+
+Wwr4 = l
+.weakref Wwr4, wr4
+.long Wwr4
+
+Wwr5 = l
+.long Wwr5
+.weakref Wwr5, wr5
+
+.weakref lr6, ur6
+.long lr6
+lr6 = l
+.long ur6
+
+.weakref lr7, wr7
+.long lr7 - (lr7 - l)
+lr7:
+.long lr7 - (lr7 - l)
+
+/* d# target symbol definitions */
+.weakref Wld1, ld1
+.long Wld1
+ld1 = l
+
+.weakref Wld2, ld2
+.long Wld2 - (ld2 - l)
+ld2:
+
+ld3:
+.weakref Wld3, ld3
+.long Wld3 - (ld3 - l)
+
+ld4:
+.long Wld4 - (ld4 - l)
+.weakref Wld4, ld4
+
+.global ud5
+.weakref Wud5, ud5
+.long Wud5
+
+.global gd6
+.weakref Wgd6, gd6
+.long Wgd6
+gd6:
+
+.weakref Wgd7, gd7
+.long Wgd7
+.global gd7
+gd7:
+
+.long Wld8c - (ld8 - l)
+.weakref Wld8a, ld8
+.weakref Wld8b, Wld8a
+.weakref Wld8c, Wld8b
+.long ld8 - (ld8 - l)
+ld8:
+
+.long Wld9c - (ld9 - l)
+.weakref Wld9c, Wld9b
+.weakref Wld9b, Wld9a
+.weakref Wld9a, ld9
+.long ld9 - (ld9 - l)
+ld9:
Index: gas/testsuite/gas/all/weakref2.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gas/testsuite/gas/all/weakref2.s 2005-10-11 10:09:06.000000000 -0300
@@ -0,0 +1,5 @@
+.weakref a,b
+.weakref b,c
+.weakref c,d
+.weakref d,e
+.weakref e,a
Index: gas/testsuite/gas/all/weakref3.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gas/testsuite/gas/all/weakref3.s 2005-10-11 10:09:06.000000000 -0300
@@ -0,0 +1,5 @@
+.weakref e,a
+.weakref d,e
+.weakref c,d
+.weakref b,c
+.weakref a,b
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}