X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=extract%2Fcodegen%2Fcode_generation.ml;h=d45134996c17125f5b0003b1abfce0265d5f07ab;hb=fea04ba6838a7fb1f7f6df9ea5b9603603205f3d;hp=41520dc1b3170a7ab6e1db31148df0d9b37b89c6;hpb=82201a5312c3582daeb7215efd731f7e784d9edf;p=virt-mem.git diff --git a/extract/codegen/code_generation.ml b/extract/codegen/code_generation.ml index 41520dc..d451349 100644 --- a/extract/codegen/code_generation.ml +++ b/extract/codegen/code_generation.ml @@ -539,10 +539,21 @@ let generate_followers names xs = and adj = data.$lid:struct_name^"_"^name^"_adjustment"$ in let offset = Int64.of_int offset and adj = Int64.of_int adj in - (* 'addr' is base of the virtual struct *) - let addr = Int64.sub (Int64.add addr offset) adj in + + (* 'addr' is base of the virtual struct, but when + * adding it to the map make sure we don't splat + * the real structure (can happen if offset=adj). + *) let map = - AddrMap.add addr ($str:dest_struct_name$, None) map in + if offset <> adj then ( + let addr = Int64.sub (Int64.add addr offset) adj in + AddrMap.add addr ($str:dest_struct_name$, None) map + ) else map in + + (* 'dest_addr' is the destination address of + * this pointer. It needs the usual list_head + * adjustment applied. + *) let dest_addr = Int64.sub dest_addr adj in let map = $lid:dest_struct_name^"_follower"$