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.
This commit is contained in:
Alan Modra
2021-01-18 09:38:22 +10:30
parent 994b251328
commit 44365e88c0
6 changed files with 21 additions and 0 deletions

View 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,

View 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;

View File

@ -1293,6 +1293,7 @@ if [gas_64_check] then {
}
}
run_dump_test pr27198
set ASFLAGS "$old_ASFLAGS --64"

View File

@ -0,0 +1,2 @@
#as:
#error_output: pr27198.err

View File

@ -0,0 +1,5 @@
#failif
#...
.*Internal error.*
#pass

View File

@ -0,0 +1 @@
call (%rax)junk