The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | zipalign -- zip archive alignment tool |
| 2 | |
| 3 | usage: zipalign [-f] [-v] <align> infile.zip outfile.zip |
Andy McFadden | 95ed76b | 2009-09-29 10:55:32 -0700 | [diff] [blame] | 4 | zipalign -c [-v] <align> infile.zip |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 5 | |
Andy McFadden | 95ed76b | 2009-09-29 10:55:32 -0700 | [diff] [blame] | 6 | -c : check alignment only (does not modify file) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 7 | -f : overwrite existing outfile.zip |
Narayan Kamath | e0b8d19 | 2015-02-26 17:57:55 +0000 | [diff] [blame] | 8 | -p : page align stored shared object files |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 9 | -v : verbose output |
| 10 | <align> is in bytes, e.g. "4" provides 32-bit alignment |
| 11 | infile.zip is an existing Zip archive |
| 12 | outfile.zip will be created |
| 13 | |
| 14 | |
| 15 | The purpose of zipalign is to ensure that all uncompressed data starts |
| 16 | with a particular alignment relative to the start of the file. This |
| 17 | allows those portions to be accessed directly with mmap() even if they |
| 18 | contain binary data with alignment restrictions. |
| 19 | |
| 20 | Some data needs to be word-aligned for easy access, others might benefit |
| 21 | from being page-aligned. The adjustment is made by altering the size of |
| 22 | the "extra" field in the zip Local File Header sections. Existing data |
| 23 | in the "extra" fields may be altered by this process. |
| 24 | |
| 25 | Compressed data isn't very useful until it's uncompressed, so there's no |
| 26 | need to adjust its alignment. |
| 27 | |
| 28 | Alterations to the archive, such as renaming or deleting entries, will |
| 29 | potentially disrupt the alignment of the modified entry and all later |
| 30 | entries. Files added to an "aligned" archive will not be aligned. |
| 31 | |
| 32 | By default, zipalign will not overwrite an existing output file. With the |
| 33 | "-f" flag, an existing file will be overwritten. |
| 34 | |
Andy McFadden | 95ed76b | 2009-09-29 10:55:32 -0700 | [diff] [blame] | 35 | You can use the "-c" flag to test whether a zip archive is properly aligned. |
| 36 | |
Narayan Kamath | e0b8d19 | 2015-02-26 17:57:55 +0000 | [diff] [blame] | 37 | The "-p" flag aligns any file with a ".so" extension, and which is stored |
| 38 | uncompressed in the zip archive, to a 4096-byte page boundary. This |
| 39 | facilitates directly loading shared libraries from inside a zip archive. |
| 40 | |