OSDN Git Service

Fix an ugly bug where try/catch offsets weren't being mapped properly.
authorJesse Wilson <jwilson@squareup.com>
Sat, 1 Sep 2012 04:37:56 +0000 (00:37 -0400)
committerJesse Wilson <jwilson@squareup.com>
Sat, 1 Sep 2012 04:44:26 +0000 (00:44 -0400)
commitd43341a24abe339d474b0b0d92669917ae2eb9bf
treed8fe1a3e49c77a7c505221a7edf9481e3efffd27
parent3e46814d8984243612176c9b15d8d012dcca2143
Fix an ugly bug where try/catch offsets weren't being mapped properly.

In dex files, there are several places where one object refers
to another object by its position in the file. The dex merger
is generally very careful to adjust these mappings when combining
dex files.

Unfortunately one of these cases was broken. Each try_item refers
to a corresponding encoded_catch_handler by its byte offset in a
list. Most of the time this byte offset is the same in the input
dex file and the output dex file. But encoded_catch_handlers are
variable-length because they use a variable-length uleb128 encoding
to address the type_idx being caught. When dex files are merged,
some exception types may go from having a small index to having
a large index, increasing the number of bytes required to encode
that index. This breaks our ability to directly copy over offsets
as we were doing previously.

Bug: http://code.google.com/p/android/issues/detail?id=36490
Change-Id: I3bdadf20899fdb5d4d074e69103b33c0404a31f8
dx/src/com/android/dx/dex/SizeOf.java
dx/src/com/android/dx/io/Code.java
dx/src/com/android/dx/io/DexBuffer.java
dx/src/com/android/dx/merge/DexMerger.java