]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
mmix bfd: fix bfd_assert for R_MMIX_PUSHJ_STUBBABLE against undef'd symbol
authorHans-Peter Nilsson <hp@bitrange.com>
Wed, 15 Jul 2020 04:22:28 +0000 (06:22 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Wed, 15 Jul 2020 04:22:28 +0000 (06:22 +0200)
Spotted when inspecting gcc testsuite logs, but this already is
covered by the ld-mmix testsuite, it's just that the assert is ignored
since the regexp match is for a substring and not anchored.

With the anchors added but not the bugfix, the ld.log shows that the
asserts cause a non-match as intended:

Executing on host: sh -c {./ld-new   -LX/src/ld/testsuite/ld-mmix  -m elf64mmix -o tmpdir/dump tmpdir/undef-2.o tmpdir/start.o  2>&1}  /dev/null dump.tmp (timeout = 300)
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: tmpdir/undef-2.o:(.text+0x0): undefined reference to `undefd'
failed with: <./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: BFD (GNU Binutils) 2.34.50.20200629 assertion fail X/src/bfd/elf64-mmix.c:2845
./ld-new: tmpdir/undef-2.o:(.text+0x0): undefined reference to `undefd'>, expected: <\A[^\n\r]*undefined reference to `undefd'\Z>
FAIL: ld-mmix/undef-2

Gone with the fix of course, leaving just the intended "undefined
reference" like.

I'm not going to add anchors manually for all the "error:" strings in
the test-suite, not even in the mmix parts.  Sorry, but I'll just do
it for *these* specific undefined-reference tests.

Just a thought: maybe the run_dump_test "error:" string should
*automatically* get anchor marks prepended and appended for a single
line match as in the patch, "\A[^\n\r]*" prepended and \Z appended
unless either anchor mark or \r or \n is present in the regexp?

Committed.

bfd:
* elf64-mmix.c (mmix_elf_relax_section): Improve accounting for
R_MMIX_PUSHJ_STUBBABLE relocs against undefined symbols.

ld/testsuite:
* testsuite/ld-mmix/undef-1.d, testsuite/ld-mmix/undef-1m.d,
testsuite/ld-mmix/undef-2.d, testsuite/ld-mmix/undef-2m.d: Add
start- and end-anchors to error-string to match just a
single-line error-message.

bfd/ChangeLog
bfd/elf64-mmix.c
ld/ChangeLog
ld/testsuite/ld-mmix/undef-1.d
ld/testsuite/ld-mmix/undef-1m.d
ld/testsuite/ld-mmix/undef-2.d
ld/testsuite/ld-mmix/undef-2m.d

index 813e3f219bfc7dc96d4a81903e3ef355cbdf2efd..321e2e060bda982d9dbf96653bc8641535e1ea9e 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-15  Hans-Peter Nilsson  <hp@bitrange.com>
+
+       * elf64-mmix.c (mmix_elf_relax_section): Improve accounting for
+       R_MMIX_PUSHJ_STUBBABLE relocs against undefined symbols.
+
 2020-07-15  Markus Böck  <markus.boeck02@gmail.com>
            Alan Modra  <amodra@gmail.com>
 
index fee4a0fbd78c778b2d63bb2c6c10b98a7680fcab..2fc491c5ffa268d133a10a1235d6b0978f5534e6 100644 (file)
@@ -2538,6 +2538,7 @@ mmix_elf_relax_section (bfd *abfd,
      spot a missing actual initialization.  */
   size_t bpono = (size_t) -1;
   size_t pjsno = 0;
+  size_t pjsno_undefs = 0;
   Elf_Internal_Sym *isymbuf = NULL;
   bfd_size_type size = sec->rawsize ? sec->rawsize : sec->size;
 
@@ -2703,6 +2704,11 @@ mmix_elf_relax_section (bfd *abfd,
                  gregdata->n_remaining_bpo_relocs_this_relaxation_round--;
                  bpono++;
                }
+
+             /* Similarly, keep accounting consistent for PUSHJ
+                referring to an undefined symbol.  */
+             if (ELF64_R_TYPE (irel->r_info) == R_MMIX_PUSHJ_STUBBABLE)
+               pjsno_undefs++;
              continue;
            }
        }
@@ -2842,7 +2848,8 @@ mmix_elf_relax_section (bfd *abfd,
        }
     }
 
-  BFD_ASSERT(pjsno == mmix_elf_section_data (sec)->pjs.n_pushj_relocs);
+  BFD_ASSERT(pjsno + pjsno_undefs
+            == mmix_elf_section_data (sec)->pjs.n_pushj_relocs);
 
   if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
index 98d10c0b73a867867a91d7dae721a4425691c472..b667566a889020ad2177b2f78c66eced2ba7fffa 100644 (file)
@@ -1,3 +1,10 @@
+2020-07-15  Hans-Peter Nilsson  <hp@bitrange.com>
+
+       * testsuite/ld-mmix/undef-1.d, testsuite/ld-mmix/undef-1m.d,
+       testsuite/ld-mmix/undef-2.d, testsuite/ld-mmix/undef-2m.d: Add
+       start- and end-anchors to error-string to match just a
+       single-line error-message.
+
 2020-07-13  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-scripts/default-script1.d: Don't skip, xfail
index fb8c7ee03a0e241d7c38cf554a4a867a51fcf6ef..ad8d757683ea73ff93bec3d2807083a0d7376303 100644 (file)
@@ -1,4 +1,4 @@
 #source: undef-1.s
 #source: start.s
 #ld: -m elf64mmix
-#error: undefined reference to `regvar'
+#error: \A[^\n\r]*undefined reference to `regvar'\Z
index 001d7f64b870e07638a0272587fa1ae8768a0938..e747e5026cc59cfb7f23b659eaa01e1acce670bc 100644 (file)
@@ -1,4 +1,4 @@
 #source: undef-1.s
 #source: start.s
 #ld: -m mmo
-#error: undefined reference to `regvar'
+#error: \A[^\n\r]*undefined reference to `regvar'\Z
index 52844dbad440008349f7f4b0cb702c89dc02585c..2dc2b4e4d5717d650e81df0464a4392e22554d17 100644 (file)
@@ -2,4 +2,4 @@
 #source: start.s
 #as: -x
 #ld: -m elf64mmix
-#error: undefined reference to `undefd'
+#error: \A[^\n\r]*undefined reference to `undefd'\Z
index aa0becc251ef4d8648147b427c43b50819328ddf..7eb3c673c621ca4d049d0713830c0bb304afa859 100644 (file)
@@ -2,4 +2,4 @@
 #source: start.s
 #as: -x
 #ld: -m mmo
-#error: undefined reference to `undefd'
+#error: \A[^\n\r]*undefined reference to `undefd'\Z