-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libbootimg: Fix support of Stock Sony ELF boot images #2
base: master
Are you sure you want to change the base?
Conversation
Tested on both Primary and Secondary Stock 4.3 based installations. |
Confirmed working fine for Huashan ELF stock bootimages. |
Up |
Updated with support for the newer Sony ELF boot images.
|
501802b
to
8986984
Compare
0aaf4e8
to
71d4468
Compare
* Unlike all boot images built for CyanogenMod or AOSP based ROMs over the last years, the elf bootimages from Stock also include additional metadata in the header section that is required for the device to power up with its kernel * Add a 3900 8bits array at the end of the header, followed by the 16 chars of the added bootimage name, in order to match the Sony ELF 4096 first block and therefore save the additional data from Stock images * Regular Sony ELF images have about 1200-1600 chars there so filling the 4096 block is more than enough for this, and moving the bootimage name at the end makes things safer Change-Id: Ic2b619b6f5e862920dcfefa5b86b016987305d4a Signed-off-by: AdrianDC <[email protected]>
The boot image found in sony firmwares (stock) is different to the already implemented version. This change adds support for these images (found in the Z2) by introducing more flexibility in the ELF handling and the output format (ELF --> ANDROID!) In particular: - Use a more dynamic structure to describe elf files: Add handling information (e.g., the elf version) and separate structures for the ELF header, the program headers, and the section headers - Adjust the read/load operations to account for the new structure - Add handling code for the differentiation between the two known ELF versions - Adjust the writing code such that it can output the content of an ELF image as a standard ANDROID! image: The newer ELF versions are not booted if a single (unused) bit is modifed Possibly the (unlocked) bootloader performs a signature check only for ELF files - Add some debug code that allows to print either to stdout or the kernel log (useful for on-device debugging) - Extend the Sony Stock support in a dynamic way - Add dependencies for klog_write - Also fix all minor warnings The code has been tested with the boot image of an Xperia Z2, and on the devices from the original ELF implementation (SP) Change-Id: I0e9a41ae6ce26bf4608ef86cec1e2735f746abb6 Signed-off-by: Alexander Diewald <[email protected]> Signed-off-by: Adrian DC <[email protected]>
* Used for debugging in the first place * Call libbootimg_get_elf_version earlier for outputs Change-Id: Id16fa289957b168c3fb6b578a8a83a0a6ddd88c5 Signed-off-by: Adrian DC <[email protected]>
* Kept as reference to easily compare alternative headers Change-Id: I25b62f898acb192c0b9ac7df5489839e0525b1d4 Signed-off-by: Adrian DC <[email protected]>
* Additional errors / success outputs * Display sizes in decimals instead of hexadecimal * Rewrite the ELF headers details outputs * Cleanup code styles Change-Id: I3b4e2277474497d8d8d97056562457df88a20779 Signed-off-by: Adrian DC <[email protected]>
* Usage of the second (rpm) should only be on 8960 * Usage of the DTB data added for v2 (8974) * The ELF format should not have blank padding added Change-Id: I66926b91b173563e767a76cb9bf332e4e6e0a9fa Signed-off-by: Adrian DC <[email protected]>
f68b50d
to
7b92072
Compare
* Store the initial 8 bytes of metadata that used to be ignored with an offset in order to rebuild the ELF original structure * Store the additional signature stored after the cmdline inside the section data on Sony ELF v2 bootimages Change-Id: I4324c88431c4d265d7e5c61f1491b6b1bfffb242 Signed-off-by: Adrian DC <[email protected]>
* Compatibility for the ELF partition used on the msm8996 devices like the Xperia X Performance * Structures aligned with 64bits addresses, offsets and sizes to match Stock bootimage * Usage of "__attribute__((packed))" to avoid structures padding breakage * Add the VER_ELF_4 identifier * Properly convert 32bits -> 64bits and reverse * Use the 64bits structures as main data * Add the libbootimg_load_elf_header function to separate the ELF header handling Change-Id: I40559ecc32833aed7b3ca7f3ebf8d53b9bc9b471 Signed-off-by: Adrian DC <[email protected]>
* Allows seeing hidden chars as hexadecimal values Change-Id: Ie35813f75d59596d484f9aab0bc659dcf3ea8ffe
Up. Used globally on Sony and non-Sony devices since 2016. |
You should fix the build. include/libbootimg.h The |
6ca06c8
to
056a34a
Compare
* A new situation on the Sony X Performance has shown that the "Processor" field from cpuinfo can be missing, therefore breaking the 32 / 64bits detection * Instead, use the native uname handling to get the name of the host machine, allowing to detect aarch64/armv8 properly Change-Id: Ib7f1aa6303390b4cc64e402e7ee242a272ddf722 Signed-off-by: Adrian DC <[email protected]>
ROMs over the last years, the elf bootimages from Stock
also include additional metadata in the header section
that is required for the device to power up with its kernel
followed by the 16 chars of the added bootimage name,
in order to match the Sony ELF 4096 first block
and therefore save the additional data from Stock images
so filling the 4096 block is more than enough for this,
and moving the bootimage name at the end makes things safer
Change-Id: Ic2b619b6f5e862920dcfefa5b86b016987305d4a
Signed-off-by: AdrianDC [email protected]