ARM: Link register is trashed by non-executed branch and link operations.
This commit is contained in:
parent
6dd4272804
commit
853a0858f3
2 changed files with 10 additions and 2 deletions
|
@ -246,7 +246,7 @@ decode COND_CODE default Unknown::unknown() {
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
0x3: decode OPCODE_24_21 {
|
0x3: decode OPCODE_24_21 {
|
||||||
0x9: BranchExchange::blx({{ LR = NPC; }});
|
0x9: BranchExchange::blx({{ }}, Link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ decode COND_CODE default Unknown::unknown() {
|
||||||
0x5: decode OPCODE_24 {
|
0x5: decode OPCODE_24 {
|
||||||
// Branch (and Link) Instructions
|
// Branch (and Link) Instructions
|
||||||
0: Branch::b({{ }});
|
0: Branch::b({{ }});
|
||||||
1: Branch::bl({{ LR = NPC; }});
|
1: Branch::bl({{ }}, Link);
|
||||||
}
|
}
|
||||||
0x6: decode CPNUM {
|
0x6: decode CPNUM {
|
||||||
0x1: decode PUNWL {
|
0x1: decode PUNWL {
|
||||||
|
|
|
@ -38,8 +38,10 @@ def format Branch(code,*opt_flags) {{
|
||||||
#Build Instruction Flags
|
#Build Instruction Flags
|
||||||
#Use Link & Likely Flags to Add Link/Condition Code
|
#Use Link & Likely Flags to Add Link/Condition Code
|
||||||
inst_flags = ('IsDirectControl', )
|
inst_flags = ('IsDirectControl', )
|
||||||
|
linking = False
|
||||||
for x in opt_flags:
|
for x in opt_flags:
|
||||||
if x == 'Link':
|
if x == 'Link':
|
||||||
|
linking = True
|
||||||
code += 'LR = NPC;\n'
|
code += 'LR = NPC;\n'
|
||||||
else:
|
else:
|
||||||
inst_flags += (x, )
|
inst_flags += (x, )
|
||||||
|
@ -55,6 +57,8 @@ def format Branch(code,*opt_flags) {{
|
||||||
icode += ' NPC = NPC + 4 + disp;\n'
|
icode += ' NPC = NPC + 4 + disp;\n'
|
||||||
icode += '} else {\n'
|
icode += '} else {\n'
|
||||||
icode += ' NPC = NPC;\n'
|
icode += ' NPC = NPC;\n'
|
||||||
|
if linking:
|
||||||
|
icode += ' LR = LR;\n'
|
||||||
icode += '};\n'
|
icode += '};\n'
|
||||||
|
|
||||||
code = icode
|
code = icode
|
||||||
|
@ -70,8 +74,10 @@ def format BranchExchange(code,*opt_flags) {{
|
||||||
#Build Instruction Flags
|
#Build Instruction Flags
|
||||||
#Use Link & Likely Flags to Add Link/Condition Code
|
#Use Link & Likely Flags to Add Link/Condition Code
|
||||||
inst_flags = ('IsIndirectControl', )
|
inst_flags = ('IsIndirectControl', )
|
||||||
|
linking = False
|
||||||
for x in opt_flags:
|
for x in opt_flags:
|
||||||
if x == 'Link':
|
if x == 'Link':
|
||||||
|
linking = True
|
||||||
code += 'LR = NPC;\n'
|
code += 'LR = NPC;\n'
|
||||||
else:
|
else:
|
||||||
inst_flags += (x, )
|
inst_flags += (x, )
|
||||||
|
@ -89,6 +95,8 @@ def format BranchExchange(code,*opt_flags) {{
|
||||||
icode += ' NPC = Rm & 0xfffffffe; // Masks off bottom bit\n'
|
icode += ' NPC = Rm & 0xfffffffe; // Masks off bottom bit\n'
|
||||||
icode += '} else {\n'
|
icode += '} else {\n'
|
||||||
icode += ' NPC = NPC;\n'
|
icode += ' NPC = NPC;\n'
|
||||||
|
if linking:
|
||||||
|
icode += ' LR = LR;\n'
|
||||||
icode += '};\n'
|
icode += '};\n'
|
||||||
|
|
||||||
code = icode
|
code = icode
|
||||||
|
|
Loading…
Reference in a new issue