]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: don't fail due to local register symbols
authorJan Beulich <jbeulich@suse.com>
Mon, 20 Apr 2026 06:36:54 +0000 (08:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 20 Apr 2026 06:36:54 +0000 (08:36 +0200)
The diagnostic text as well as its origin are pretty clear: This is about
global symbols. This is further supported by S_IS_LOCAL() returning true
for symbols in reg_section. Add the missing check, adjusting the testcase
that was introduced back at the time (where the sole diagnostic originally
issued was therefore wrong, while other diagnostics were missing, but got
added thanks to work done elsewhere). Further drop the bogus trailing .equ
in another testcase, which were apparently put there to avoid tripping
this or some other undue check (albeit no error surfaced there already
before the change here).

While there also fully eliminate the redundant "sname": There's "name"
already, getting set up a little earlier.

gas/testsuite/gas/i386/equ.s
gas/testsuite/gas/i386/inval-equ-2.l
gas/testsuite/gas/i386/inval-equ-2.s
gas/write.c

index c7c4e604f03cba68613749e7b68f021cab450c1d..30401ca9c1e91e73c12126f40a19461b8d2d677a 100644 (file)
@@ -59,6 +59,3 @@ _start:
  .if s == x
  .err
  .endif
-
- .equ r, -3
- .equ s, -3
index 839bc8d3523719ef5a3ebf53f79cf724f56606f4..d4c7f1714174abd97cfbc26e37e95819796d4c35 100644 (file)
@@ -18,10 +18,13 @@ GAS LISTING .*
 [      ]*6[    ]+\.globl  bar2
 [      ]*7[    ]+\.set    bar3,\(%eax\+1\)
 [      ]*8[    ]+\?\?\?\? A1......             mov bar3,%eax
+[      ]*8[    ]+..
+[      ]*9[    ]+\.globl  bar4
+[      ]*10[   ]+\.set    bar4,\(%eax\+1\)
+[      ]*11[   ]+\?\?\?\? 90                   nop
 .*  Error: invalid .* relocation against register
 .*  Error: invalid .* relocation against register
 .*  Error: invalid .* relocation against register
 .*  Error: can't make global register symbol `bar1'
 .*  Error: can't make global register symbol `bar2'
-.*  Error: can't make global register symbol `bar3'
-[      ]*8[    ]+..
+.*  Error: can't make global register symbol `bar4'
index 90caa25df37713d638948e63475891306cf5c691..afc13eb86e87c9b9bdf56e9ee7d5b46589854a5a 100644 (file)
@@ -6,3 +6,6 @@
        .globl  bar2
        .set    bar3,(%eax+1)
        mov bar3,%eax
+       .globl  bar4
+       .set    bar4,(%eax+1)
+       nop
index 9d0777051dde8695c24d31de1a7a0bd2d9bdfbf5..9bb47857936099246cd07b99c04b83070109ce84 100644 (file)
@@ -2396,24 +2396,22 @@ write_object_file (void)
          if (symbol_equated_reloc_p (symp)
              || S_IS_WEAKREFR (symp))
            {
-             const char *sname = S_GET_NAME (symp);
-
              if (S_IS_COMMON (symp)
-                 && !TC_FAKE_LABEL (sname)
+                 && !TC_FAKE_LABEL (name)
                  && !S_IS_WEAKREFR (symp))
                {
                  expressionS *e = symbol_get_value_expression (symp);
 
                  as_bad (_("`%s' can't be equated to common symbol `%s'"),
-                         sname, S_GET_NAME (e->X_add_symbol));
+                         name, S_GET_NAME (e->X_add_symbol));
                }
-             if (S_GET_SEGMENT (symp) == reg_section)
-               {
+
+             if (S_GET_SEGMENT (symp) == reg_section
+                 && S_IS_EXTERNAL (symp)
                  /* Report error only if we know the symbol name.  */
-                 if (S_GET_NAME (symp) != reg_section->name)
-                   as_bad (_("can't make global register symbol `%s'"),
-                           sname);
-               }
+                 && name != reg_section->name)
+               as_bad (_("can't make global register symbol `%s'"), name);
+
              symbol_remove (symp, &symbol_rootP, &symbol_lastP);
              continue;
            }