RE: PR 6848: Not all targets generate relocs against kept symbols.

View: New views
9 Messages — Rating Filter:   Alert me  

RE: PR 6848: Not all targets generate relocs against kept symbols.

by Nick Clifton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alan,

  Your fix for PR 6848 has introduced new testsuite failures for
  various ports, most notably the FRV:
 
FAIL: FRV TLS relocs, static linking
FAIL: FRV TLS relocs, dynamic linking
FAIL: FRV TLS relocs, pie linking
FAIL: FRV TLS relocs, shared linking
FAIL: FRV TLS relocs, shared linking with local binding
FAIL: FRV TLS relocs, static linking with relaxation
FAIL: FRV TLS relocs, dynamic linking with relaxation
FAIL: FRV TLS relocs, pie linking with relaxation
FAIL: FRV TLS relocs, shared linking with relaxation
FAIL: FRV TLS relocs with addends, dynamic linking
FAIL: FRV TLS relocs with addends, shared linking
FAIL: FRV TLS relocs with addends, shared linking with static TLS
FAIL: FRV TLS relocs with addends, dynamic linking, relaxing
FAIL: FRV TLS relocs with addends, shared linking, relaxing
FAIL: FRV TLS relocs with addends, shared linking with static TLS, relaxing

  and the MMIX:

FAIL: gas/mmix/err-bpo6.s (test for excess errors)
FAIL: gas/mmix/basep-1
FAIL: gas/mmix/basep-10
FAIL: gas/mmix/basep-1b
FAIL: gas/mmix/basep-2
FAIL: gas/mmix/basep-2b
FAIL: gas/mmix/basep-3
FAIL: gas/mmix/basep-3b
FAIL: gas/mmix/basep-7
FAIL: gas/mmix/basep-9
FAIL: gas/mmix/greg4
FAIL: gas/mmix/greg5
FAIL: gas/mmix/greg6
FAIL: gas/mmix/greg7
FAIL: gas/mmix/greg8

  I think that we need a target specific escape mechanism to allow
  relocs against unemitted symbols in certain cases.  Something like
  the patch below.  What do you think ?

Cheers
  Nick

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 write.c
*** gas/write.c 20 Aug 2008 13:43:32 -0000 1.118
--- gas/write.c 14 Sep 2008 09:00:41 -0000
*************** fix_segment (bfd *abfd ATTRIBUTE_UNUSED,
*** 1078,1083 ****
--- 1078,1087 ----
    fixup_segment (seginfo->fix_root, sec);
  }
 
+ #ifndef tc_allow_reloc_against_unemitted_symbol
+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) false
+ #endif
+
  static void
  install_reloc (asection *sec, arelent *reloc, fragS *fragp,
        char *file, unsigned int line)
*************** install_reloc (asection *sec, arelent *r
*** 1091,1098 ****
        && (sym->flags & BSF_KEEP) == 0
        && ((sym->flags & BSF_SECTION_SYM) == 0
   || !EMIT_SECTION_SYMBOLS
!  || !bfd_is_abs_section (sym->section)))
!     as_bad_where (file, line, _("redefined symbol cannot be used on reloc"));
 
    s = bfd_install_relocation (stdoutput, reloc,
       fragp->fr_literal, fragp->fr_address,
--- 1095,1103 ----
        && (sym->flags & BSF_KEEP) == 0
        && ((sym->flags & BSF_SECTION_SYM) == 0
   || !EMIT_SECTION_SYMBOLS
!  || !bfd_is_abs_section (sym->section))
!       && ! tc_allow_reloc_against_unemitted_symbol (reloc, sym))
!     as_bad_where (file, line, _("redefined symbol '%s' cannot be used on reloc"), sym->name);
 
    s = bfd_install_relocation (stdoutput, reloc,
       fragp->fr_literal, fragp->fr_address,
Index: gas/config/tc-frv.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-frv.h,v
retrieving revision 1.12
diff -c -3 -p -r1.12 tc-frv.h
*** gas/config/tc-frv.h 12 Aug 2008 23:39:30 -0000 1.12
--- gas/config/tc-frv.h 14 Sep 2008 09:00:41 -0000
*************** extern void frv_frob_file (void);
*** 122,124 ****
--- 122,127 ----
  } \
      } \
   while (0)
