From: Alan Modra Date: Sun, 17 Jan 2021 23:08:22 +0000 (+1030) Subject: PR27198, segv in S_IS_WEAK X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44365e88c0e021a7f734e44aa845f1e96cd83389;p=binutils-gdb.git PR27198, segv in S_IS_WEAK 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. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index ab5cc98ba64..3d242869eac 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2021-01-18 Alan Modra + + 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 * config/tc-riscv.c: Indent and GNU coding standards tidy, diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index a7d2ff1c1f9..b0140e1128a 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -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; diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index c9bca8ab215..b4a75e4552f 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -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 index 00000000000..6cf0d547dcd --- /dev/null +++ b/gas/testsuite/gas/i386/pr27198.d @@ -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 index 00000000000..1f71543e1d4 --- /dev/null +++ b/gas/testsuite/gas/i386/pr27198.err @@ -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 index 00000000000..9ac98982f48 --- /dev/null +++ b/gas/testsuite/gas/i386/pr27198.s @@ -0,0 +1 @@ + call (%rax)junk