This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
x86-64 neutral code fillers
- From: Jan Hubicka <jh at suse dot cz>
- To: binutils at sources dot redhat dot com
- Date: Mon, 15 Jul 2002 16:39:42 +0200
- Subject: x86-64 neutral code fillers
Hi,
this patch makes multi byte nops to be used as neutral code fillers for
x86-64 configuration.
OK?
Honza
Wed Jul 10 16:13:20 CEST 2002 Jan Hubicka <jh@suse.cz>
* tc-i386.c (i386_align_code): Implement x86_64 neutral code fillers.
Index: tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.122
diff -c -3 -p -r1.122 tc-i386.c
*** tc-i386.c 9 Jul 2002 09:46:18 -0000 1.122
--- tc-i386.c 10 Jul 2002 14:11:25 -0000
*************** i386_align_code (fragP, count)
*** 521,546 ****
f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15
};
! /* ??? We can't use these fillers for x86_64, since they often kills the
! upper halves. Solve later. */
! if (flag_code == CODE_64BIT)
! count = 1;
! if (count > 0 && count <= 15)
{
! if (flag_code == CODE_16BIT)
{
! memcpy (fragP->fr_literal + fragP->fr_fix,
! f16_patt[count - 1], count);
! if (count > 8)
! /* Adjust jump offset. */
! fragP->fr_literal[fragP->fr_fix + 1] = count - 2;
}
- else
- memcpy (fragP->fr_literal + fragP->fr_fix,
- f32_patt[count - 1], count);
- fragP->fr_var = count;
}
}
static INLINE unsigned int
--- 521,565 ----
f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15
};
! if (count <= 0 || count > 15)
! return;
! /* The reccomended way to pad 64bit code is to use NOPs preceeded by
! maximally for 0x66 prefixes. Ballance the size of nops. */
! if (flag_code == CODE_64BIT)
{
! int i;
! int nnops = (count + 3) / 4;
! int len = count / nnops;
! int remains = count - nnops * len;
! int pos = 0;
!
! for (i = 0; i < remains; i++)
{
! memset (fragP->fr_literal + fragP->fr_fix + pos, 0x66, len);
! fragP->fr_literal[fragP->fr_fix + pos + len] = 0x90;
! pos += len + 1;
! }
! for (; i < nnops; i++)
! {
! memset (fragP->fr_literal + fragP->fr_fix + pos, 0x66, len - 1);
! fragP->fr_literal[fragP->fr_fix + pos + len - 1] = 0x90;
! pos += len;
}
}
+ else
+ if (flag_code == CODE_16BIT)
+ {
+ memcpy (fragP->fr_literal + fragP->fr_fix,
+ f16_patt[count - 1], count);
+ if (count > 8)
+ /* Adjust jump offset. */
+ fragP->fr_literal[fragP->fr_fix + 1] = count - 2;
+ }
+ else
+ memcpy (fragP->fr_literal + fragP->fr_fix,
+ f32_patt[count - 1], count);
+ fragP->fr_var = count;
}
static INLINE unsigned int