]> Git Repo - qemu.git/commitdiff
target-arm: A64: Avoid left shifting negative integers in disas_pc_rel_addr
authorPeter Maydell <[email protected]>
Fri, 13 Feb 2015 05:46:09 +0000 (05:46 +0000)
committerPeter Maydell <[email protected]>
Fri, 13 Feb 2015 05:46:09 +0000 (05:46 +0000)
Shifting a negative integer left is undefined behaviour in C.
Avoid it by assembling and shifting the offset fields as
unsigned values and then sign extending as the final action.

Signed-off-by: Peter Maydell <[email protected]>
Message-id: 1423233250[email protected]

target-arm/translate-a64.c

index 94b3bf40f60ff194810919c6251e2e1c8c54169c..68c5b239141f614c073bc2635b89b34aa3ea1111 100644 (file)
@@ -2662,11 +2662,12 @@ static void disas_pc_rel_adr(DisasContext *s, uint32_t insn)
 {
     unsigned int page, rd;
     uint64_t base;
-    int64_t offset;
+    uint64_t offset;
 
     page = extract32(insn, 31, 1);
     /* SignExtend(immhi:immlo) -> offset */
-    offset = ((int64_t)sextract32(insn, 5, 19) << 2) | extract32(insn, 29, 2);
+    offset = sextract64(insn, 5, 19);
+    offset = offset << 2 | extract32(insn, 29, 2);
     rd = extract32(insn, 0, 5);
     base = s->pc - 4;
 
This page took 0.040702 seconds and 4 git commands to generate.