PR27198, segv in S_IS_WEAK
authorAlan Modra <amodra@gmail.com>
Sun, 17 Jan 2021 23:08:22 +0000 (09:38 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 18 Jan 2021 04:43:10 +0000 (15:13 +1030)
Fix a NULL dereference seen when assembling invalid input.

PR 27198
* config/tc-i386.c (need_plt32_p): Return FALSE for NULL symbol.
* testsuite/gas/i386/pr27198.d,
* gas/testsuite/gas/i386/pr27198.err,
* gas/testsuite/gas/i386/pr27198.s: New test.
* gas/testsuite/gas/i386/i386.exp: Run it.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/pr27198.d [new file with mode: 0644]
gas/testsuite/gas/i386/pr27198.err [new file with mode: 0644]
gas/testsuite/gas/i386/pr27198.s [new file with mode: 0644]

index ab5cc98ba649d733f507ec6bbe3cbcb53130b60a..3d242869eacac71512b100d35abc4bf438e43e14 100644 (file)
@@ -1,3 +1,12 @@
+2021-01-18  Alan Modra  <amodra@gmail.com>
+
+       PR 27198
+       * config/tc-i386.c (need_plt32_p): Return FALSE for NULL symbol.
+       * testsuite/gas/i386/pr27198.d,
+       * gas/testsuite/gas/i386/pr27198.err,
+       * gas/testsuite/gas/i386/pr27198.s: New test.
+       * gas/testsuite/gas/i386/i386.exp: Run it.
+
 2021-01-15  Nelson Chu  <nelson.chu@sifive.com>
 
        * config/tc-riscv.c: Indent and GNU coding standards tidy,
index a7d2ff1c1f91d0be837ed7dc9715d39e1ca8aa04..b0140e1128abc270188535875dd328e7f5791899 100644 (file)
@@ -8628,6 +8628,9 @@ need_plt32_p (symbolS *s)
   if (!object_64bit)
     return FALSE;
 
+  if (s == NULL)
+    return FALSE;
+
   /* Weak or undefined symbol need PLT32 relocation.  */
   if (S_IS_WEAK (s) || !S_IS_DEFINED (s))
     return TRUE;
index c9bca8ab215bca65e0be3c917ee5423f69d2c6ef..b4a75e4552ff244a4d92812cd2aafd197abce6c3 100644 (file)
@@ -1293,6 +1293,7 @@ if [gas_64_check] then {
        }
 
     }
+    run_dump_test pr27198
 
     set ASFLAGS "$old_ASFLAGS --64"
 
diff --git a/gas/testsuite/gas/i386/pr27198.d b/gas/testsuite/gas/i386/pr27198.d
new file mode 100644 (file)
index 0000000..6cf0d54
--- /dev/null
@@ -0,0 +1,2 @@
+#as:
+#error_output: pr27198.err
diff --git a/gas/testsuite/gas/i386/pr27198.err b/gas/testsuite/gas/i386/pr27198.err
new file mode 100644 (file)
index 0000000..1f71543
--- /dev/null
@@ -0,0 +1,5 @@
+#failif
+
+#...
+.*Internal error.*
+#pass
diff --git a/gas/testsuite/gas/i386/pr27198.s b/gas/testsuite/gas/i386/pr27198.s
new file mode 100644 (file)
index 0000000..9ac9898
--- /dev/null
@@ -0,0 +1 @@
+ call (%rax)junk