aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/tools
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2009-12-13 17:04:38 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-15 14:35:49 -0500
commit23637568ad0c9b5ab0ad27d2f2f26d1e9282c527 (patch)
tree20f46ea8ae7df6a50bdbde3ed3f2fcda1623db4b /arch/x86/tools
parentbf08b3b1a1d06e92036a0c4f144b64fe6be2bffa (diff)
x86: Fix kprobes build with non-gawk awk
The instruction attribute table generator fails when run by mawk or original-awk: $ mawk -f arch/x86/tools/gen-insn-attr-x86.awk \ arch/x86/lib/x86-opcode-map.txt > /dev/null Semantic error at 240: Second IMM error $ echo $? 1 Line 240 contains "c8: ENTER Iw,Ib", which indicates that this instruction has two immediate operands, the second of which is one byte. The script loops through the immediate operands using a for loop. Unfortunately, there is no guarantee in awk that a for (variable in array) loop will return the indices in increasing order. Internally, both original-awk and mawk iterate over a hash table for this purpose, and both implementations happen to produce the index 2 before 1. The supposed second immediate operand is more than one byte wide, producing the error. So loop over the indices in increasing order instead. As a side-effect, with mawk this means the silly two-entry hash table never has to be built. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by Masami Hiramatsu <mhiramat@redhat.com> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20091213220437.GA27718@progeny.tock> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/tools')
-rw-r--r--arch/x86/tools/gen-insn-attr-x86.awk10
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk
index e34e92a28eb6..7a6850683c34 100644
--- a/arch/x86/tools/gen-insn-attr-x86.awk
+++ b/arch/x86/tools/gen-insn-attr-x86.awk
@@ -226,12 +226,12 @@ function add_flags(old,new) {
226} 226}
227 227
228# convert operands to flags. 228# convert operands to flags.
229function convert_operands(opnd, i,imm,mod) 229function convert_operands(count,opnd, i,j,imm,mod)
230{ 230{
231 imm = null 231 imm = null
232 mod = null 232 mod = null
233 for (i in opnd) { 233 for (j = 1; j <= count; j++) {
234 i = opnd[i] 234 i = opnd[j]
235 if (match(i, imm_expr) == 1) { 235 if (match(i, imm_expr) == 1) {
236 if (!imm_flag[i]) 236 if (!imm_flag[i])
237 semantic_error("Unknown imm opnd: " i) 237 semantic_error("Unknown imm opnd: " i)
@@ -282,8 +282,8 @@ function convert_operands(opnd, i,imm,mod)
282 # parse one opcode 282 # parse one opcode
283 if (match($i, opnd_expr)) { 283 if (match($i, opnd_expr)) {
284 opnd = $i 284 opnd = $i
285 split($(i++), opnds, ",") 285 count = split($(i++), opnds, ",")
286 flags = convert_operands(opnds) 286 flags = convert_operands(count, opnds)
287 } 287 }
288 if (match($i, ext_expr)) 288 if (match($i, ext_expr))
289 ext = $(i++) 289 ext = $(i++)