From 1c6b92e00a4d9144af690d3c92e2a6df9488f099 Mon Sep 17 00:00:00 2001 From: whh8b <whh8b@git.zephyr-software.com> Date: Fri, 6 Jan 2017 22:36:54 +0000 Subject: [PATCH] Make check_for_PIC_switch_table64 a little more precise. This was necessary to fix some missed pins in libjvm. Former-commit-id: f54389ff9f816b67098a47b813aaf4f13527f4ff --- libIRDB/test/fill_in_indtargs.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libIRDB/test/fill_in_indtargs.cpp b/libIRDB/test/fill_in_indtargs.cpp index 630349afe..c0b6fbc05 100644 --- a/libIRDB/test/fill_in_indtargs.cpp +++ b/libIRDB/test/fill_in_indtargs.cpp @@ -1171,6 +1171,7 @@ Since I6 doesn't access memory, do another backup until with to verify a // for now, only trying to find I4-I8. ideally finding I1 would let us know the size of the // jump table. We'll figure out N by trying targets until they fail to produce something valid. + string table_index_str, cmp_str; Instruction_t* I8=insn; Instruction_t* I7=NULL; Instruction_t* I6=NULL; @@ -1195,9 +1196,16 @@ Since I6 doesn't access memory, do another backup until with to verify a * the target address of the jump. * * Backup and find the instruction that's an add or lea before I8. - * TODO: Should we check to make sure that the registers match? */ - if(!backup_until("(add|lea)", I7, I8)) + table_index_str = "(add "; + table_index_str += disasm.Argument1.ArgMnemonic; + table_index_str += "|lea "; + table_index_str += disasm.Argument1.ArgMnemonic; + table_index_str += ")"; + + cmp_str = string("cmp ") + disasm.Argument1.ArgMnemonic; + + if(!backup_until(table_index_str.c_str(), I7, I8)) return; I7->Disassemble(disasm); @@ -1333,7 +1341,7 @@ Since I6 doesn't access memory, do another backup until with to verify a continue; int table_size = 0; - if(!backup_until("cmp", I1, I5_cur)) + if(!backup_until(cmp_str.c_str(), I1, I8)) { cout<<"pic64: could not find size of switch table"<<endl; -- GitLab