[1/5] gas: Add md_cons_worker

Message ID 20191112161905.10048-2-hjl.tools@gmail.com
State Superseded
Headers show
Series
  • i386: Optimize for Jump Conditional Code Erratum
Related show

Commit Message

H.J. Lu Nov. 12, 2019, 4:19 p.m.
Add md_cons_worker to allow backend to track hard-coded opcodes in
instruction stream.

	* read.c (cons_worker): Call md_cons_worker if it is define.
---
 gas/read.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.21.0

Comments

Michael Matz Nov. 13, 2019, 11:55 a.m. | #1
Hello,

On Tue, 12 Nov 2019, H.J. Lu wrote:

> Add md_cons_worker to allow backend to track hard-coded opcodes in

> instruction stream.

> 

> @@ -3977,6 +3977,10 @@ cons_worker (int nbytes,	/* 1=.byte, 2=.word, 4=.long.  */

>    md_cons_align (nbytes);

>  #endif

>  

> +#ifdef md_cons_worker

> +  md_cons_worker (nbytes);

> +#endif


Why can't you simply implement the md_cons_align hook, instead of adding a 
new one?  I realize there are other calls to that hook, but they all won't 
be in the code segment, and if they happen to be and the emitted constants 
happen to be byte sequence matching jump instructions, then you probably 
want to do the alignments as well (in other words aren't you missing to 
patch the other places that currently call md_cons_align for constructed 
corner cases?).

If you decide to really need a new hook then you still need to document it 
in doc/internals.texi.


Ciao,
Michael.
H.J. Lu Nov. 13, 2019, 9:32 p.m. | #2
On Wed, Nov 13, 2019 at 3:55 AM Michael Matz <matz@suse.de> wrote:
>

> Hello,

>

> On Tue, 12 Nov 2019, H.J. Lu wrote:

>

> > Add md_cons_worker to allow backend to track hard-coded opcodes in

> > instruction stream.

> >

> > @@ -3977,6 +3977,10 @@ cons_worker (int nbytes,       /* 1=.byte, 2=.word, 4=.long.  */

> >    md_cons_align (nbytes);

> >  #endif

> >

> > +#ifdef md_cons_worker

> > +  md_cons_worker (nbytes);

> > +#endif

>

> Why can't you simply implement the md_cons_align hook, instead of adding a

> new one?  I realize there are other calls to that hook, but they all won't

> be in the code segment, and if they happen to be and the emitted constants

> happen to be byte sequence matching jump instructions, then you probably

> want to do the alignments as well (in other words aren't you missing to

> patch the other places that currently call md_cons_align for constructed

> corner cases?).

>


I will drop it and use md_cons_align instead.

Thanks.

-- 
H.J.

Patch

diff --git a/gas/read.c b/gas/read.c
index e53dd0232d..d1ce4eeb6c 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3977,6 +3977,10 @@  cons_worker (int nbytes,	/* 1=.byte, 2=.word, 4=.long.  */
   md_cons_align (nbytes);
 #endif
 
+#ifdef md_cons_worker
+  md_cons_worker (nbytes);
+#endif
+
   c = 0;
   do
     {