Bu belge, bir dizi sınıf tanımını ve bunlarla ilişkili ek verileri tutmak için kullanılan .dex
dosyalarının düzenini ve içeriğini açıklar.
Türler için rehber
İsim | Tanım |
---|---|
bayt | 8 bit imzalı int |
ubyte | 8 bit imzasız int |
kısa | 16 bit imzalı int, küçük endian |
kısa | 16 bit imzasız int, küçük endian |
int | 32 bit imzalı int, küçük endian |
uint | 32 bit imzasız int, küçük endian |
uzun | 64 bit imzalı int, küçük endian |
uzun | 64 bit imzasız int, küçük endian |
sleb128 | imzalı LEB128, değişken uzunluklu (aşağıya bakınız) |
uleb128 | imzasız LEB128, değişken uzunluklu (aşağıya bakın) |
uleb128p1 | imzasız LEB128 artı 1 , değişken uzunluk (aşağıya bakın) |
LEB128
LEB128 ("Little-Endian B ase 128 " ) , rastgele işaretli veya işaretsiz tamsayı miktarları için değişken uzunluklu bir kodlamadır. Format, DWARF3 spesifikasyonundan ödünç alınmıştır. Bir .dex
dosyasında LEB128 yalnızca 32 bitlik miktarları kodlamak için kullanılır.
Her LEB128 kodlanmış değeri, birlikte tek bir 32 bitlik değeri temsil eden bir ila beş bayttan oluşur. Sıradaki en anlamlı biti net olan son bayt dışında, her bayt en anlamlı bit kümesine sahiptir. Her bir baytın kalan yedi biti, miktarın en az anlamlı yedi biti ilk baytta, sonraki yedi biti ikinci baytta vb. olmak üzere yüktür. İşaretli bir LEB128 ( sleb128
) durumunda, dizideki son baytın en önemli veri yükü biti, nihai değeri üretmek için işaretle genişletilir. İşaretsiz durumda ( uleb128
) açıkça temsil edilmeyen bitler 0
olarak yorumlanır.
İki baytlık bir LEB128 değerinin bit düzeyinde diyagramı | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
İlk bayt | İkinci bayt | ||||||||||||||
1 | 6. bit | 5. bit | 4. bit | 3. bit | 2. bit | 1. bit | bit 0 | 0 | 13. bit | bit 12 | 11. bit | bit 10 | bit 9 | bit 8 | 7. bit |
uleb128p1
varyantı, işaretli bir değeri temsil etmek için kullanılır, burada temsil değer artı bir uleb128
olarak kodlanmıştır. Bu, -1
(alternatif olarak 0xffffffff
işaretsiz değeri olarak düşünülür) - ancak başka bir negatif sayı olmayan - tek bir bayt kodlamasını yapar ve tam olarak temsil edilen sayının negatif olmaması veya -1
(veya 0xffffffff
) ve başka hiçbir negatif değere izin verilmeyen (veya büyük işaretsiz değerlere gerek duyulmayan) durumlarda.
İşte bazı biçim örnekleri:
Kodlanmış Sıra | sleb128 olarak | uleb128 olarak | uleb128p1 olarak |
---|---|---|---|
00 | 0 | 0 | -1 |
01 | 1 | 1 | 0 |
7f | -1 | 127 | 126 |
80 7f | -128 | 16256 | 16255 |
Dosya düzeni
İsim | Biçim | Tanım |
---|---|---|
başlık | başlık_öğesi | başlık |
string_ids | string_id_item[] | dize tanımlayıcıları listesi. Bunlar, ya dahili adlandırma için (örn., tip tanımlayıcılar) ya da kod tarafından atıfta bulunulan sabit nesneler olarak, bu dosya tarafından kullanılan tüm dizgiler için tanımlayıcılardır. Bu liste, UTF-16 kod noktası değerleri kullanılarak (yerel ayara duyarlı bir şekilde değil) dize içeriğine göre sıralanmalıdır ve yinelenen girişler içermemelidir. |
type_ids | type_id_item[] | tür tanımlayıcıları listesi. Bunlar, dosyada tanımlanmış olsun ya da olmasın, bu dosya tarafından atıfta bulunulan tüm türler (sınıflar, diziler veya ilkel türler) için tanımlayıcılardır. Bu liste string_id dizinine göre sıralanmalı ve yinelenen girdiler içermemelidir. |
proto_ids | proto_id_item[] | yöntem prototip tanımlayıcıları listesi. Bunlar, bu dosya tarafından atıfta bulunulan tüm prototipler için tanımlayıcılardır. Bu liste, dönüş tipinde ( type_id dizinine göre) ana sıraya ve ardından bağımsız değişken listesine (sözlük sıralaması, type_id dizinine göre sıralanan bağımsız bağımsız değişkenler) göre sıralanmalıdır. Liste yinelenen girdiler içermemelidir. |
field_ids | field_id_item[] | alan tanımlayıcıları listesi. Bunlar, dosyada tanımlanmış olsun ya da olmasın, bu dosya tarafından atıfta bulunulan tüm alanlar için tanımlayıcılardır. Tanımlayıcı tip ( type_id indeksine göre) ana sıra, alan adı ( string_id indeksine göre) ara sıra ve tip ( type_id indeksine göre) alt sıra olduğunda, bu liste sıralanmalıdır. Liste yinelenen girdiler içermemelidir. |
method_ids | method_id_item[] | yöntem tanımlayıcıları listesi. Bunlar, dosyada tanımlanmış olsun ya da olmasın, bu dosya tarafından atıfta bulunulan tüm yöntemlerin tanımlayıcılarıdır. Bu liste, tanımlayıcı tip ( type_id indeksine göre) ana sıra, yöntem adı ( string_id indeksine göre) ara sıra ve yöntem prototipi ( proto_id indeksine göre) alt sıra olduğunda sıralanmalıdır. Liste yinelenen girdiler içermemelidir. |
sınıf_defs | class_def_item[] | sınıf tanımları listesi. Sınıflar, belirli bir sınıfın üst sınıfı ve uygulanan arabirimler, ilgili sınıftan önce listede görünecek şekilde sıralanmalıdır. Ayrıca, aynı isimli sınıfın bir tanımın listede birden fazla görünmesi geçersizdir. |
call_site_ids | call_site_id_item[] | site tanımlayıcıları listesini arayın. Bunlar, dosyada tanımlanmış olsun ya da olmasın, bu dosya tarafından atıfta bulunulan tüm çağrı siteleri için tanımlayıcılardır. Bu liste artan call_site_off düzeninde sıralanmalıdır. |
method_handles | method_handle_item[] | yöntem tanıtıcı listesi. Dosyada tanımlanmış olsun ya da olmasın, bu dosya tarafından atıfta bulunulan tüm yöntem tanıtıcılarının listesi. Bu liste sıralanmamıştır ve mantıksal olarak farklı yöntem tanıtıcı örneklerine karşılık gelen kopyalar içerebilir. |
veri | ubyte[] | Yukarıda listelenen tablolar için tüm destek verilerini içeren veri alanı. Farklı öğelerin farklı hizalama gereksinimleri vardır ve uygun hizalamayı elde etmek için gerekirse her öğeden önce doldurma baytları eklenir. |
link_data | ubyte[] | statik olarak bağlantılı dosyalarda kullanılan veriler. Bu bölümdeki verilerin formatı bu belge tarafından belirtilmeden bırakılmıştır. Bu bölüm, bağlantısız dosyalarda boştur ve çalışma zamanı uygulamaları bunu uygun gördükleri şekilde kullanabilir. |
Bitfield, dize ve sabit tanımlar
DEX_FILE_MAGIC
header_item içine gömülü
Sabit dizi/dize DEX_FILE_MAGIC
, bir .dex
dosyasının bu şekilde tanınması için başında görünmesi gereken baytların listesidir. Değer, belirli bozulma biçimlerinin saptanmasına yardımcı olmak için kasıtlı olarak bir yeni satır ( "\n"
veya 0x0a
) ve bir boş bayt ( "\0"
veya 0x00
) içerir. Değer ayrıca bir biçim sürüm numarasını, biçim geliştikçe zaman içinde monoton bir şekilde artması beklenen üç ondalık basamak olarak kodlar.
ubyte[8] DEX_FILE_MAGIC = { 0x64 0x65 0x78 0x0a 0x30 0x33 0x39 0x00 } = "dex\n039\0"
Not: 039
sürümü için destek, const-method-handle
ve const-method-type
olmak üzere iki yeni bayt kodu sunan Android 9.0 sürümüne eklendi. (Bunların her biri Özet bayt kodu kümesi tablosunda açıklanmıştır.) Android 10'da sürüm 039
, DEX dosya biçimini yalnızca önyükleme sınıfı yolundaki DEX dosyaları için geçerli olan gizli API bilgilerini içerecek şekilde genişletir.
Not: 038
sürümü desteği, Android 8.0 sürümüne eklenmiştir. Sürüm 038
, yeni bayt kodları ( invoke-polymorphic
ve invoke-custom
) ve yöntem tanıtıcıları için veriler ekledi.
Not: 037
sürümü desteği, Android 7.0 sürümüne eklenmiştir. 037
sürümünden önce, Android'in çoğu sürümü, biçimin 035
sürümünü kullanıyordu. 035
ve 037
sürümleri arasındaki tek fark, varsayılan yöntemlerin eklenmesi ve invoke
ayarlanmasıdır.
Not: Formatın en az birkaç önceki sürümü, yaygın olarak bulunan genel yazılım sürümlerinde kullanılmıştır. Örneğin, Android platformunun M3 sürümleri (Kasım-Aralık 2007) için 009
sürümü ve Android platformunun M5 sürümleri (Şubat-Mart 2008) için 013
sürümü kullanıldı. Biçimin bu önceki sürümleri, birçok açıdan bu belgede açıklanan sürümden önemli ölçüde farklıdır.
ENDIAN_CONSTANT ve REVERSE_ENDIAN_CONSTANT
header_item içine gömülü
ENDIAN_CONSTANT
sabiti, içinde bulunduğu dosyanın endianlığını belirtmek için kullanılır. Standart .dex
biçimi küçük endian olsa da, uygulamalar bayt değiş tokuşu yapmayı seçebilir. Bir uygulama, endian_tag
REVERSE_ENDIAN_CONSTANT
yerine ENDIAN_CONSTANT
olan bir üstbilgiyle karşılaşırsa, dosyanın beklenen biçimden bayt değiş tokuşu yapıldığını bilir.
uint ENDIAN_CONSTANT = 0x12345678; uint REVERSE_ENDIAN_CONSTANT = 0x78563412;
NO_INDEX
class_def_item ve debug_info_item içine gömülü
NO_INDEX
sabiti, bir indeks değerinin olmadığını belirtmek için kullanılır.
Not: Bu değer 0
olarak tanımlanmamıştır, çünkü bu aslında tipik olarak geçerli bir dizindir.
NO_INDEX
için seçilen değer, uleb128p1
kodlamasında tek bir bayt olarak gösterilebilir.
uint NO_INDEX = 0xffffffff; // == -1 if treated as a signed int
access_flags tanımları
class_def_item, encoded_field, encoded_method ve InnerClass'a gömülü
Bu bayrakların bit alanları, sınıfların ve sınıf üyelerinin erişilebilirliğini ve genel özelliklerini belirtmek için kullanılır.
İsim | Değer | Sınıflar (ve InnerClass ek açıklamaları) için | Alanlar için | Yöntemler için |
---|---|---|---|---|
ACC_PUBLIC | 0x1 | public : her yerde görünür | public : her yerde görünür | public : her yerde görünür |
ACC_PRIVATE | 0x2 | private : yalnızca sınıfı tanımlayan tarafından görülebilir | private : yalnızca sınıfı tanımlayan tarafından görülebilir | private : yalnızca sınıfı tanımlayan tarafından görülebilir |
ACC_PROTECTED | 0x4 | protected : paket ve alt sınıflara görünür | protected : paket ve alt sınıflara görünür | protected : paket ve alt sınıflara görünür |
ACC_STATIC | 0x8 | static : bir dış this referansla oluşturulmamıştır | static : globalden sınıf tanımlamaya | static : this argümanı almaz |
ACC_FINAL | 0x10 | final : alt sınıflanamaz | final : inşaattan sonra değişmez | final : geçersiz kılınamaz |
ACC_SENKRONİZE EDİLDİ | 0x20 | synchronized : bu yönteme yapılan çağrı sırasında ilgili kilit otomatik olarak alınır. Not: Bu, yalnızca | ||
ACC_VOLATILE | 0x40 | volatile : iş parçacığı güvenliğine yardımcı olmak için özel erişim kuralları | ||
ACC_BRIDGE | 0x40 | tip-güvenli bir köprü olarak derleyici tarafından otomatik olarak eklenen köprü yöntemi | ||
ACC_TRANSIENT | 0x80 | transient : varsayılan serileştirme ile kaydedilmeyecek | ||
ACC_VARARGS | 0x80 | son argüman derleyici tarafından "dinlenme" argümanı olarak ele alınmalıdır | ||
ACC_NATIVE | 0x100 | native : yerel kodda uygulandı | ||
ACC_INTERFACE | 0x200 | interface : çoğaltılabilir soyut sınıf | ||
ACC_ABSTRACT | 0x400 | abstract : doğrudan somutlaştırılamaz | abstract : bu sınıf tarafından uygulanmadı | |
ACC_STRICT | 0x800 | strictfp : kayan nokta aritmetiği için katı kurallar | ||
ACC_SENTETİK | 0x1000 | doğrudan kaynak kodunda tanımlanmadı | doğrudan kaynak kodunda tanımlanmadı | doğrudan kaynak kodunda tanımlanmadı |
ACC_ANNOTATION | 0x2000 | açıklama sınıfı olarak ilan edildi | ||
ACC_ENUM | 0x4000 | numaralandırılmış bir tür olarak bildirildi | numaralandırılmış bir değer olarak bildirildi | |
(kullanılmamış) | 0x8000 | |||
ACC_CONSTRUCTOR | 0x10000 | yapıcı yöntemi (sınıf veya örnek başlatıcı) | ||
ACC_DECLARED_ SENKRONİZE | 0x20000 | synchronized ilan edildi.Not: Bunun yürütme üzerinde hiçbir etkisi yoktur (bu bayrağın kendi başına yansıması dışında). |
InnerClass
ek açıklamaları için izin verilir ve hiçbir zaman class_def_item
içinde açık olmamalıdır.
MUTF-8 (Değiştirilmiş UTF-8) Kodlaması
Daha kolay eski desteğin bir imtiyazı olarak, .dex
biçimi, dize verilerini, bundan sonra MUTF-8 olarak anılacak olan fiili standart değiştirilmiş UTF-8 biçiminde kodlar. Bu form, aşağıdakiler dışında standart UTF-8 ile aynıdır:
- Yalnızca bir, iki ve üç baytlık kodlamalar kullanılır.
-
U+10000
…U+10ffff
aralığındaki kod noktaları, her biri üç baytlık kodlanmış bir değer olarak temsil edilen vekil bir çift olarak kodlanır. -
U+0000
kod noktası iki bayt biçiminde kodlanmıştır. - Düz bir boş bayt (değer
0
), standart C dili yorumunda olduğu gibi bir dizenin sonunu belirtir.
Yukarıdaki ilk iki öğe şu şekilde özetlenebilir: MUTF-8, Unicode karakterler için daha doğrudan bir kodlama biçimi olmak yerine UTF-16 için bir kodlama biçimidir.
Yukarıdaki son iki öğe, U+0000
kod noktasını bir dizgeye dahil etmeyi ve yine de onu C-stili boş sonlandırılmış bir dizge olarak işlemeyi aynı anda mümkün kılar.
Bununla birlikte, U+0000
özel kodlaması, normal UTF-8'den farklı olarak, bir çift MUTF-8 dizesinde standart C işlevinin strcmp()
çağrılmasının sonucunun, her zaman, eşit olmayan dizelerin karşılaştırmasının doğru şekilde imzalanmış sonucunu göstermediği anlamına gelir. . Sıralama (yalnızca eşitlik değil) söz konusu olduğunda, MUTF-8 dizelerini karşılaştırmanın en basit yolu onları karakter karakter çözmek ve kodu çözülen değerleri karşılaştırmaktır. (Ancak, daha akıllı uygulamalar da mümkündür.)
Karakter kodlaması hakkında daha fazla bilgi için lütfen Unicode Standardına bakın. MUTF-8 aslında (nispeten daha az bilinen) CESU-8'i kodlamaya kendi başına UTF-8'den daha yakındır.
kodlanmış_değer kodlaması
annotation_element ve encoding_array_item içine gömülü
Encoding_value, (neredeyse) rastgele hiyerarşik olarak yapılandırılmış verilerin encoded_value
bir parçasıdır. Kodlamanın hem kompakt hem de ayrıştırılması kolay olması amaçlanmıştır.
İsim | Biçim | Tanım |
---|---|---|
(değer_arg << 5) | değer türü | ubyte | yüksek dereceli üç bitte isteğe bağlı açıklayıcı bir argümanla birlikte hemen sonraki value türünü gösteren bayt. Çeşitli value tanımları için aşağıya bakın. Çoğu durumda, value_arg , hemen sonraki value uzunluğunu bayt cinsinden kodlar, çünkü (size - 1) , örneğin 0 , değerin bir bayt gerektirdiği ve 7 , sekiz bayt gerektirdiği anlamına gelir; ancak, aşağıda belirtildiği gibi istisnalar vardır. |
değer | ubyte[] | değeri temsil eden baytlar, uzunluk olarak değişkendir ve her zaman küçük endian olsa da, farklı value_type baytları için farklı yorumlanır. Ayrıntılar için aşağıdaki çeşitli değer tanımlarına bakın. |
Değer biçimleri
Tür Adı | value_type | value_arg Biçimi | value Biçimi | Tanım |
---|---|---|---|---|
VALUE_BYTE | 0x00 | (yok; 0 olmalıdır) | ubyte[1] | imzalı bir baytlık tamsayı değeri |
VALUE_SHORT | 0x02 | boyut - 1 (0…1) | ubyte[boyut] | imzalı iki baytlık tamsayı değeri, genişletilmiş işaret |
VALUE_CHAR | 0x03 | boyut - 1 (0…1) | ubyte[boyut] | işaretsiz iki baytlık tamsayı değeri, sıfır genişletilmiş |
VALUE_INT | 0x04 | boyut - 1 (0…3) | ubyte[boyut] | imzalı dört baytlık tamsayı değeri, işaretle genişletilmiş |
VALUE_LONG | 0x06 | boyut - 1 (0…7) | ubyte[boyut] | işaretli sekiz baytlık tamsayı değeri, işaretle genişletilmiş |
VALUE_FLOAT | 0x10 | boyut - 1 (0…3) | ubyte[boyut] | dört baytlık bit deseni, sağa sıfır genişletilmiş ve IEEE754 32 bit kayan nokta değeri olarak yorumlanmıştır |
VALUE_DOUBLE | 0x11 | boyut - 1 (0…7) | ubyte[boyut] | sekiz bayt bit deseni, sağa sıfır uzatılmış ve IEEE754 64 bit kayan nokta değeri olarak yorumlanmıştır |
VALUE_METHOD_TYPE | 0x15 | boyut - 1 (0…3) | ubyte[boyut] | imzasız (sıfır genişletilmiş) dört baytlık tamsayı değeri, proto_ids bölümüne bir dizin olarak yorumlanır ve bir yöntem türü değerini temsil eder |
VALUE_METHOD_HANDLE | 0x16 | boyut - 1 (0…3) | ubyte[boyut] | işaretsiz (sıfır genişletilmiş) dört baytlık tamsayı değeri, method_handles bölümüne bir dizin olarak yorumlanır ve bir yöntem tanıtıcı değerini temsil eder |
VALUE_STRING | 0x17 | boyut - 1 (0…3) | ubyte[boyut] | string_ids bölümüne bir dizin olarak yorumlanan ve bir dize değerini temsil eden işaretsiz (sıfır-genişletilmiş) dört baytlık tamsayı değeri |
DEĞER TÜRÜ | 0x18 | boyut - 1 (0…3) | ubyte[boyut] | type_ids bölümüne bir dizin olarak yorumlanan ve yansıtıcı bir tür/sınıf değerini temsil eden işaretsiz (sıfır-genişletilmiş) dört baytlık tamsayı değeri |
VALUE_FIELD | 0x19 | boyut - 1 (0…3) | ubyte[boyut] | field_ids bölümüne bir dizin olarak yorumlanan ve yansıtıcı bir alan değerini temsil eden işaretsiz (sıfır-genişletilmiş) dört baytlık tamsayı değeri |
VALUE_METHOD | 0x1a | boyut - 1 (0…3) | ubyte[boyut] | işaretsiz (sıfır-genişletilmiş) dört baytlık tamsayı değeri, method_ids bölümüne bir dizin olarak yorumlanır ve yansıtıcı bir yöntem değerini temsil eder |
VALUE_ENUM | 0x1b | boyut - 1 (0…3) | ubyte[boyut] | işaretsiz (sıfır-genişletilmiş) dört baytlık tamsayı değeri, field_ids bölümüne bir dizin olarak yorumlanır ve numaralandırılmış türdeki bir sabitin değerini temsil eder |
VALUE_ARRAY | 0x1c | (yok; 0 olmalıdır) | kodlanmış_dizi | aşağıda " encoded_array biçimi" ile belirtilen biçimde bir değerler dizisi. value boyutu kodlamada gizlidir. |
VALUE_ANNOTATION | 0x1d | (yok; 0 olmalıdır) | kodlanmış_annotation | aşağıda " encoded_annotation biçimi" ile belirtilen biçimde bir alt açıklama. value boyutu kodlamada gizlidir. |
VALUE_NULL | 0x1e | (yok; 0 olmalıdır) | (Yok) | null referans değeri |
VALUE_BOOLEAN | 0x1f | boole (0…1) | (Yok) | bir bitlik değer; false için 0 ve true için 1 . Bit, value_arg içinde temsil edilir. |
kodlanmış_dizi biçimi
İsim | Biçim | Tanım |
---|---|---|
boyut | uleb128 | dizideki eleman sayısı |
değerler | kodlanmış_değer[boyut] | bu bölüm tarafından belirtilen biçimde sırayla birleştirilmiş bir dizi size encoded_value bayt dizisi. |
kodlanmış_annotation biçimi
İsim | Biçim | Tanım |
---|---|---|
type_idx | uleb128 | açıklama türü. Bu bir sınıf (dizi veya ilkel değil) türü olmalıdır. |
boyut | uleb128 | bu ek açıklamada ad-değer eşlemelerinin sayısı |
elementler | annotation_element[boyut] | doğrudan satır içi olarak gösterilen (ofset olarak değil) açıklamanın öğeleri. Öğeler, string_id dizinine göre artan düzende sıralanmalıdır. |
annotation_element biçimi
İsim | Biçim | Tanım |
---|---|---|
ad_idx | uleb128 | string_ids bölümünde bir dizin olarak gösterilen öğe adı. Dize, yukarıda tanımlanan ÜyeAdı sözdizimine uygun olmalıdır. |
değer | kodlanmış_değer | eleman değeri |
dize sözdizimi
Bir .dex
dosyasında, nihayetinde bir dizgeye atıfta bulunan birkaç çeşit öğe vardır. Aşağıdaki BNF stili tanımlar, bu dizeler için kabul edilebilir sözdizimini gösterir.
BasitAdı
SimpleName , diğer şeylerin adlarının sözdiziminin temelidir. .dex
formatı burada oldukça geniş bir alana izin verir (çoğu yaygın kaynak dilden çok daha fazlası). Kısaca, basit bir ad, herhangi bir düşük ASCII alfabetik karakter veya rakamdan, birkaç özel düşük ASCII sembolünden ve kontrol, boşluk veya özel karakter olmayan çoğu ASCII olmayan kod noktasından oluşur. 040
sürümünden başlayarak, biçim ek olarak boşluk karakterlerine izin verir (Unicode Zs
kategorisi). Yedek kod noktalarının ( U+d800
… U+dfff
) kendi başına geçerli ad karakterleri olarak kabul edilmediğini, ancak Unicode tamamlayıcı karakterlerinin geçerli olduğunu (bunlar SimpleNameChar için kuralın son alternatifiyle temsil edilir) ve bunların geçerli olduğunu unutmayın. MUTF-8 kodlamasında bir dosyada vekil kod noktaları çiftleri olarak temsil edilmelidir.
BasitAd → | ||
SimpleNameChar ( SimpleNameChar )* | ||
BasitAd Karakteri → | ||
'A' ... 'Z' | ||
| | 'a' ... 'z' | |
| | '0' … '9' | |
| | ' ' | DEX sürüm 040'tan beri |
| | '$' | |
| | '-' | |
| | '_' | |
| | U+00a0 | DEX sürüm 040'tan beri |
| | U+00a1 … U+1fff | |
| | U+2000 … U+200a | DEX sürüm 040'tan beri |
| | U+2010 … U+2027 | |
| | U+202f | DEX sürüm 040'tan beri |
| | U+2030 … U+d7ff | |
| | U+e000 … U+ffef | |
| | U+10000 … U+10ffff |
Üye adı
field_id_item ve method_id_item tarafından kullanılır
ÜyeAdı , bir sınıfın üyesinin adıdır; üyeler alanlar, yöntemler ve iç sınıflardır.
ÜyeAdı → | |
BasitAdı | |
| | '<' BasitAdı '>' |
TamSınıfAdı
FullClassName , isteğe bağlı bir paket belirteci ve ardından gerekli bir ad içeren tam nitelikli bir sınıf adıdır.
TamSınıfAdı → | |
İsteğe BağlıPaketÖneki BasitAdı | |
İsteğe Bağlı Paket Öneki → | |
( SimpleName '/' )* |
TipAçıklayıcı
type_id_item tarafından kullanılır
TypeDescriptor , temel öğeler, sınıflar, diziler ve void
dahil olmak üzere herhangi bir türün temsilidir. Çeşitli sürümlerin anlamı için aşağıya bakın.
Tip Tanımlayıcı → | |
'V' | |
| | FieldTypeDescriptor |
FieldTypeDescriptor → | |
NonArrayFieldTypeDescriptor | |
| | ( '[' * 1…255) NonArrayFieldTypeDescriptor |
NonArrayFieldTypeDescriptor → | |
'Z' | |
| | 'B' |
| | 'S' |
| | 'C' |
| | 'I' |
| | 'J' |
| | 'F' |
| | 'D' |
| | 'L' TamSınıfAdı ';' |
Kısa Tanımlayıcı
proto_id_item tarafından kullanılır
ShortyDescriptor , çeşitli referans (sınıf veya dizi) türleri arasında hiçbir ayrım olmaması dışında, dönüş ve parametre türleri dahil olmak üzere bir yöntem prototipinin kısa biçimli temsilidir. Bunun yerine, tüm referans türleri tek bir 'L'
karakteri ile temsil edilir.
Kısa Tanımlayıcı → | |
ShortyReturnType ( ShortyFieldType )* | |
ShortyReturnType → | |
'V' | |
| | ShortyFieldType |
ShortyFieldType → | |
'Z' | |
| | 'B' |
| | 'S' |
| | 'C' |
| | 'I' |
| | 'J' |
| | 'F' |
| | 'D' |
| | 'L' |
TipAçıklayıcı Semantik
TypeDescriptor değişkenlerinin her birinin anlamı budur.
Sözdizimi | Anlam |
---|---|
V | void ; sadece iade türleri için geçerlidir |
Z | boolean |
B | byte |
S | short |
C | char |
ben | int |
J | long |
F | float |
D | double |
L tam/nitelikli/Ad ; | sınıf fully.qualified.Name |
[ tanımlayıcı | 255'ten fazla boyuta sahip olmak geçersiz olsa da, diziler dizileri için özyinelemeli olarak kullanılabilir descriptor dizisi. |
Öğeler ve ilgili yapılar
Bu bölüm, bir .dex
dosyasında görünebilecek her bir üst düzey öğenin tanımlarını içerir.
başlık_öğesi
başlık bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
büyü | ubyte[8] = DEX_FILE_MAGIC | sihirli değer. Daha fazla ayrıntı için yukarıdaki " DEX_FILE_MAGIC " başlığı altındaki tartışmaya bakın. |
sağlama toplamı | uint | dosyanın geri kalanının adler32 sağlama toplamı ( magic ve bu alan dışında her şey); dosya bozulmasını tespit etmek için kullanılır |
imza | ubyte[20] | Dosyanın geri kalanının ( magic , checksum ve bu alan dışında her şey) SHA-1 imzası (karma); dosyaları benzersiz bir şekilde tanımlamak için kullanılır |
Dosya boyutu | uint | tüm dosyanın boyutu (başlık dahil), bayt cinsinden |
başlık_boyutu | uint = 0x70 | bayt cinsinden başlığın boyutu (bu bölümün tamamı). Bu, formatı geçersiz kılmadan en azından sınırlı miktarda geriye/ileriye uyumluluğa izin verir. |
endian_tag | uint = ENDIAN_CONSTANT | endianness etiketi. Daha fazla ayrıntı için yukarıdaki " ENDIAN_CONSTANT ve REVERSE_ENDIAN_CONSTANT " altındaki tartışmaya bakın. |
link_size | uint | bağlantı bölümünün boyutu veya bu dosya statik olarak bağlı değilse 0 |
link_off | uint | dosyanın başlangıcından bağlantı bölümüne uzaklık veya link_size == 0 0 Sıfır değilse, mahsup link_data bölümünde bir mahsup olmalıdır. İşaret edilen verilerin formatı bu belgede belirtilmemiş olarak bırakılmıştır; bu başlık alanı (ve önceki), çalışma zamanı uygulamaları tarafından kullanılmak üzere kanca olarak bırakılır. |
map_off | uint | dosyanın başlangıcından harita öğesine ofset. Sıfırdan farklı olması gereken offset, data bölümünde bir offsete olmalı ve veriler aşağıdaki " map_list " ile belirtilen formatta olmalıdır. |
string_ids_size | uint | dize tanımlayıcıları listesindeki dize sayısı |
string_ids_off | uint | dosyanın başlangıcından dize tanımlayıcıları listesine kadar ofset veya string_ids_size == 0 0 kuşkusuz bir garip kenar durumu). Ofset, sıfır değilse, string_ids bölümünün başlangıcı olmalıdır. |
type_ids_size | uint | tip tanımlayıcıları listesindeki eleman sayısı, en fazla 65535 |
type_ids_off | uint | dosyanın başlangıcından tür tanımlayıcıları listesine kadar ofset veya type_ids_size == 0 0 kuşkusuz bir garip kenar durumu). Ofset, sıfır değilse, type_ids bölümünün başlangıcı olmalıdır. |
proto_ids_size | uint | prototip tanımlayıcılar listesindeki öğelerin sayısı, en fazla 65535 |
proto_ids_off | uint | dosyanın başlangıcından prototip tanımlayıcılar listesine kadar ofset veya proto_ids_size == 0 0 kuşkusuz garip bir uç durum). Ofset, sıfır değilse, proto_ids bölümünün başlangıcı olmalıdır. |
field_ids_size | uint | alan tanımlayıcıları listesindeki öğelerin sayısı |
field_ids_off | uint | dosyanın başlangıcından alan tanımlayıcıları listesine uzaklık veya field_ids_size == 0 0 Ofset, sıfır değilse, field_ids bölümünün başlangıcı olmalıdır. |
method_ids_size | uint | yöntem tanımlayıcıları listesindeki öğelerin sayısı |
method_ids_off | uint | dosyanın başlangıcından yöntem tanımlayıcıları listesine uzaklık veya method_ids_size == 0 0 Ofset, sıfır değilse, method_ids bölümünün başlangıcı olmalıdır. |
class_defs_size | uint | sınıf tanımları listesindeki öğelerin sayısı |
class_defs_off | uint | dosyanın başlangıcından sınıf tanımları listesine uzaklık veya class_defs_size == 0 0 0 (kuşkusuz garip bir uç durum). Ofset, sıfır değilse, class_defs bölümünün başlangıcı olmalıdır. |
data_size | uint | Bayt cinsinden data bölümünün boyutu. sizeof(uint) öğesinin çift katı olmalıdır. |
data_off | uint | dosyanın başlangıcından data bölümünün başlangıcına kadar ofset. |
map_list
veri bölümünde görünür
header_item'den referans alındı
hizalama: 4 bayt
Bu, bir dosyanın tüm içeriğinin sırayla bir listesidir. header_item
ile ilgili olarak biraz fazlalık içerir, ancak tüm dosya üzerinde yineleme yapmak için kullanımı kolay bir form olması amaçlanmıştır. Belirli bir tür, bir haritada en fazla bir kez görünmelidir, ancak biçimin geri kalanının ima ettiği kısıtlamalar dışında, hangi düzen türlerinin görünebileceği konusunda herhangi bir kısıtlama yoktur (örneğin, önce bir header
bölümü görünmelidir, ardından bir string_ids
gelmelidir). bölüm vb.). Ek olarak, harita girişleri ilk uzaklığa göre sıralanmalı ve çakışmamalıdır.
İsim | Biçim | Tanım |
---|---|---|
boyut | uint | girişlerde listenin boyutu |
liste | map_item[boyut] | listenin öğeleri |
map_item biçimi
İsim | Biçim | Tanım |
---|---|---|
tip | kısa | öğelerin türü; aşağıdaki tabloya bakınız |
kullanılmamış | kısa | (kullanılmamış) |
boyut | uint | belirtilen ofsette bulunacak öğe sayısının sayısı |
telafi etmek | uint | dosyanın başlangıcından söz konusu öğelere kadar ofset |
Tip Kodları
Öğe türü | Devamlı | Değer | Bayt Olarak Öğe Boyutu |
---|---|---|---|
başlık_öğesi | TYPE_HEADER_ITEM | 0x0000 | 0x70 |
string_id_item | TYPE_STRING_ID_ITEM | 0x0001 | 0x04 |
type_id_item | TYPE_TYPE_ID_ITEM | 0x0002 | 0x04 |
proto_id_item | TYPE_PROTO_ID_ITEM | 0x0003 | 0x0c |
field_id_item | TYPE_FIELD_ID_ITEM | 0x0004 | 0x08 |
method_id_item | TYPE_METHOD_ID_ITEM | 0x0005 | 0x08 |
class_def_item | TYPE_CLASS_DEF_ITEM | 0x0006 | 0x20 |
call_site_id_item | TYPE_CALL_SITE_ID_ITEM | 0x0007 | 0x04 |
method_handle_item | TYPE_METHOD_HANDLE_ITEM | 0x0008 | 0x08 |
map_list | TYPE_MAP_LIST | 0x1000 | 4 + (ürün boyutu * 12) |
tür_listesi | TYPE_TYPE_LIST | 0x1001 | 4 + (ürün.boyutu * 2) |
annotation_set_ref_list | TYPE_ANNOTATION_SET_REF_LIST | 0x1002 | 4 + (ürün boyutu * 4) |
annotation_set_item | TYPE_ANNOTATION_SET_ITEM | 0x1003 | 4 + (ürün.boyutu * 4) |
class_data_item | TYPE_CLASS_DATA_ITEM | 0x2000 | örtük; ayrıştırmalı |
kod_öğesi | TYPE_CODE_ITEM | 0x2001 | örtük; ayrıştırmalı |
string_data_item | TYPE_STRING_DATA_ITEM | 0x2002 | örtük; ayrıştırmalı |
debug_info_item | TYPE_DEBUG_INFO_ITEM | 0x2003 | örtük; ayrıştırmalı |
annotation_item | TYPE_ANNOTATION_ITEM | 0x2004 | örtük; ayrıştırmalı |
kodlanmış_array_item | TYPE_ENCODED_ARRAY_ITEM | 0x2005 | örtük; ayrıştırmalı |
annotations_directory_item | TYPE_ANNOTATIONS_DIRECTORY_ITEM | 0x2006 | örtük; ayrıştırmalı |
hideapi_class_data_item | TYPE_HIDDENAPI_CLASS_DATA_ITEM | 0xF000 | örtük; ayrıştırmalı |
string_id_item
string_ids bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
string_data_off | uint | dosyanın başlangıcından bu öğe için dize verilerine göre değişir. Ofset, data bölümündeki bir konuma olmalıdır ve veriler, aşağıdaki " string_data_item " ile belirtilen biçimde olmalıdır. Ofset için hizalama gerekliliği yoktur. |
string_data_item
veri bölümünde görünür
hizalama: yok (bayt hizalı)
İsim | Biçim | Tanım |
---|---|---|
utf16_size | uleb128 | bu dizenin boyutu, UTF-16 kod birimlerinde (birçok sistemde "dize uzunluğu"dur). Yani, bu, dizenin kodu çözülmüş uzunluğudur. (Kodlanmış uzunluk, 0 baytın konumu ile belirtilir.) |
veri | ubyte[] | bir dizi MUTF-8 kod birimi (aka sekizli, diğer adıyla bayt) ve ardından 0 değerinde bir bayt. Veri formatı hakkında ayrıntılar ve tartışma için yukarıdaki "MUTF-8 (Modifiye UTF-8) Kodlaması" bölümüne bakın. Not: UTF-16 vekil kod birimlerini (yani, |
type_id_item
type_ids bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
tanımlayıcı_idx | uint | bu türdeki tanımlayıcı dize için string_ids listesine dizin. Dize, yukarıda tanımlanan TypeDescriptor sözdizimine uygun olmalıdır. |
proto_id_item
proto_ids bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
shorty_idx | uint | bu prototipin kısa biçimli tanımlayıcı dizesi için string_ids listesine dizin. Dize, yukarıda tanımlanan ShortyDescriptor sözdizimine uymalı ve bu öğenin dönüş türüne ve parametrelerine karşılık gelmelidir. |
dönüş_tipi_idx | uint | bu prototipin dönüş türü için type_ids listesine dizin |
parametreler_off | uint | dosyanın başlangıcından bu prototip için parametre türleri listesine ofset veya bu prototipin parametresi yoksa 0 . Bu ofset, sıfır değilse, data bölümünde olmalı ve oradaki veriler, aşağıda "type_list" ile belirtilen biçimde olmalıdır. Ek olarak, listede void tipine atıfta bulunulmamalıdır. |
field_id_item
field_ids bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
sınıf_idx | kısa | bu alanın tanımlayıcısı için type_ids listesine dizin. Bu, bir dizi veya ilkel tür değil, bir sınıf türü olmalıdır. |
type_idx | kısa | bu alanın türü için type_ids listesine dizin |
ad_idx | uint | bu alanın adı için string_ids listesine dizin. Dize, yukarıda tanımlanan ÜyeAdı sözdizimine uygun olmalıdır. |
method_id_item
method_ids bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
sınıf_idx | kısa | Bu yöntemin tanımlayıcısı için type_ids listesine dizin. Bu, ilkel bir tür değil, bir sınıf veya dizi türü olmalıdır. |
proto_idx | kısa | bu yöntemin prototipi için proto_ids listesine dizin |
ad_idx | uint | Bu yöntemin adı için string_ids listesine dizin. Dize, yukarıda tanımlanan ÜyeAdı sözdizimine uygun olmalıdır. |
class_def_item
class_defs bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
sınıf_idx | uint | bu sınıf için type_ids listesine dizin. Bu, bir dizi veya ilkel tür değil, bir sınıf türü olmalıdır. |
access_flags | uint | sınıf için erişim bayrakları ( public , final , vb.). Ayrıntılar için bkz. " access_flags Tanımları". |
süper sınıf_idx | uint | üst sınıf için type_ids listesine dizin veya bu sınıfın üst sınıfı yoksa (yani, Object gibi bir kök sınıfsa) NO_INDEX sabit değeri. Varsa, bu bir dizi veya ilkel tür değil, bir sınıf türü olmalıdır. |
interfaces_off | uint | dosyanın başlangıcından arabirimler listesine kadar ofset veya hiçbiri yoksa 0 . Bu offset data bölümünde olmalı ve oradaki data aşağıdaki " type_list " ile belirtilen formatta olmalıdır. Listedeki öğelerin her biri bir sınıf türü olmalıdır (bir dizi veya ilkel tür değil) ve herhangi bir kopya olmamalıdır. |
kaynak_dosya_idx | uint | Bu sınıf için (en azından çoğu) orijinal kaynağı içeren dosyanın adı için string_ids listesine dizin veya bu bilginin eksikliğini temsil etmek için NO_INDEX özel değeri. Herhangi bir yöntemin debug_info_item bu kaynak dosyayı geçersiz kılabilir, ancak beklenti, çoğu sınıfın yalnızca bir kaynak dosyadan gelmesidir. |
annotations_off | uint | dosyanın başlangıcından bu sınıf için ek açıklama yapısına uzaklık veya bu sınıfta herhangi bir açıklama yoksa 0 . Bu mahsup, sıfır değilse, data bölümünde olmalıdır ve buradaki veriler, aşağıdaki " annotations_directory_item " ile belirtilen biçimde olmalı ve tüm öğeler tanımlayıcı olarak bu sınıfa atıfta bulunmalıdır. |
class_data_off | uint | dosyanın başlangıcından bu öğe için ilişkili sınıf verilerine ofset veya bu sınıf için sınıf verisi yoksa 0 . (Örneğin bu sınıf bir işaretleyici arayüzü ise bu durum söz konusu olabilir.) Sıfırdan farklı ise offset data bölümünde olmalı ve oradaki data aşağıdaki " class_data_item " ile belirtilen formatta olmalıdır, tanımlayıcı olarak bu sınıfa atıfta bulunan tüm öğelerle. |
static_values_off | uint | dosyanın başlangıcından static alanlar için başlangıç değerlerinin listesine kadar ofset veya hiçbiri yoksa 0 (ve tüm static alanlar 0 veya null ile başlatılmalıdır). Bu offset data bölümünde olmalı ve oradaki veriler aşağıda " encoded_array_item " ile belirtilen formatta olmalıdır. Dizinin boyutu, bu sınıf tarafından bildirilen static alanların sayısından daha büyük olmamalıdır ve öğeler, karşılık gelen field_list belirtilen sırayla static alanlara karşılık gelir. Her dizi öğesinin türü, karşılık gelen alanın bildirilen türüyle eşleşmelidir. Dizide static alanlardan daha az öğe varsa, kalan alanlar türe uygun 0 veya null ile başlatılır. |
call_site_id_item
call_site_ids bölümünde görünür
hizalama: 4 bayt
İsim | Biçim | Tanım |
---|---|---|
call_site_off | uint | site tanımını çağırmak için dosyanın başlangıcından uzaklık. Ofset veri bölümünde olmalı ve oradaki veriler aşağıda "call_site_item" ile belirtilen formatta olmalıdır. |
call_site_item
veri bölümünde görünür
hizalama: yok (bayt hizalı)
call_site_item, öğeleri bir önyükleme bağlayıcı yöntemine sağlanan bağımsız değişkenlere karşılık gelen bir kodlanmış_array_itemdir. İlk üç argüman:
- Önyükleme bağlayıcı yöntemini (VALUE_METHOD_HANDLE) temsil eden bir yöntem tanıtıcısı.
- Önyükleme bağlayıcısının çözümlemesi gereken bir yöntem adı (VALUE_STRING).
- A method type corresponding to the type of the method name to be resolved (VALUE_METHOD_TYPE).
Any additional arguments are constant values passed to the bootstrap linker method. These arguments are passed in order and without any type conversions.
The method handle representing the bootstrap linker method must have return type java.lang.invoke.CallSite
. The first three parameter types are:
-
java.lang.invoke.Lookup
-
java.lang.String
-
java.lang.invoke.MethodType
The parameter types of any additional arguments are determined from their constant values.
method_handle_item
appears in the method_handles section
alignment: 4 bytes
Name | Format | Tanım |
---|---|---|
method_handle_type | ushort | type of the method handle; see table below |
unused | ushort | (unused) |
field_or_method_id | ushort | Field or method id depending on whether the method handle type is an accessor or a method invoker |
unused | ushort | (unused) |
Method Handle Type Codes
Constant | Value | Tanım |
---|---|---|
METHOD_HANDLE_TYPE_STATIC_PUT | 0x00 | Method handle is a static field setter (accessor) |
METHOD_HANDLE_TYPE_STATIC_GET | 0x01 | Method handle is a static field getter (accessor) |
METHOD_HANDLE_TYPE_INSTANCE_PUT | 0x02 | Method handle is an instance field setter (accessor) |
METHOD_HANDLE_TYPE_INSTANCE_GET | 0x03 | Method handle is an instance field getter (accessor) |
METHOD_HANDLE_TYPE_INVOKE_STATIC | 0x04 | Method handle is a static method invoker |
METHOD_HANDLE_TYPE_INVOKE_INSTANCE | 0x05 | Method handle is an instance method invoker |
METHOD_HANDLE_TYPE_INVOKE_CONSTRUCTOR | 0x06 | Method handle is a constructor method invoker |
METHOD_HANDLE_TYPE_INVOKE_DIRECT | 0x07 | Method handle is a direct method invoker |
METHOD_HANDLE_TYPE_INVOKE_INTERFACE | 0x08 | Method handle is an interface method invoker |
class_data_item
referenced from class_def_item
appears in the data section
alignment: none (byte-aligned)
Name | Format | Tanım |
---|---|---|
static_fields_size | uleb128 | the number of static fields defined in this item |
instance_fields_size | uleb128 | the number of instance fields defined in this item |
direct_methods_size | uleb128 | the number of direct methods defined in this item |
virtual_methods_size | uleb128 | the number of virtual methods defined in this item |
static_fields | encoded_field[static_fields_size] | the defined static fields, represented as a sequence of encoded elements. The fields must be sorted by field_idx in increasing order. |
instance_fields | encoded_field[instance_fields_size] | the defined instance fields, represented as a sequence of encoded elements. The fields must be sorted by field_idx in increasing order. |
direct_methods | encoded_method[direct_methods_size] | the defined direct (any of static , private , or constructor) methods, represented as a sequence of encoded elements. The methods must be sorted by method_idx in increasing order. |
virtual_methods | encoded_method[virtual_methods_size] | the defined virtual (none of static , private , or constructor) methods, represented as a sequence of encoded elements. This list should not include inherited methods unless overridden by the class that this item represents. The methods must be sorted by method_idx in increasing order. The method_idx of a virtual method must not be the same as any direct method. |
Note: All elements' field_id
s and method_id
s must refer to the same defining class.
encoded_field format
Name | Format | Tanım |
---|---|---|
field_idx_diff | uleb128 | index into the field_ids list for the identity of this field (includes the name and descriptor), represented as a difference from the index of previous element in the list. The index of the first element in a list is represented directly. |
access_flags | uleb128 | access flags for the field ( public , final , etc.). See " access_flags Definitions" for details. |
encoded_method format
Name | Format | Tanım |
---|---|---|
method_idx_diff | uleb128 | index into the method_ids list for the identity of this method (includes the name and descriptor), represented as a difference from the index of previous element in the list. The index of the first element in a list is represented directly. |
access_flags | uleb128 | access flags for the method ( public , final , etc.). See " access_flags Definitions" for details. |
code_off | uleb128 | offset from the start of the file to the code structure for this method, or 0 if this method is either abstract or native . The offset should be to a location in the data section. The format of the data is specified by " code_item " below. |
type_list
referenced from class_def_item and proto_id_item
appears in the data section
alignment: 4 bytes
Name | Format | Tanım |
---|---|---|
size | uint | size of the list, in entries |
list | type_item[size] | elements of the list |
type_item format
Name | Format | Tanım |
---|---|---|
type_idx | ushort | index into the type_ids list |
code_item
referenced from encoded_method
appears in the data section
alignment: 4 bytes
Name | Format | Tanım |
---|---|---|
registers_size | ushort | the number of registers used by this code |
ins_size | ushort | the number of words of incoming arguments to the method that this code is for |
outs_size | ushort | the number of words of outgoing argument space required by this code for method invocation |
tries_size | ushort | the number of try_item s for this instance. If non-zero, then these appear as the tries array just after the insns in this instance. |
debug_info_off | uint | offset from the start of the file to the debug info (line numbers + local variable info) sequence for this code, or 0 if there simply is no information. The offset, if non-zero, should be to a location in the data section. The format of the data is specified by " debug_info_item " below. |
insns_size | uint | size of the instructions list, in 16-bit code units |
insns | ushort[insns_size] | actual array of bytecode. The format of code in an insns array is specified by the companion document Dalvik bytecode . Note that though this is defined as an array of ushort , there are some internal structures that prefer four-byte alignment. Also, if this happens to be in an endian-swapped file, then the swapping is only done on individual ushort s and not on the larger internal structures. |
padding | ushort (optional) = 0 | two bytes of padding to make tries four-byte aligned. This element is only present if tries_size is non-zero and insns_size is odd. |
tries | try_item[tries_size] (optional) | array indicating where in the code exceptions are caught and how to handle them. Elements of the array must be non-overlapping in range and in order from low to high address. This element is only present if tries_size is non-zero. |
handlers | encoded_catch_handler_list (optional) | bytes representing a list of lists of catch types and associated handler addresses. Each try_item has a byte-wise offset into this structure. This element is only present if tries_size is non-zero. |
try_item format
Name | Format | Tanım |
---|---|---|
start_addr | uint | start address of the block of code covered by this entry. The address is a count of 16-bit code units to the start of the first covered instruction. |
insn_count | ushort | number of 16-bit code units covered by this entry. The last code unit covered (inclusive) is start_addr + insn_count - 1 . |
handler_off | ushort | offset in bytes from the start of the associated encoded_catch_hander_list to the encoded_catch_handler for this entry. This must be an offset to the start of an encoded_catch_handler . |
encoded_catch_handler_list format
Name | Format | Tanım |
---|---|---|
size | uleb128 | size of this list, in entries |
list | encoded_catch_handler[handlers_size] | actual list of handler lists, represented directly (not as offsets), and concatenated sequentially |
encoded_catch_handler format
Name | Format | Tanım |
---|---|---|
size | sleb128 | number of catch types in this list. If non-positive, then this is the negative of the number of catch types, and the catches are followed by a catch-all handler. For example: A size of 0 means that there is a catch-all but no explicitly typed catches. A size of 2 means that there are two explicitly typed catches and no catch-all. And a size of -1 means that there is one typed catch along with a catch-all. |
handlers | encoded_type_addr_pair[abs(size)] | stream of abs(size) encoded items, one for each caught type, in the order that the types should be tested. |
catch_all_addr | uleb128 (optional) | bytecode address of the catch-all handler. This element is only present if size is non-positive. |
encoded_type_addr_pair format
Name | Format | Tanım |
---|---|---|
type_idx | uleb128 | index into the type_ids list for the type of the exception to catch |
addr | uleb128 | bytecode address of the associated exception handler |
debug_info_item
referenced from code_item
appears in the data section
alignment: none (byte-aligned)
Each debug_info_item
defines a DWARF3-inspired byte-coded state machine that, when interpreted, emits the positions table and (potentially) the local variable information for a code_item
. The sequence begins with a variable-length header (the length of which depends on the number of method parameters), is followed by the state machine bytecodes, and ends with an DBG_END_SEQUENCE
byte.
The state machine consists of five registers. The address
register represents the instruction offset in the associated insns_item
in 16-bit code units. The address
register starts at 0
at the beginning of each debug_info
sequence and must only monotonically increase. The line
register represents what source line number should be associated with the next positions table entry emitted by the state machine. It is initialized in the sequence header, and may change in positive or negative directions but must never be less than 1
. The source_file
register represents the source file that the line number entries refer to. It is initialized to the value of source_file_idx
in class_def_item
. The other two variables, prologue_end
and epilogue_begin
, are boolean flags (initialized to false
) that indicate whether the next position emitted should be considered a method prologue or epilogue. The state machine must also track the name and type of the last local variable live in each register for the DBG_RESTART_LOCAL
code.
The header is as follows:
Name | Format | Tanım |
---|---|---|
line_start | uleb128 | the initial value for the state machine's line register. Does not represent an actual positions entry. |
parameters_size | uleb128 | the number of parameter names that are encoded. There should be one per method parameter, excluding an instance method's this , if any. |
parameter_names | uleb128p1[parameters_size] | string index of the method parameter name. An encoded value of NO_INDEX indicates that no name is available for the associated parameter. The type descriptor and signature are implied from the method descriptor and signature. |
The byte code values are as follows:
Name | Value | Format | Arguments | Tanım |
---|---|---|---|---|
DBG_END_SEQUENCE | 0x00 | (none) | terminates a debug info sequence for a code_item | |
DBG_ADVANCE_PC | 0x01 | uleb128 addr_diff | addr_diff : amount to add to address register | advances the address register without emitting a positions entry |
DBG_ADVANCE_LINE | 0x02 | sleb128 line_diff | line_diff : amount to change line register by | advances the line register without emitting a positions entry |
DBG_START_LOCAL | 0x03 | uleb128 register_num uleb128p1 name_idx uleb128p1 type_idx | register_num : register that will contain localname_idx : string index of the nametype_idx : type index of the type | introduces a local variable at the current address. Either name_idx or type_idx may be NO_INDEX to indicate that that value is unknown. |
DBG_START_LOCAL_EXTENDED | 0x04 | uleb128 register_num uleb128p1 name_idx uleb128p1 type_idx uleb128p1 sig_idx | register_num : register that will contain localname_idx : string index of the nametype_idx : type index of the typesig_idx : string index of the type signature | introduces a local with a type signature at the current address. Any of name_idx , type_idx , or sig_idx may be NO_INDEX to indicate that that value is unknown. (If sig_idx is -1 , though, the same data could be represented more efficiently using the opcode DBG_START_LOCAL .) Note: See the discussion under " |
DBG_END_LOCAL | 0x05 | uleb128 register_num | register_num : register that contained local | marks a currently-live local variable as out of scope at the current address |
DBG_RESTART_LOCAL | 0x06 | uleb128 register_num | register_num : register to restart | re-introduces a local variable at the current address. The name and type are the same as the last local that was live in the specified register. |
DBG_SET_PROLOGUE_END | 0x07 | (none) | sets the prologue_end state machine register, indicating that the next position entry that is added should be considered the end of a method prologue (an appropriate place for a method breakpoint). The prologue_end register is cleared by any special ( >= 0x0a ) opcode. | |
DBG_SET_EPILOGUE_BEGIN | 0x08 | (none) | sets the epilogue_begin state machine register, indicating that the next position entry that is added should be considered the beginning of a method epilogue (an appropriate place to suspend execution before method exit). The epilogue_begin register is cleared by any special ( >= 0x0a ) opcode. | |
DBG_SET_FILE | 0x09 | uleb128p1 name_idx | name_idx : string index of source file name; NO_INDEX if unknown | indicates that all subsequent line number entries make reference to this source file name, instead of the default name specified in code_item |
Special Opcodes | 0x0a…0xff | (none) | advances the line and address registers, emits a position entry, and clears prologue_end and epilogue_begin . See below for description. |
Special opcodes
Opcodes with values between 0x0a
and 0xff
(inclusive) move both the line
and address
registers by a small amount and then emit a new position table entry. The formula for the increments are as follows:
DBG_FIRST_SPECIAL = 0x0a // the smallest special opcode DBG_LINE_BASE = -4 // the smallest line number increment DBG_LINE_RANGE = 15 // the number of line increments represented adjusted_opcode = opcode - DBG_FIRST_SPECIAL line += DBG_LINE_BASE + (adjusted_opcode % DBG_LINE_RANGE) address += (adjusted_opcode / DBG_LINE_RANGE)
annotations_directory_item
referenced from class_def_item
appears in the data section
alignment: 4 bytes
Name | Format | Tanım |
---|---|---|
class_annotations_off | uint | offset from the start of the file to the annotations made directly on the class, or 0 if the class has no direct annotations. The offset, if non-zero, should be to a location in the data section. The format of the data is specified by " annotation_set_item " below. |
fields_size | uint | count of fields annotated by this item |
annotated_methods_size | uint | count of methods annotated by this item |
annotated_parameters_size | uint | count of method parameter lists annotated by this item |
field_annotations | field_annotation[fields_size] (optional) | list of associated field annotations. The elements of the list must be sorted in increasing order, by field_idx . |
method_annotations | method_annotation[methods_size] (optional) | list of associated method annotations. The elements of the list must be sorted in increasing order, by method_idx . |
parameter_annotations | parameter_annotation[parameters_size] (optional) | list of associated method parameter annotations. The elements of the list must be sorted in increasing order, by method_idx . |
Note: All elements' field_id
s and method_id
s must refer to the same defining class.
field_annotation format
Name | Format | Tanım |
---|---|---|
field_idx | uint | index into the field_ids list for the identity of the field being annotated |
annotations_off | uint | offset from the start of the file to the list of annotations for the field. The offset should be to a location in the data section. The format of the data is specified by " annotation_set_item " below. |
method_annotation format
Name | Format | Tanım |
---|---|---|
method_idx | uint | index into the method_ids list for the identity of the method being annotated |
annotations_off | uint | offset from the start of the file to the list of annotations for the method. The offset should be to a location in the data section. The format of the data is specified by " annotation_set_item " below. |
parameter_annotation format
Name | Format | Tanım |
---|---|---|
method_idx | uint | index into the method_ids list for the identity of the method whose parameters are being annotated |
annotations_off | uint | offset from the start of the file to the list of annotations for the method parameters. The offset should be to a location in the data section. The format of the data is specified by " annotation_set_ref_list " below. |
annotation_set_ref_list
referenced from parameter_annotations_item
appears in the data section
alignment: 4 bytes
Name | Format | Tanım |
---|---|---|
size | uint | size of the list, in entries |
list | annotation_set_ref_item[size] | elements of the list |
annotation_set_ref_item format
Name | Format | Tanım |
---|---|---|
annotations_off | uint | offset from the start of the file to the referenced annotation set or 0 if there are no annotations for this element. The offset, if non-zero, should be to a location in the data section. The format of the data is specified by " annotation_set_item " below. |
annotation_set_item
referenced from annotations_directory_item, field_annotations_item, method_annotations_item, and annotation_set_ref_item
appears in the data section
alignment: 4 bytes
Name | Format | Tanım |
---|---|---|
size | uint | size of the set, in entries |
entries | annotation_off_item[size] | elements of the set. The elements must be sorted in increasing order, by type_idx . |
annotation_off_item format
Name | Format | Tanım |
---|---|---|
annotation_off | uint | offset from the start of the file to an annotation. The offset should be to a location in the data section, and the format of the data at that location is specified by " annotation_item " below. |
annotation_item
referenced from annotation_set_item
appears in the data section
alignment: none (byte-aligned)
Name | Format | Tanım |
---|---|---|
visibility | ubyte | intended visibility of this annotation (see below) |
annotation | encoded_annotation | encoded annotation contents, in the format described by " encoded_annotation format" under " encoded_value encoding" above. |
Visibility values
These are the options for the visibility
field in an annotation_item
:
Name | Value | Tanım |
---|---|---|
VISIBILITY_BUILD | 0x00 | intended only to be visible at build time (eg, during compilation of other code) |
VISIBILITY_RUNTIME | 0x01 | intended to visible at runtime |
VISIBILITY_SYSTEM | 0x02 | intended to visible at runtime, but only to the underlying system (and not to regular user code) |
encoded_array_item
referenced from class_def_item
appears in the data section
alignment: none (byte-aligned)
Name | Format | Tanım |
---|---|---|
value | encoded_array | bytes representing the encoded array value, in the format specified by " encoded_array Format" under " encoded_value Encoding" above. |
hiddenapi_class_data_item
This section contains data on restricted interfaces used by each class.
Note: The hidden API feature was introduced in Android 10.0 and is only applicable to the DEX files of classes in the boot class path. The list of flags described below may be extended in the future releases of Android. For more information, see restrictions on non-SDK interfaces .
Name | Format | Tanım |
---|---|---|
size | uint | total size of the section |
offsets | uint[] | array of offsets indexed by class_idx . A zero array entry at index class_idx means that either there is no data for this class_idx , or all hidden API flags are zero. Otherwise the array entry is non-zero and contains an offset from the beginning of the section to an array of hidden API flags for this class_idx . |
flags | uleb128[] | concatenated arrays of hidden API flags for each class. Possible flag values are described in the table below. Flags are encoded in the same order as fields and methods are encoded in class data. |
Restriction flag types:
Name | Value | Tanım |
---|---|---|
whitelist | 0 | Interfaces that can be freely used and are supported as part of the officially documented Android framework Package Index . |
greylist | 1 | Non-SDK interfaces that can be used regardless of the application's target API level . |
blacklist | 2 | Non-SDK interfaces that cannot be used regardless of the application's target API level . Accessing one of these interfaces causes a runtime error . |
greylist‑max‑o | 3 | Non-SDK interfaces that can be used for Android 8.x and below unless they are restricted. |
greylist‑max‑p | 4 | Non-SDK interfaces that can be used for Android 9.x unless they are restricted. |
greylist‑max‑q | 5 | Non-SDK interfaces that can be used for Android 10.x unless they are restricted. |
greylist‑max‑r | 6 | Non-SDK interfaces that can be used for Android 11.x unless they are restricted. |
System annotations
System annotations are used to represent various pieces of reflective information about classes (and methods and fields). This information is generally only accessed indirectly by client (non-system) code.
System annotations are represented in .dex
files as annotations with visibility set to VISIBILITY_SYSTEM
.
dalvik.annotation.AnnotationDefault
appears on methods in annotation interfaces
An AnnotationDefault
annotation is attached to each annotation interface which wishes to indicate default bindings.
Name | Format | Tanım |
---|---|---|
value | Annotation | the default bindings for this annotation, represented as an annotation of this type. The annotation need not include all names defined by the annotation; missing names simply do not have defaults. |
dalvik.annotation.EnclosingClass
appears on classes
An EnclosingClass
annotation is attached to each class which is either defined as a member of another class, per se, or is anonymous but not defined within a method body (eg, a synthetic inner class). Every class that has this annotation must also have an InnerClass
annotation. Additionally, a class must not have both an EnclosingClass
and an EnclosingMethod
annotation.
Name | Format | Tanım |
---|---|---|
value | Class | the class which most closely lexically scopes this class |
dalvik.annotation.EnclosingMethod
appears on classes
An EnclosingMethod
annotation is attached to each class which is defined inside a method body. Every class that has this annotation must also have an InnerClass
annotation. Additionally, a class must not have both an EnclosingClass
and an EnclosingMethod
annotation.
Name | Format | Tanım |
---|---|---|
value | Method | the method which most closely lexically scopes this class |
dalvik.annotation.InnerClass
appears on classes
An InnerClass
annotation is attached to each class which is defined in the lexical scope of another class's definition. Any class which has this annotation must also have either an EnclosingClass
annotation or an EnclosingMethod
annotation.
Name | Format | Tanım |
---|---|---|
name | String | the originally declared simple name of this class (not including any package prefix). If this class is anonymous, then the name is null . |
accessFlags | int | the originally declared access flags of the class (which may differ from the effective flags because of a mismatch between the execution models of the source language and target virtual machine) |
dalvik.annotation.MemberClasses
appears on classes
A MemberClasses
annotation is attached to each class which declares member classes. (A member class is a direct inner class that has a name.)
Name | Format | Tanım |
---|---|---|
value | Class[] | array of the member classes |
dalvik.annotation.MethodParameters
appears on methods
Note: This annotation was added after Android 7.1. Its presence on earlier Android releases will be ignored.
A MethodParameters
annotation is optional and can be used to provide parameter metadata such as parameter names and modifiers.
The annotation can be omitted from a method or constructor safely when the parameter metadata is not required at runtime. java.lang.reflect.Parameter.isNamePresent()
can be used to check whether metadata is present for a parameter, and the associated reflection methods such as java.lang.reflect.Parameter.getName()
will fall back to default behavior at runtime if the information is not present.
When including parameter metadata, compilers must include information for generated classes such as enums, since the parameter metadata includes whether or not a parameter is synthetic or mandated.
A MethodParameters
annotation describes only individual method parameters. Therefore, compilers may omit the annotation entirely for constructors and methods that have no parameters, for the sake of code-size and runtime efficiency.
The arrays documented below must be the same size as for the method_id_item
dex structure associated with the method, otherwise a java.lang.reflect.MalformedParametersException
will be thrown at runtime.
That is: method_id_item.proto_idx
-> proto_id_item.parameters_off
-> type_list.size
must be the same as names().length
and accessFlags().length
.
Because MethodParameters
describes all formal method parameters, even those not explicitly or implicitly declared in source code, the size of the arrays may differ from the Signature or other metadata information that is based only on explicit parameters declared in source code. MethodParameters
will also not include any information about type annotation receiver parameters that do not exist in the actual method signature.
Name | Format | Tanım |
---|---|---|
names | String[] | The names of formal parameters for the associated method. The array must not be null but must be empty if there are no formal parameters. A value in the array must be null if the formal parameter with that index has no name. If parameter name strings are empty or contain '.', ';', '[' or '/' then a java.lang.reflect.MalformedParametersException will be thrown at runtime. |
accessFlags | int[] | The access flags of the formal parameters for the associated method. The array must not be null but must be empty if there are no formal parameters. The value is a bit mask with the following values:
java.lang.reflect.MalformedParametersException will be thrown at runtime. |
dalvik.annotation.Signature
appears on classes, fields, and methods
A Signature
annotation is attached to each class, field, or method which is defined in terms of a more complicated type than is representable by a type_id_item
. The .dex
format does not define the format for signatures; it is merely meant to be able to represent whatever signatures a source language requires for successful implementation of that language's semantics. As such, signatures are not generally parsed (or verified) by virtual machine implementations. The signatures simply get handed off to higher-level APIs and tools (such as debuggers). Any use of a signature, therefore, should be written so as not to make any assumptions about only receiving valid signatures, explicitly guarding itself against the possibility of coming across a syntactically invalid signature.
Because signature strings tend to have a lot of duplicated content, a Signature
annotation is defined as an array of strings, where duplicated elements naturally refer to the same underlying data, and the signature is taken to be the concatenation of all the strings in the array. There are no rules about how to pull apart a signature into separate strings; that is entirely up to the tools that generate .dex
files.
Name | Format | Tanım |
---|---|---|
value | String[] | the signature of this class or member, as an array of strings that is to be concatenated together |
dalvik.annotation.Throws
appears on methods
A Throws
annotation is attached to each method which is declared to throw one or more exception types.
Name | Format | Tanım |
---|---|---|
value | Class[] | the array of exception types thrown |