[PATCH] x86: Handle {disp32} for (%bp)/(%ebp)/(%rbp)

H.J. Lu hjl.tools@gmail.com
Tue Jul 28 19:02:26 GMT 2020


On Tue, Jul 28, 2020 at 11:43 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 28.07.2020 01:23, H.J. Lu via Binutils wrote:
> > Since (%bp)/(%ebp)/(%rbp) are encoded as 0(%bp)/0(%ebp)/0(%rbp), use
> > disp32/disp16 on 0(%bp)/0(%ebp)/0(%rbp) for {disp32}.
>
> Same for (%r13d) / (%r13) afaict?

Yes. {disp32} works on (%r13d) / (%r13) now:

[hjl@gnu-cfl-2 testsuite]$ cat x.s
movb (%r13),%al
{disp8} movb (%r13),%al
{disp32} movb (%r13),%al

movb (%r13d),%al
{disp8} movb (%r13d),%al
{disp32} movb (%r13d),%al
[hjl@gnu-cfl-2 testsuite]$ gcc -c x.s
[hjl@gnu-cfl-2 testsuite]$ objdump -dw x.o

x.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <.text>:
   0: 41 8a 45 00          mov    0x0(%r13),%al
   4: 41 8a 45 00          mov    0x0(%r13),%al
   8: 41 8a 45 00          mov    0x0(%r13),%al
   c: 67 41 8a 45 00        mov    0x0(%r13d),%al
  11: 67 41 8a 45 00        mov    0x0(%r13d),%al
  16: 67 41 8a 45 00        mov    0x0(%r13d),%al
[hjl@gnu-cfl-2 testsuite]$ ../as-new -o x.o x.s
[hjl@gnu-cfl-2 testsuite]$ objdump -dw x.o

x.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <.text>:
   0: 41 8a 45 00          mov    0x0(%r13),%al
   4: 41 8a 45 00          mov    0x0(%r13),%al
   8: 41 8a 85 00 00 00 00 mov    0x0(%r13),%al
   f: 67 41 8a 45 00        mov    0x0(%r13d),%al
  14: 67 41 8a 45 00        mov    0x0(%r13d),%al
  19: 67 41 8a 85 00 00 00 00 mov    0x0(%r13d),%al
[hjl@gnu-cfl-2 testsuite]$


> > Note: Since there is no disp32 on 0(%bp), use disp16 instead.
>
> What use is it to fix the special case of (%bp) when the more general
> case ((%bx), (%si), etc) doesn't work? I anyway think that instead of
> ...
>
> > --- a/gas/config/tc-i386.c
> > +++ b/gas/config/tc-i386.c
> > @@ -8151,7 +8151,12 @@ build_modrm_byte (void)
> >                     if (operand_type_check (i.types[op], disp) == 0)
> >                       {
> >                         /* fake (%bp) into 0(%bp)  */
> > -                       i.types[op].bitfield.disp8 = 1;
> > +                       if (i.disp_encoding == disp_encoding_32bit)
> > +                         /* NB: Use disp16 since there is no disp32
> > +                            in 16-bit mode.  */
> > +                         i.types[op].bitfield.disp16 = 1;
> > +                       else
> > +                         i.types[op].bitfield.disp8 = 1;
> >                         fake_zero_displacement = 1;
> >                       }
>
> ... the comment you add here, support for {disp16} should be added.
>

I will add {disp16} to master branch.


-- 
H.J.


More information about the Binutils mailing list