diff options
author | Pierre Langlois <pierre.langlois@arm.com> | 2016-09-22 11:15:35 +0100 |
---|---|---|
committer | Pierre Langlois <pierre.langlois@arm.com> | 2016-09-29 15:10:09 +0100 |
commit | f5348cedd702124c90fc75e75d0195e2e485c620 (patch) | |
tree | 45deaac9c771ff62698523708ba0c544ecb20544 /examples/aarch32/disasm-a32.cc | |
parent | 5b0cbc8d721ff369c76e09ff1e7ab878ffcae4e9 (diff) |
Remove implicit 64 to 32 bit narrowing
This patch fixes cases of implicit 64 to 32 bit narrowing. The issue is
that `CodeBuffer` represents code offsets with `ptrdiff_t`, which will
be 64 bit on a 64 bit system. However, we want to support generating 32
bit code from a 64 bit program, therefore the 32 bit part of VIXL works
with `int32_t` for code offsets. We had implicit conversions happening
due to this.
We solve this by explicitely casting to `int32_t` in the AArch32
assembler when calling `GetCursorOffset`. If you are working with the
`CodeBuffer` directly, you are dealing with a code buffer on the host
and so will work with offsets as `ptrdiff_t`. But, when working with the
AArch32 assembler itself you will get offsets as `int32_t`. The
assembler is in charge of checking that the offsets it gets from the
code buffer fit into `int32_t`.
Additionally, we had narrowing cases when generally wrapping host
pointers into an Operand. This can only work if the pointer fits into 32
bits. This patch introduces a Operand::From() factory method that can be
used for converting any integral or pointer type to an immediate
operand.
Change-Id: Icc15711b34c2477ed997eef238e25496d86ea9aa
Diffstat (limited to 'examples/aarch32/disasm-a32.cc')
-rw-r--r-- | examples/aarch32/disasm-a32.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/aarch32/disasm-a32.cc b/examples/aarch32/disasm-a32.cc index d72f50cc..1971acb3 100644 --- a/examples/aarch32/disasm-a32.cc +++ b/examples/aarch32/disasm-a32.cc @@ -280,7 +280,7 @@ int main(int argc, char** argv) { sres++) { const Symbol& symbol = sres->second; uint32_t func_addr = symbol.GetAddress(); - size_t func_size = symbol.GetSize(); + uint32_t func_size = symbol.GetSize(); if (func_size == 0) { SymbolTable::iterator next_func = sres; next_func++; |