+
+ /* TLS relocs resolve to a dollar label, which is OK, since the linker will adjust them.  */
+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) (strchr (sym->name, '\001'))
Index: gas/config/tc-mmix.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.h,v
retrieving revision 1.12
diff -c -3 -p -r1.12 tc-mmix.h
*** gas/config/tc-mmix.h 3 Jul 2007 11:01:04 -0000 1.12
--- gas/config/tc-mmix.h 14 Sep 2008 09:00:41 -0000
*************** extern void mmix_md_do_align (int, char
*** 224,226 ****
--- 224,233 ----
 
  /* This target is buggy, and sets fix size too large.  */
  #define TC_FX_SIZE_SLACK(FIX) 6
+
+ #include "elf/mmix.h"
+
+ /* Allow relocs against the MMIX reg contents symbol - it will be
+    created by the linker.  */
+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) \
+   (strcmp (sym->name, MMIX_REG_CONTENTS_SECTION_NAME) == 0)
Index: gas/doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.60
diff -c -3 -p -r1.60 internals.texi
*** gas/doc/internals.texi 12 Aug 2008 23:39:31 -0000 1.60
--- gas/doc/internals.texi 14 Sep 2008 09:00:42 -0000
*************** poorly, as @code{bfd_install_relocation}
*** 1354,1359 ****
--- 1354,1369 ----
  instances of @code{tc_gen_reloc} have been written to work around the problems,
  which in turns makes it difficult to fix @code{bfd_install_relocation}.
 
+ @item tc_allow_reloc_against_unemitted_symbol (@var{reloc}, @var{sym})
+ @cindex tc_allow_reloc_against_unemitted_symbol
+ Define this macro if it is permissable for GAS to generate @var{reloc} against
+ symbol @var{sym} even though this symbol is not going to be emitted into the
+ symbol table of the object file.  GAs will normally refuse to emit a reloc
+ against a symbol which is not going to be in the symbol table, but this macro
+ allows targets to override this behaviour for specific relocations and symbols.
+ This may be necessary if the relocation ignores the symbol, or if the symbol is
+ going to be created by the linker.
+
  @item RELOC_EXPANSION_POSSIBLE
  @cindex RELOC_EXPANSION_POSSIBLE
  If you define this macro, it means that @code{tc_gen_reloc} may return multiple

Re: PR 6848: Not all targets generate relocs against kept symbols.

by Nick Clifton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alan,

   Oops, there was a typo in that patch:

+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) false

should be:

+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) FALSE

Cheers
   Nick




Re: PR 6848: Not all targets generate relocs against kept symbols.

by Alan Modra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Sep 14, 2008 at 10:10:34AM +0100, Nick Clifton wrote:
>   Your fix for PR 6848 has introduced new testsuite failures for
>   various ports, most notably the FRV:
[snip]
>   and the MMIX:
[snip]

Sigh.  I must have not run a multi-target test..  Oh well, I think we
can fix these closer to the point where the targets introduce the odd
symbols rather than weakening the reloc symbol check.  For FRV, I
don't see why expr_build_uconstant is needed.  The same is probably
true for the MMIX BFD_RELOC_MMIX_BASE_PLUS_OFFSET expresion symbol but
I couldn't convince myself of that so opted to mark the symbol.

        * config/tc-frv.c (md_apply_fix): Use abs_section_sym for
        relocs with no symbol.
        * config/tc-mmix.c (md_assemble): Mark fake symbol on
        BFD_RELOC_MMIX_BASE_PLUS_OFFSET as OK for use by relocs.
        (mmix_md_end): Likewise mark mmix reg contents section symbol.

Index: gas/config/tc-frv.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-frv.c,v
retrieving revision 1.25
diff -u -p -r1.25 tc-frv.c
--- gas/config/tc-frv.c 12 Aug 2008 23:39:30 -0000 1.25
+++ gas/config/tc-frv.c 15 Sep 2008 01:26:50 -0000
@@ -1475,7 +1475,7 @@ md_apply_fix (fixS *fixP, valueT *valP,
       case BFD_RELOC_FRV_TLSDESC_RELAX:
       case BFD_RELOC_FRV_GETTLSOFF_RELAX:
       case BFD_RELOC_FRV_TLSOFF_RELAX:
- fixP->fx_addsy = expr_build_uconstant (0);
+ fixP->fx_addsy = abs_section_sym;
  break;
       }
   else
