Index: gas/config/tc-i386.c =================================================================== RCS file: /cvs/src/src/gas/config/tc-i386.c,v retrieving revision 1.266 diff -p -u -w -d -p -u -w -r1.266 tc-i386.c --- gas/config/tc-i386.c 22 Jun 2007 14:15:51 -0000 1.266 +++ gas/config/tc-i386.c 26 Jun 2007 18:56:56 -0000 @@ -566,6 +566,22 @@ static struct hash_control *op_hash; /* Hash table for register lookup. */ static struct hash_control *reg_hash; +/* Maximum number of predefined alignment filling patterns. */ +#define ALIGN_FILL_PATT_MAX 15 + +/* Handle alignments greater than the predefined ones. */ +static inline void +handle_align_code (fragS *fragP, const char *const *patt, int max, int count) +{ + while (count > max) + { + count -= max; + memcpy (fragP->fr_literal + fragP->fr_fix + count, patt [max - 1], max); + } + + memcpy (fragP->fr_literal + fragP->fr_fix, patt [count - 1], count); +} + void i386_align_code (fragS *fragP, int count) { @@ -740,7 +756,8 @@ i386_align_code (fragS *fragP, int count alt_long_14, alt_long_15 }; - if (count <= 0 || count > 15) + /* Only align for at least a positive non-zero boundary. */ + if (count <= 0 || count > MAX_MEM_FOR_RS_ALIGN_CODE) return; /* We need to decide which NOP sequence to use for 32bit and @@ -763,35 +780,12 @@ i386_align_code (fragS *fragP, int count if (flag_code == CODE_16BIT) { - memcpy (fragP->fr_literal + fragP->fr_fix, - f16_patt[count - 1], count); + handle_align_code (fragP, f16_patt, ALIGN_FILL_PATT_MAX, count); + if (count > 8) /* Adjust jump offset. */ fragP->fr_literal[fragP->fr_fix + 1] = count - 2; } - else if (flag_code == CODE_64BIT && cpu_arch_tune == PROCESSOR_K8) - { - int i; - int nnops = (count + 3) / 4; - int len = count / nnops; - int remains = count - nnops * len; - int pos = 0; - - /* The recommended way to pad 64bit code is to use NOPs preceded - by maximally four 0x66 prefixes. Balance the size of nops. */ - 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 { const char *const *patt = NULL; @@ -870,8 +864,7 @@ i386_align_code (fragS *fragP, int count } } - memcpy (fragP->fr_literal + fragP->fr_fix, - patt[count - 1], count); + handle_align_code (fragP, patt, ALIGN_FILL_PATT_MAX, count); } fragP->fr_var = count; } Index: gas/config/tc-i386.h =================================================================== RCS file: /cvs/src/src/gas/config/tc-i386.h,v retrieving revision 1.87 diff -p -u -w -d -p -u -w -r1.87 tc-i386.h --- gas/config/tc-i386.h 21 Mar 2007 15:37:21 -0000 1.87 +++ gas/config/tc-i386.h 26 Jun 2007 18:56:56 -0000 @@ -261,7 +261,7 @@ if ((n) \ goto around; \ } -#define MAX_MEM_FOR_RS_ALIGN_CODE 15 +#define MAX_MEM_FOR_RS_ALIGN_CODE 31 extern void i386_align_code (fragS *, int); Index: gas/testsuite/gas/i386/i386.exp =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/i386/i386.exp,v retrieving revision 1.70 diff -p -u -w -d -p -u -w -r1.70 i386.exp --- gas/testsuite/gas/i386/i386.exp 23 Jun 2007 14:55:18 -0000 1.70 +++ gas/testsuite/gas/i386/i386.exp 26 Jun 2007 18:56:57 -0000 @@ -70,7 +70,7 @@ if [expr ([istarget "i*86-*-*"] || [ist run_dump_test "nops-2" run_dump_test "nops-2-i386" run_dump_test "nops-2-merom" - run_dump_test "nops-3" + run_dump_test "nops-3-i686" run_dump_test "addr16" run_dump_test "addr32" run_dump_test "sse4_1" @@ -164,7 +164,6 @@ if [expr ([istarget "i*86-*-*"] || [ista if ![istarget "x86_64-*-mingw*"] then { run_dump_test "x86-64-nops-1" } - run_dump_test "x86-64-nops-1-k8" run_dump_test "x86-64-nops-1-nocona" run_dump_test "x86-64-nops-1-merom" run_dump_test "x86-64-sse4_1" --- binutils-head/src/gas/testsuite/gas/i386/nops-3-i686.d 1969-12-31 18:00:00.000000000 -0600 +++ binutils-nop/src/gas/testsuite/gas/i386/nops-3-i686.d 2007-06-25 17:29:23.590739000 -0500 @@ -1,20 +0,0 @@ +#as: -mtune=i686 +#source: nops-3.s +#objdump: -drw +#name: i386 -mtune=i686 nops 3 + +.*: +file format .* + +Disassembly of section .text: + +0+ : +[ ]*0:[ ]+90[ ]+nop[ ]* +[ ]*1:[ ]+90[ ]+nop[ ]* +[ ]*2:[ ]+0f 1f 80 00 00 00 00[ ]+nop.+ +[ ]*9:[ ]+0f 1f 84 00 00 00 00 00[ ]+nop.+ +[ ]*11:[ ]+0f 1f 80 00 00 00 00[ ]+nop.+ +[ ]*18:[ ]+0f 1f 84 00 00 00 00 00[ ]+nop.+ +[ ]*20:[ ]+89 c3[ ]+mov[ ]+%eax,%ebx[ ]* +[ ]*22:[ ]+0f 1f 80 00 00 00 00[ ]+nop.+ +[ ]*29:[ ]+0f 1f 80 00 00 00 00[ ]+nop.+ +#pass --- binutils-head/src/gas/testsuite/gas/i386/x86-64-nops-1-k8.d 2006-06-23 16:47:36.000000000 -0500 +++ binutils-nop/src/gas/testsuite/gas/i386/x86-64-nops-1-k8.d 1969-12-31 18:00:00.000000000 -0600 @@ -0,0 +1,177 @@ -#as: -mtune=k8 -#source: x86-64-nops-1.s -#objdump: -drw -#name: x86-64 -mtune=k8 nops 1 - -.*: +file format .* - -Disassembly of section .text: - -0+ : -[ ]*0:[ ]+90[ ]+nop[ ]* -[ ]*1:[ ]+66 66 66 90[ ]+xchg[ ]+%ax,%ax -[ ]*5:[ ]+66 66 66 90[ ]+xchg[ ]+%ax,%ax -[ ]*9:[ ]+66 66 66 90[ ]+xchg[ ]+%ax,%ax -[ ]*d:[ ]+66 66 90[ ]+xchg[ ]+%ax,%ax - -0+10 : -[ ]*10:[ ]+90[ ]+nop[ ]* -[ ]*11:[ ]+90[ ]+nop[ ]* -[ ]*12:[ ]+66 66 66 90[ ]+xchg[ ]+%ax,%ax -[ ]*16:[ ]+66 66 66 90[ ]+xchg[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