1*9e94795aSAndroid Build Coastguard Workerzipalign -- zip archive alignment tool 2*9e94795aSAndroid Build Coastguard Worker 3*9e94795aSAndroid Build Coastguard Workerusage: zipalign [-f] [-v] <align> infile.zip outfile.zip 4*9e94795aSAndroid Build Coastguard Worker zipalign -c [-v] <align> infile.zip 5*9e94795aSAndroid Build Coastguard Worker 6*9e94795aSAndroid Build Coastguard Worker -c : check alignment only (does not modify file) 7*9e94795aSAndroid Build Coastguard Worker -f : overwrite existing outfile.zip 8*9e94795aSAndroid Build Coastguard Worker -p : page align stored shared object files 9*9e94795aSAndroid Build Coastguard Worker -v : verbose output 10*9e94795aSAndroid Build Coastguard Worker <align> is in bytes, e.g. "4" provides 32-bit alignment 11*9e94795aSAndroid Build Coastguard Worker infile.zip is an existing Zip archive 12*9e94795aSAndroid Build Coastguard Worker outfile.zip will be created 13*9e94795aSAndroid Build Coastguard Worker 14*9e94795aSAndroid Build Coastguard Worker 15*9e94795aSAndroid Build Coastguard WorkerThe purpose of zipalign is to ensure that all uncompressed data starts 16*9e94795aSAndroid Build Coastguard Workerwith a particular alignment relative to the start of the file. This 17*9e94795aSAndroid Build Coastguard Workerallows those portions to be accessed directly with mmap() even if they 18*9e94795aSAndroid Build Coastguard Workercontain binary data with alignment restrictions. 19*9e94795aSAndroid Build Coastguard Worker 20*9e94795aSAndroid Build Coastguard WorkerSome data needs to be word-aligned for easy access, others might benefit 21*9e94795aSAndroid Build Coastguard Workerfrom being page-aligned. The adjustment is made by altering the size of 22*9e94795aSAndroid Build Coastguard Workerthe "extra" field in the zip Local File Header sections. Existing data 23*9e94795aSAndroid Build Coastguard Workerin the "extra" fields may be altered by this process. 24*9e94795aSAndroid Build Coastguard Worker 25*9e94795aSAndroid Build Coastguard WorkerCompressed data isn't very useful until it's uncompressed, so there's no 26*9e94795aSAndroid Build Coastguard Workerneed to adjust its alignment. 27*9e94795aSAndroid Build Coastguard Worker 28*9e94795aSAndroid Build Coastguard WorkerAlterations to the archive, such as renaming or deleting entries, will 29*9e94795aSAndroid Build Coastguard Workerpotentially disrupt the alignment of the modified entry and all later 30*9e94795aSAndroid Build Coastguard Workerentries. Files added to an "aligned" archive will not be aligned. 31*9e94795aSAndroid Build Coastguard Worker 32*9e94795aSAndroid Build Coastguard WorkerBy default, zipalign will not overwrite an existing output file. With the 33*9e94795aSAndroid Build Coastguard Worker"-f" flag, an existing file will be overwritten. 34*9e94795aSAndroid Build Coastguard Worker 35*9e94795aSAndroid Build Coastguard WorkerYou can use the "-c" flag to test whether a zip archive is properly aligned. 36*9e94795aSAndroid Build Coastguard Worker 37*9e94795aSAndroid Build Coastguard WorkerThe "-p" flag aligns any file with a ".so" extension, and which is stored 38*9e94795aSAndroid Build Coastguard Workeruncompressed in the zip archive, to a 4096-byte page boundary. This 39*9e94795aSAndroid Build Coastguard Workerfacilitates directly loading shared libraries from inside a zip archive. 40*9e94795aSAndroid Build Coastguard Worker 41