Index: gas/config/tc-mmix.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.c,v
retrieving revision 1.30
diff -u -p -r1.30 tc-mmix.c
--- gas/config/tc-mmix.c 16 Jun 2008 15:04:41 -0000 1.30
+++ gas/config/tc-mmix.c 15 Sep 2008 02:58:38 -0000
@@ -1365,6 +1365,9 @@ md_assemble (char *str)
      pass expressions as symbols and use fix_new, not fix_new_exp.  */
   sym = make_expr_symbol (exp + 1);
 
+  /* Mark the symbol as being OK for a reloc.  */
+  symbol_get_bfdsym (sym)->flags |= BSF_KEEP;
+
   /* Now we know it can be a "base address plus offset".  Add
      proper fixup types so we can handle this later, when we've
      parsed everything.  */
@@ -3448,6 +3451,7 @@ mmix_md_end (void)
 {
   fragS *fragP;
   symbolS *mainsym;
+  asection *regsec;
   int i;
 
   /* The first frag of GREG:s going into the register contents section.  */
@@ -3512,9 +3516,9 @@ mmix_md_end (void)
  and the same allocation order (within a file) as mmixal.  */
       segT this_segment = now_seg;
       subsegT this_subsegment = now_subseg;
-      asection *regsec
- = bfd_make_section_old_way (stdoutput,
-    MMIX_REG_CONTENTS_SECTION_NAME);
+
+      regsec = bfd_make_section_old_way (stdoutput,
+ MMIX_REG_CONTENTS_SECTION_NAME);
       subseg_set (regsec, 0);
 
       /* Finally emit the initialization-value.  Emit a variable frag, which
@@ -3541,6 +3545,11 @@ mmix_md_end (void)
       subseg_set (this_segment, this_subsegment);
     }
 
+  regsec = bfd_get_section_by_name (stdoutput, MMIX_REG_CONTENTS_SECTION_NAME);
+  /* Mark the section symbol as being OK for a reloc.  */
+  if (regsec != NULL)
+    regsec->symbol->flags |= BSF_KEEP;
+
   /* Iterate over frags resulting from GREGs and move those that evidently
      have the same value together and point one to another.
 
--
Alan Modra
Australia Development Lab, IBM

Re: PR 6848: Not all targets generate relocs against kept symbols.

by Alan Modra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Another reason we had a rather lot of failures was a silly mistake on
my part when inverting some logic.

gas/
        * write.c (install_reloc): Correct EMIT_SECTION_SYMBOLS test.
gas/testsuite/
        * gas/all/gas.exp: Don't run redef tests on a bunch of targets.
        * gas/elf/elf.exp: Likewise.

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.118
diff -u -p -r1.118 write.c
--- gas/write.c 20 Aug 2008 13:43:32 -0000 1.118
+++ gas/write.c 15 Sep 2008 13:29:12 -0000
@@ -1090,8 +1090,8 @@ install_reloc (asection *sec, arelent *r
       && (sym = *reloc->sym_ptr_ptr) != NULL
       && (sym->flags & BSF_KEEP) == 0
       && ((sym->flags & BSF_SECTION_SYM) == 0
-  || !EMIT_SECTION_SYMBOLS
-  || !bfd_is_abs_section (sym->section)))
+  || (EMIT_SECTION_SYMBOLS
+      && !bfd_is_abs_section (sym->section))))
     as_bad_where (file, line, _("redefined symbol cannot be used on reloc"));
 
   s = bfd_install_relocation (stdoutput, reloc,
Index: gas/testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.54
diff -u -p -r1.54 gas.exp
--- gas/testsuite/gas/all/gas.exp 20 Aug 2008 23:38:39 -0000 1.54
+++ gas/testsuite/gas/all/gas.exp 15 Sep 2008 13:24:19 -0000
@@ -81,30 +81,39 @@ case $target_triplet in {
 }
 
 # .set works differently on some targets.
+# most of the tests won't work on targets that set linkrelax.
+# 4 octet bytes confuse address matching on ti targets.
+# pdp11 gets unexpected reloc types.
 case $target_triplet in {
     { alpha*-*-* } { }
+    { cr16*-*-* } { }
+    { crx*-*-* } { }
+    { h8300-*-* } { }
     { mips*-*-* } { }
-    { *c54x*-*-* } { }
+    { mn10200-*-* } { }
+    { mn10300-*-* } { }
+    { pdp11-*-* } { }
+    { tic30*-*-* } { }
+    { tic4x*-*-* } { }
+    { tic54x*-*-* } { }
+    { xtensa*-*-* } { }
     { z80-*-* } { }
     default {
- setup_xfail "*c30*-*-*" "*c4x*-*-*" "pdp11-*-*" "xtensa*-*-*"
  run_dump_test redef
  # The next two tests can fail if the target does not convert fixups
  # against ordinary symbols into relocations against section symbols.
  # This is usually revealed by the error message:
  #  symbol `sym' required but not present
- setup_xfail "*c30*-*-*" "*c4x*-*-*" "*arm*-*-*aout*" "*arm*-*-*coff" \
-    "*arm*-*-pe" "crx*-*-*" "h8300*-*-*" "m68hc*-*-*" "maxq-*-*" \
-    "mn10300-*-*" "pdp11-*-*" "vax*-*-*" "z8k-*-*" "cr16-*-*"
+ setup_xfail "*arm*-*-*aout*" "*arm*-*-*coff" \
+    "*arm*-*-pe" "m68hc*-*-*" "maxq-*-*" \
+    "vax*-*-*" "z8k-*-*"
  run_dump_test redef2
  setup_xfail "*-*-aix*" "*-*-coff" "*-*-cygwin" "*-*-mingw*" "*-*-pe*" \
-    "bfin-*-*" "*c4x*-*-*" "crx*-*-*" "h8300*-*-*" "hppa*-*-hpux*" \
-    "m68hc*-*-*" "maxq-*-*" "mn10300-*-*" "or32-*-*" "pdp11-*-*" \
-    "vax*-*-*" "z8k-*-*" "cr16-*-*"
+    "bfin-*-*" "hppa*-*-hpux*" \
+    "m68hc*-*-*" "maxq-*-*" "or32-*-*" \
+    "vax*-*-*" "z8k-*-*"
  run_dump_test redef3
- setup_xfail "*c4x*-*-*"
  gas_test_error "redef4.s" "" ".set for symbol already used as label"
- setup_xfail "*c4x*-*-*"
  gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
     }
 }
Index: gas/testsuite/gas/elf/elf.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/elf/elf.exp,v
retrieving revision 1.46
diff -u -p -r1.46 elf.exp
--- gas/testsuite/gas/elf/elf.exp 1 Feb 2008 17:58:48 -0000 1.46
+++ gas/testsuite/gas/elf/elf.exp 15 Sep 2008 13:24:19 -0000
@@ -88,16 +88,20 @@ if { ([istarget "*-*-*elf*"]
     run_dump_test "group1b"
     case $target_triplet in {
  { alpha*-*-* } { }
+ { cr16*-*-* } { }
+ { crx*-*-* } { }
+ { h8300-*-* } { }
  { hppa*-*-* } { }
  { iq2000*-*-* } { }
  { mips*-*-* } { }
+ { mn10200-*-* } { }
+ { mn10300-*-* } { }
  { *c54x*-*-* } { }
  default {
     # The next test can fail if the target does not convert fixups
     # against ordinary symbols into relocations against section symbols.
     # This is usually revealed by the error message:
     #  symbol `sym' required but not present
-    setup_xfail "cr16-*-*" "h8300-*-*" "mn10300-*-*"
     run_dump_test redef
     run_dump_test equ-reloc
  }

--
Alan Modra
Australia Development Lab, IBM

PR gas/5543 broke mmix: "can't equate global symbol foo with register name"

by Hans-Peter Nilsson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I see:
Running /home/hp/binutils/src/ld/testsuite/ld-mmix/mmix.exp ...
...
FAIL: ld-mmix/bpo-13
FAIL: ld-mmix/bpo-13m
FAIL: ld-mmix/local1
FAIL: ld-mmix/local1m
FAIL: ld-mmix/local2
FAIL: ld-mmix/local2m
FAIL: ld-mmix/local5
FAIL: ld-mmix/local5m
FAIL: ld-mmix/reg-1
FAIL: ld-mmix/reg-1m

where entries in ld.log say e.g.:
binutils/src/ld/testsuite/ld-mmix/areg-256.s:2: Error: can't equate global symbol `areg' with register name

This used to work.  cvs ann read.c shows you added the error
message above around March 3 to fix PR gas/5543.  Please fix the fix.

brgds, H-P

Re: PR gas/5543 broke mmix: "can't equate global symbol foo with register name"

by H.J. Lu-30 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 04, 2008 at 08:41:29PM -0400, Hans-Peter Nilsson wrote:

> I see:
> Running /home/hp/binutils/src/ld/testsuite/ld-mmix/mmix.exp ...
> ...
> FAIL: ld-mmix/bpo-13
> FAIL: ld-mmix/bpo-13m
> FAIL: ld-mmix/local1
> FAIL: ld-mmix/local1m
> FAIL: ld-mmix/local2
> FAIL: ld-mmix/local2m
> FAIL: ld-mmix/local5
> FAIL: ld-mmix/local5m
> FAIL: ld-mmix/reg-1
> FAIL: ld-mmix/reg-1m
>
> where entries in ld.log say e.g.:
> binutils/src/ld/testsuite/ld-mmix/areg-256.s:2: Error: can't equate global symbol `areg' with register name
>
> This used to work.  cvs ann read.c shows you added the error
> message above around March 3 to fix PR gas/5543.  Please fix the fix.
>

MMIX has

/* Symbol attributes.  */
/* A symbol with this section-index is a register.  */
#define SHN_REGISTER SHN_LOPROC

This patch allows global register symbol if GLOBAL_REGISTER_SYMBOL_OK
is defined.  OK to install?

Thanks.


H.J.
----
2008-10-05  H.J. Lu  <hongjiu.lu@...>

        * read.c (pseudo_set): Don't allow global register symbol only
        if GLOBAL_REGISTER_SYMBOL_OK is undefined.
        * symbols.c (S_SET_EXTERNAL): Likewise.

        * config/tc-mmix.h (GLOBAL_REGISTER_SYMBOL_OK): Defined.

--- gas/config/tc-mmix.h.reg 2007-07-03 06:45:21.000000000 -0700
+++ gas/config/tc-mmix.h 2008-10-05 12:26:54.000000000 -0700
@@ -224,3 +224,6 @@ extern void mmix_md_do_align (int, char
 
 /* This target is buggy, and sets fix size too large.  */
 #define TC_FX_SIZE_SLACK(FIX) 6
+
+/* MMIX has global register symbols.  */
+#define GLOBAL_REGISTER_SYMBOL_OK
--- gas/read.c.reg 2008-10-05 11:10:28.000000000 -0700
+++ gas/read.c 2008-10-05 12:26:40.000000000 -0700
@@ -3604,12 +3604,14 @@ pseudo_set (symbolS *symbolP)
       break;
 
     case O_register:
+#ifndef GLOBAL_REGISTER_SYMBOL_OK
       if (S_IS_EXTERNAL (symbolP))
  {
   as_bad ("can't equate global symbol `%s' with register name",
   S_GET_NAME (symbolP));
   return;
  }
+#endif
       S_SET_SEGMENT (symbolP, reg_section);
       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
       set_zero_frag (symbolP);
--- gas/symbols.c.reg 2008-03-03 07:29:13.000000000 -0800
+++ gas/symbols.c 2008-10-05 12:26:45.000000000 -0700
@@ -2184,12 +2184,14 @@ S_SET_EXTERNAL (symbolS *s)
      _("section symbols are already global"));
       return;
     }
