--- 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 @@ -0,0 +1,20 @@ +#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/nops-4-i686.d 1969-12-31 18:00:00.000000000 -0600 +++ binutils-nop/src/gas/testsuite/gas/i386/nops-4-i686.d 2007-07-03 18:06:34.047676000 -0500 @@ -0,0 +1,234 @@ +#as: -mtune=i686 +#source: nops-4.s +#objdump: -drw +#name: i386 -mtune=i686 nops 4 + +.*:[ ]+file format.* + +Disassembly of section .text: + +0+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.* + +0+20 : +[ ]+20:[ ]+90[ ]+nop.* +[ ]+21:[ ]+90[ ]+nop.* +[ ]+22:[ ]+90[ ]+nop.* +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op.* +[ ]+13b:[ ]+90[ ]+nop.* +[ ]+13c:[ ]+90[ ]+nop.* +[ ]+13d:[ ]+0f 1f 00[ ]+nop.* + +0+140 : +[ ]+140:[ ]+90[ ]+nop.* +[ ]+141:[ ]+90[ ]+nop.* +[ ]+142:[ ]+90[ ]+nop.* +[ ]+143:[ ]+90[ ]+nop.* +[ ]+144:[ ]+90[ ]+nop.* +[ ]+145:[ ]+90[ ]+nop.* +[ ]+146:[ ]+90[ ]+nop.* +[ ]+147:[ ]+90[ ]+nop.* +[ ]+148:[ ]+90[ ]+nop.* +[ ]+149:[ ]+90[ ]+nop.* +[ ]+14a:[ ]+90[ ]+nop.* +[ ]+14b:[ ]+90[ ]+nop.* +[ ]+14c:[ ]+90[ ]+nop.* +[ ]+14d:[ ]+90[ ]+nop.* +[ ]+14e:[ ]+90[ ]+nop.* +[ ]+14f:[ ]+90[ ]+nop.* +[ ]+150:[ ]+90[ ]+nop.* +[ ]+151:[ ]+90[ ]+nop.* +[ ]+152:[ ]+90[ ]+nop.* +[ ]+153:[ ]+90[ ]+nop.* +[ ]+154:[ ]+90[ ]+nop.* +[ ]+155:[ ]+90[ ]+nop.* +[ ]+156:[ ]+90[ ]+nop.* +[ ]+157:[ ]+90[ ]+nop.* +[ ]+158:[ ]+90[ ]+nop.* +[ ]+159:[ ]+90[ ]+nop.* +[ ]+15a:[ ]+90[ ]+nop.* +[ ]+15b:[ ]+90[ ]+nop.* +[ ]+15c:[ ]+90[ ]+nop.* +[ ]+15d:[ ]+90[ ]+nop.* +[ ]+15e:[ ]+90[ ]+nop.* +[ ]+15f:[ ]+90[ ]+nop.* --- binutils-head/src/gas/testsuite/gas/i386/nops-4.s 1969-12-31 18:00:00.000000000 -0600 +++ binutils-nop/src/gas/testsuite/gas/i386/nops-4.s 2007-07-03 18:02:02.694276000 -0500 @@ -0,0 +1,212 @@ + .text + +nop31: + nop + .p2align 5 + +nop28: + nop + nop + nop + nop + .p2align 5 + +nop25: + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop22: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop19: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop16: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop13: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop10: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop7: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop4: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 + +nop1: + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + .p2align 5 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 -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 3 Jul 2007 23:56:19 -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) { @@ -611,6 +627,10 @@ i386_align_code (fragS *fragP, int count static const char f32_15[] = {0xeb,0x0d,0x90,0x90,0x90,0x90,0x90, /* jmp .+15; lotsa nops */ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90}; + static const char *const f32_patt[] = { + f32_1, f32_2, f32_3, f32_4, f32_5, f32_6, f32_7, f32_8, + f32_9, f32_10, f32_11, f32_12, f32_13, f32_14, f32_15 + }; static const char f16_3[] = {0x8d,0x74,0x00}; /* lea 0(%esi),%esi */ static const char f16_4[] = @@ -627,10 +647,6 @@ i386_align_code (fragS *fragP, int count static const char f16_8[] = {0x8d,0xb4,0x00,0x00, /* lea 0w(%si),%si */ 0x8d,0xbd,0x00,0x00}; /* lea 0w(%di),%di */ - static const char *const f32_patt[] = { - f32_1, f32_2, f32_3, f32_4, f32_5, f32_6, f32_7, f32_8, - f32_9, f32_10, f32_11, f32_12, f32_13, f32_14, f32_15 - }; static const char *const f16_patt[] = { f32_1, f32_2, f16_3, f16_4, f16_5, f16_6, f16_7, f16_8, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15, f32_15 @@ -704,6 +720,11 @@ i386_align_code (fragS *fragP, int count 0x66, 0x66, 0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00}; + static const char *const alt_long_patt[] = { + f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8, + alt_9, alt_10, alt_long_11, alt_long_12, alt_long_13, + alt_long_14, alt_long_15 + }; /* nopl 0(%[re]ax,%[re]ax,1) nopw 0(%[re]ax,%[re]ax,1) */ static const char alt_short_11[] = @@ -734,13 +755,9 @@ i386_align_code (fragS *fragP, int count alt_9, alt_10, alt_short_11, alt_short_12, alt_short_13, alt_short_14, alt_short_15 }; - static const char *const alt_long_patt[] = { - f32_1, f32_2, alt_3, alt_4, alt_5, alt_6, alt_7, alt_8, - alt_9, alt_10, alt_long_11, alt_long_12, alt_long_13, - 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 @@ -748,12 +765,11 @@ i386_align_code (fragS *fragP, int count 1. For PROCESSOR_I486, PROCESSOR_PENTIUM and PROCESSOR_GENERIC32, f32_patt will be used. - 2. For PROCESSOR_K8 and PROCESSOR_AMDFAM10 in 64bit, NOPs with - 0x66 prefix will be used. - 3. For PROCESSOR_CORE2, alt_long_patt will be used. - 4. For PROCESSOR_PENTIUMPRO, PROCESSOR_PENTIUM4, PROCESSOR_NOCONA, - PROCESSOR_CORE, PROCESSOR_CORE2, PROCESSOR_K6, PROCESSOR_ATHLON - and PROCESSOR_GENERIC64, alt_short_patt will be used. + 2. For PROCESSOR_CORE2, alt_long_patt will be used. + 3. For PROCESSOR_PENTIUMPRO, PROCESSOR_PENTIUM4, PROCESSOR_NOCONA, + PROCESSOR_CORE, PROCESSOR_CORE2, PROCESSOR_K6, PROCESSOR_ATHLON, + PROCESSOR_K8, PROCESSOR_AMDFAM10 and PROCESSOR_GENERIC64, + alt_short_patt will be used. When -mtune= isn't used, alt_short_patt will be used if cpu_arch_isa_flags has Cpu686. Otherwise, f32_patt will be used. @@ -769,29 +785,6 @@ i386_align_code (fragS *fragP, int count /* 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 +863,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 -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 3 Jul 2007 23:56:19 -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 -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 3 Jul 2007 23:56:20 -0000 @@ -70,7 +70,8 @@ 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 "nops-4-i686" run_dump_test "addr16" run_dump_test "addr32" run_dump_test "sse4_1" @@ -164,7 +165,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"