public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* x
@ 2021-01-18  0:28 Alan Modra
  2021-01-18  0:40 ` x H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2021-01-18  0:28 UTC (permalink / raw)
  To: binutils

From 047fc1a199fd859df6f662f7ce47cf1e7bdf4e4d Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Mon, 18 Jan 2021 09:38:22 +1030
Subject: PR27198, segv in S_IS_WEAK

This erroneous input
 call (%rax)printf
results in a NULL dereference.

A nicer fix might be to parse "call (%rax)junk" as "call (%rax)" which
is a variant of "call *%rax" missing the explicit indirection and with
some extra parentheses, but I figure it's not worth bothering.

OK?

	PR 27198
	* config/tc-i386.c (need_plt32_p): Return FALSE for NULL symbol.

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;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: x
  2021-01-18  0:28 x Alan Modra
@ 2021-01-18  0:40 ` H.J. Lu
  2021-01-18  2:32   ` PR27198, segv in S_IS_WEAK Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2021-01-18  0:40 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

On Sun, Jan 17, 2021 at 4:28 PM Alan Modra <amodra@gmail.com> wrote:
>
> From 047fc1a199fd859df6f662f7ce47cf1e7bdf4e4d Mon Sep 17 00:00:00 2001
> From: Alan Modra <amodra@gmail.com>
> Date: Mon, 18 Jan 2021 09:38:22 +1030
> Subject: PR27198, segv in S_IS_WEAK
>
> This erroneous input
>  call (%rax)printf
> results in a NULL dereference.
>
> A nicer fix might be to parse "call (%rax)junk" as "call (%rax)" which
> is a variant of "call *%rax" missing the explicit indirection and with
> some extra parentheses, but I figure it's not worth bothering.
>
> OK?
>
>         PR 27198
>         * config/tc-i386.c (need_plt32_p): Return FALSE for NULL symbol.
>
> 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;
>

OK with a testcase to show that the assembler issues an error
message.

Thanks.


-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PR27198, segv in S_IS_WEAK
  2021-01-18  0:40 ` x H.J. Lu
@ 2021-01-18  2:32   ` Alan Modra
  2021-01-18  2:44     ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2021-01-18  2:32 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On Sun, Jan 17, 2021 at 04:40:58PM -0800, H.J. Lu wrote:
> OK with a testcase to show that the assembler issues an error
> message.

This is what I'll commit after running regression tests.
(Apologies for the silly subject line at the start of this thread.)

	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/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


-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PR27198, segv in S_IS_WEAK
  2021-01-18  2:32   ` PR27198, segv in S_IS_WEAK Alan Modra
@ 2021-01-18  2:44     ` H.J. Lu
  0 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 2021-01-18  2:44 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils

On Sun, Jan 17, 2021 at 6:33 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Jan 17, 2021 at 04:40:58PM -0800, H.J. Lu wrote:
> > OK with a testcase to show that the assembler issues an error
> > message.
>
> This is what I'll commit after running regression tests.
> (Apologies for the silly subject line at the start of this thread.)
>
>         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/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
>
>

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* x
@ 2020-01-04  8:53 Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2020-01-04  8:53 UTC (permalink / raw)
  To: binutils

cpu/
	* m32r.cpu (f-disp8): Avoid left shift of negative values.
	(f-disp16, f-disp24): Likewise.
opcodes/
	* m32r-ibld.c: Regenerate.

diff --git a/cpu/m32r.cpu b/cpu/m32r.cpu
index 003c848687..a2395259b5 100644
--- a/cpu/m32r.cpu
+++ b/cpu/m32r.cpu
@@ -478,13 +478,13 @@
 (dnf f-hi16      "high 16 bits"        (SIGN-OPT) 16 16)
 (df f-disp8      "disp8, slot unknown" (PCREL-ADDR RELOC) 8 8 INT
     ((value pc) (sra WI (sub WI value (and WI pc (const -4))) (const 2)))
-    ((value pc) (add WI (sll WI value (const 2)) (and WI pc (const -4)))))
+    ((value pc) (add WI (mul WI value (const 4)) (and WI pc (const -4)))))
 (df f-disp16     "disp16"              (PCREL-ADDR RELOC) 16 16 INT
     ((value pc) (sra WI (sub WI value pc) (const 2)))
-    ((value pc) (add WI (sll WI value (const 2)) pc)))
+    ((value pc) (add WI (mul WI value (const 4)) pc)))
 (df f-disp24     "disp24"              (PCREL-ADDR RELOC) 8 24 INT
     ((value pc) (sra WI (sub WI value pc) (const 2)))
-    ((value pc) (add WI (sll WI value (const 2)) pc)))
+    ((value pc) (add WI (mul WI value (const 4)) pc)))
 
 (dnf f-op23      "op2.3"               ()  9 3)
 (dnf f-op3       "op3"                 () 14 2)

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-18  2:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18  0:28 x Alan Modra
2021-01-18  0:40 ` x H.J. Lu
2021-01-18  2:32   ` PR27198, segv in S_IS_WEAK Alan Modra
2021-01-18  2:44     ` H.J. Lu
  -- strict thread matches above, loose matches on Subject: below --
2020-01-04  8:53 x Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).