+#ifndef GLOBAL_REGISTER_SYMBOL_OK
   if (S_GET_SEGMENT (s) == reg_section)
     {
       as_bad ("can't make register symbol `%s' global",
       S_GET_NAME (s));
       return;
     }
+#endif
   s->bsym->flags |= BSF_GLOBAL;
   s->bsym->flags &= ~(BSF_LOCAL | BSF_WEAK);
 

Re: PR gas/5543 broke mmix: "can't equate global symbol foo with register name"

by Hans-Peter Nilsson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 5 Oct 2008, H.J. Lu wrote:
> This patch allows global register symbol if GLOBAL_REGISTER_SYMBOL_OK
> is defined.  OK to install?

I think the convention is to call it e.g.
TC_GLOBAL_REGISTER_SYMBOL_OK, but (without actually testing it)
I don't see any other issues with the patch.
Thanks for the quick action!

brgds, H-P

Re: PR gas/5543 broke mmix: "can't equate global symbol foo with register name"

by Nick Clifton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,

 >> On Sun, 5 Oct 2008, H.J. Lu wrote:
 >> This patch allows global register symbol if GLOBAL_REGISTER_SYMBOL_OK
 >> is defined.  OK to install?

 > Hans-Peter Nilsson wrote:
> I think the convention is to call it e.g.
> TC_GLOBAL_REGISTER_SYMBOL_OK, but (without actually testing it)

Correct.  Also target macros like this should be documented in
gas/doc/internals.texi.

H.J.:  The patch is approved with these two changes.

Cheers
   Nick



Re: PR gas/5543 broke mmix: "can't equate global symbol foo with register name"

by H.J. Lu-30 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 06, 2008 at 09:07:51AM +0100, Nick Clifton wrote:

> Hi Guys,
>
> >> On Sun, 5 Oct 2008, H.J. Lu wrote:
> >> This patch allows global register symbol if GLOBAL_REGISTER_SYMBOL_OK
> >> is defined.  OK to install?
>
> > Hans-Peter Nilsson wrote:
>> I think the convention is to call it e.g.
>> TC_GLOBAL_REGISTER_SYMBOL_OK, but (without actually testing it)
>
> Correct.  Also target macros like this should be documented in  
> gas/doc/internals.texi.
>
> H.J.:  The patch is approved with these two changes.
>

I am checking in this patch.

Thanks.


H.J.
----
2008-10-07  H.J. Lu  <hongjiu.lu@...>

        * read.c (pseudo_set): Don't allow global register symbol only
        if TC_GLOBAL_REGISTER_SYMBOL_OK is undefined.
        * symbols.c (S_SET_EXTERNAL): Likewise.

        * config/tc-mmix.h (TC_GLOBAL_REGISTER_SYMBOL_OK): Defined.

        * doc/internals.texi: Document TC_GLOBAL_REGISTER_SYMBOL_OK.

--- gas/config/tc-mmix.h.reg 2007-07-03 06:45:21.000000000 -0700
+++ gas/config/tc-mmix.h 2008-10-07 07:12:19.000000000 -0700
@@ -224,3 +224,6 @@ extern void mmix_md_do_align (int, char
 
 /* This target is buggy, and sets fix size too large.  */
 #define TC_FX_SIZE_SLACK(FIX) 6
+
+/* MMIX has global register symbols.  */
+#define TC_GLOBAL_REGISTER_SYMBOL_OK
--- gas/doc/internals.texi.reg 2008-09-20 09:25:29.000000000 -0700
+++ gas/doc/internals.texi 2008-10-07 07:16:51.000000000 -0700
@@ -1325,6 +1325,11 @@ This macro is evaluated for any fixup wi
 @code{fixup_segment} cannot reduce to a number.  If the macro returns
 @code{false} an error will be reported.
 
+@item TC_GLOBAL_REGISTER_SYMBOL_OK
+@cindex TC_GLOBAL_REGISTER_SYMBOL_OK
+Define this macro if global register symbols are supported. The default
+is to disallow global register symbols.
+
 @item MD_APPLY_SYM_VALUE (@var{fix})
 @cindex MD_APPLY_SYM_VALUE
 This macro controls whether the symbol value becomes part of the value passed
--- gas/read.c.reg 2008-10-06 19:52:44.000000000 -0700
+++ gas/read.c 2008-10-07 07:12:19.000000000 -0700
@@ -3621,12 +3621,14 @@ pseudo_set (symbolS *symbolP)
       break;
 
     case O_register:
+#ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
       if (S_IS_EXTERNAL (symbolP))
  {
   as_bad ("can't equate global symbol `%s' with register name",
   S_GET_NAME (symbolP));
   return;
  }
+#endif
       S_SET_SEGMENT (symbolP, reg_section);
       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
       set_zero_frag (symbolP);
--- gas/symbols.c.reg 2008-08-22 08:07:08.000000000 -0700
+++ gas/symbols.c 2008-10-07 07:12:19.000000000 -0700
@@ -2191,12 +2191,14 @@ S_SET_EXTERNAL (symbolS *s)
      _("section symbols are already global"));
       return;
     }
+#ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
   if (S_GET_SEGMENT (s) == reg_section)
     {
       as_bad ("can't make register symbol `%s' global",
       S_GET_NAME (s));
       return;
     }
+#endif
   s->bsym->flags |= BSF_GLOBAL;
   s->bsym->flags &= ~(BSF_LOCAL | BSF_WEAK);