[Android Q&A, Help & Troubleshooting] smithjohn:
the kernel gzip magic bytes

ROM:000032E8 ; Attributes: bp-based frame

ROM:000032E8

ROM:000032E8 gzip_kernel_hearder ; CODE XREF: boot_uncompressing_linux_kernel+70p

ROM:000032E8 MOV R12, SP

ROM:000032EC STMFD SP!, {R3-R12,LR,PC}

ROM:000032F0 SUB R11, R12, #4

ROM:000032F4 LDR R4, =(dword_3E20B4 - 0x330C)

ROM:000032F8 SUBS R6, R2, #0

ROM:000032FC MOV R5, R0

ROM:00003300 MOV R7, R1

ROM:00003304 ADD R4, PC, R4 ; dword_3E20B4

ROM:00003308 MOV R10, R3

ROM:0000330C BEQ loc_3578

ROM:00003310 CMP R0, #0

ROM:00003314 MOVNE R9, R0

ROM:00003318 BEQ loc_351C

ROM:0000331C

ROM:0000331C loc_331C ; CODE XREF: gzip_kernel_hearder+2D0j

ROM:0000331C MOV R0, #0x30 ; '0'

ROM:00003320 BL sub_988

ROM:00003324 SUBS R8, R0, #0

ROM:00003328 BEQ loc_3544

ROM:0000332C MOV R0, #0x252C

ROM:00003330 BL sub_988

ROM:00003334 CMP R0, #0

ROM:00003338 STR R0, [R8,#0x20]

ROM:0000333C BEQ loc_3558

ROM:00003340 CMP R7, #0

ROM:00003344 BEQ loc_3508

ROM:00003348

ROM:00003348 loc_3348 ; CODE XREF: gzip_kernel_hearder+230j

ROM:00003348 CMP R7, #9

ROM:0000334C BGT loc_3414

ROM:00003350

ROM:00003350 loc_3350 ; CODE XREF: gzip_kernel_hearder+134j

ROM:00003350 ; gzip_kernel_hearder+140j ...

ROM:00003350 LDR R0, =(aNotAGzipFile - 0x3360)

ROM:00003354 MOV R6, #0xFFFFFFFF

ROM:00003358 ADD R0, PC, R0 ; "Not a gzip file"

ROM:0000335C BLX R10

ROM:00003360

ROM:00003360 loc_3360 ; CODE XREF: gzip_kernel_hearder+21Cj

ROM:00003360 ; gzip_kernel_hearder+2B4j

ROM:00003360 LDR R3, =0xC

ROM:00003364 LDR R3, [R4,R3]

ROM:00003368 LDR R2, [R3]

ROM:0000336C SUB R2, R2, #1

ROM:00003370 STR R2, [R3]

ROM:00003374 CMP R2, #0

ROM:00003378 BEQ loc_33B4

ROM:0000337C

ROM:0000337C loc_337C ; CODE XREF: gzip_kernel_hearder+28Cj

ROM:0000337C SUB R2, R2, #1

ROM:00003380 STR R2, [R3]

ROM:00003384 CMP R2, #0

ROM:00003388 BNE loc_33A4

ROM:0000338C LDR R3, =0x20

ROM:00003390 LDR R2, [R4,R3]

ROM:00003394 LDR R3, =4

ROM:00003398 LDR R2, [R2]

ROM:0000339C LDR R3, [R4,R3]

ROM:000033A0 STR R2, [R3]

ROM:000033A4

ROM:000033A4 loc_33A4 ; CODE XREF: gzip_kernel_hearder+A0j

ROM:000033A4 ; gzip_kernel_hearder+26Cj

ROM:000033A4 CMP R5, #0

ROM:000033A8 BEQ loc_33DC

ROM:000033AC

ROM:000033AC loc_33AC ; CODE XREF: gzip_kernel_hearder+F0j

ROM:000033AC ; gzip_kernel_hearder+10Cj ...

ROM:000033AC MOV R0, R6

ROM:000033B0 LDMFD SP, {R3-R11,SP,PC}

ROM:000033B4 ; ---------------------------------------------------------------------------

ROM:000033B4

ROM:000033B4 loc_33B4 ; CODE XREF: gzip_kernel_hearder+90j

ROM:000033B4 LDR R2, =0x20

ROM:000033B8 MOV R0, #0xFFFFFFFF

ROM:000033BC CMP R5, #0

ROM:000033C0 LDR R1, [R4,R2]

ROM:000033C4 LDR R2, =4

ROM:000033C8 LDR R2, [R4,R2]

ROM:000033CC STR R0, [R3]

ROM:000033D0 LDR R3, [R1]

ROM:000033D4 STR R3, [R2]

ROM:000033D8 BNE loc_33AC

ROM:000033DC

ROM:000033DC loc_33DC ; CODE XREF: gzip_kernel_hearder+C0j

ROM:000033DC LDR R3, =0xC

ROM:000033E0 LDR R2, [R4,R3]

ROM:000033E4 LDR R3, [R2]

ROM:000033E8 SUB R3, R3, #1

ROM:000033EC STR R3, [R2]

ROM:000033F0 CMP R3, #0

ROM:000033F4 BNE loc_33AC

ROM:000033F8 LDR R3, =0x20

ROM:000033FC LDR R2, [R4,R3]

ROM:00003400 LDR R3, =4

ROM:00003404 LDR R2, [R2]

ROM:00003408 LDR R3, [R4,R3]

ROM:0000340C STR R2, [R3]

ROM:00003410 B loc_33AC

ROM:00003414 ; ---------------------------------------------------------------------------

ROM:00003414

ROM:00003414 loc_3414 ; CODE XREF: gzip_kernel_hearder+64j

ROM:00003414 LDRB R3, [R9]

ROM:00003418 CMP R3, #0x1F ; bite 1f if another then error not a gzip file

ROM:0000341C BNE loc_3350

ROM:00003420 LDRB R3, [R9,#1]

ROM:00003424 CMP R3, #0x8B ; 'ï' ; if 1f and 8b is good signal but if not have this then not a gzip file

ROM:00003428 BNE loc_3350

ROM:0000342C LDRB R3, [R9,#2] ; another more byte for header 8 if not then error not a gzip file

ROM:00003430 CMP R3, #8

ROM:00003434 BNE loc_3350

ROM:00003438 ADD R3, R9, #0xA

ROM:0000343C SUB R7, R7, #0xA

ROM:00003440 STMIA R8, {R3,R7}

ROM:00003444 LDRB R3, [R9,#3]

ROM:00003448 TST R3, #8

ROM:0000344C BEQ loc_3474

ROM:00003450

ROM:00003450 loc_3450 ; CODE XREF: gzip_kernel_hearder+188j

ROM:00003450 CMP R7, #0

ROM:00003454 SUB R7, R7, #1

ROM:00003458 BEQ loc_358C

ROM:0000345C LDR R3, [R8]

ROM:00003460 STR R7, [R8,#4]

ROM:00003464 LDRB R2, [R3],#1

ROM:00003468 CMP R2, #0

ROM:0000346C STR R3, [R8]

ROM:00003470 BNE loc_3450

ROM:00003474

ROM:00003474 loc_3474 ; CODE XREF: gzip_kernel_hearder+164j

ROM:00003474 MOV R3, #0x7FFFFFFF

ROM:00003478 STR R6, [R8,#0xC]

ROM:0000347C STR R3, [R8,#0x10]

ROM:00003480 MOV R0, R8

ROM:00003484 MOV R1, #0xFFFFFFF1

ROM:00003488 BL sub_1820

ROM:0000348C LDR R2, [R8,#0x20]

ROM:00003490 MOV R3, #0

ROM:00003494 STR R3, [R2,#0x24]

ROM:00003498 LDR R2, [R8,#0x20]

ROM:0000349C STR R3, [R2,#0x30]

ROM:000034A0 SUBS R6, R0, #0

ROM:000034A4 BNE loc_34FC

ROM:000034A8

ROM:000034A8 loc_34A8 ; CODE XREF: gzip_kernel_hearder+200j

ROM:000034A8 LDR R3, [R8,#4]

ROM:000034AC MOV R1, #0x4000

ROM:000034B0 MOV R0, R9

ROM:000034B4 CMP R3, #0

ROM:000034B8 BNE loc_34D0

ROM:000034BC BL sub_A24

ROM:000034C0 CMP R0, #0

ROM:000034C4 BLT loc_35A0

ROM:000034C8 STR R9, [R8]

ROM:000034CC STR R0, [R8,#4]

ROM:000034D0

ROM:000034D0 loc_34D0 ; CODE XREF: gzip_kernel_hearder+1D0j

ROM:000034D0 MOV R0, R8

ROM:000034D4 MOV R1, #0

ROM:000034D8 BL sub_1894

ROM:000034DC CMP R0, #1

ROM:000034E0 BEQ loc_34FC

ROM:000034E4 CMP R0, #0

ROM:000034E8 BEQ loc_34A8

ROM:000034EC LDR R0, =(aUncompressionE - 0x34FC)

ROM:000034F0 MOV R6, #0xFFFFFFFF

ROM:000034F4 ADD R0, PC, R0 ; "uncompression error"

ROM:000034F8 BLX R10

ROM:000034FC

ROM:000034FC loc_34FC ; CODE XREF: gzip_kernel_hearder+1BCj

ROM:000034FC ; gzip_kernel_hearder+1F8j ...

ROM:000034FC MOV R0, R8

ROM:00003500 BL sub_304C

ROM:00003504 B loc_3360

ROM:00003508 ; ---------------------------------------------------------------------------

ROM:00003508

ROM:00003508 loc_3508 ; CODE XREF: gzip_kernel_hearder+5Cj

ROM:00003508 MOV R0, R9

ROM:0000350C MOV R1, #0x4000

ROM:00003510 BL sub_A24

ROM:00003514 MOV R7, R0

ROM:00003518 B loc_3348

ROM:0000351C ; ---------------------------------------------------------------------------

ROM:0000351C

ROM:0000351C loc_351C ; CODE XREF: gzip_kernel_hearder+30j

ROM:0000351C MOV R0, #0x4000

ROM:00003520 BL sub_988

ROM:00003524 SUBS R9, R0, #0

ROM:00003528 BNE loc_35B4

ROM:0000352C LDR R0, =(aOutOfMemoryWhi - 0x353C)

ROM:00003530 MOV R6, #0xFFFFFFFF

ROM:00003534 ADD R0, PC, R0 ; "Out of memory while allocating input bu"...

ROM:00003538 BLX R10

ROM:0000353C MOV R0, R6

ROM:00003540 LDMFD SP, {R3-R11,SP,PC}

ROM:00003544 ; ---------------------------------------------------------------------------

ROM:00003544

ROM:00003544 loc_3544 ; CODE XREF: gzip_kernel_hearder+40j

ROM:00003544 LDR R0, =(aOutOfMemoryW_0 - 0x3554)

ROM:00003548 MOV R6, #0xFFFFFFFF

ROM:0000354C ADD R0, PC, R0 ; "Out of memory while allocating z_stream"

ROM:00003550 BLX R10

ROM:00003554 B loc_33A4

ROM:00003558 ; ---------------------------------------------------------------------------

ROM:00003558

ROM:00003558 loc_3558 ; CODE XREF: gzip_kernel_hearder+54j

ROM:00003558 LDR R0, =(aOutOfMemoryW_1 - 0x3568)

ROM:0000355C MOV R6, #0xFFFFFFFF

ROM:00003560 ADD R0, PC, R0 ; "Out of memory while allocating workspac"...

ROM:00003564 BLX R10

ROM:00003568 LDR R3, =0xC

ROM:0000356C LDR R3, [R4,R3]

ROM:00003570 LDR R2, [R3]

ROM:00003574 B loc_337C

ROM:00003578 ; ---------------------------------------------------------------------------

ROM:00003578

ROM:00003578 loc_3578 ; CODE XREF: gzip_kernel_hearder+24j

ROM:00003578 LDR R0, =(aOutOfMemoryW_2 - 0x3588)

ROM:0000357C MOV R6, #0xFFFFFFFF

ROM:00003580 ADD R0, PC, R0 ; "Out of memory while allocating output b"...

ROM:00003584 BLX R3

ROM:00003588 B loc_33AC

ROM:0000358C ; ---------------------------------------------------------------------------

ROM:0000358C

ROM:0000358C loc_358C ; CODE XREF: gzip_kernel_hearder+170j

ROM:0000358C LDR R0, =(aHeaderError - 0x359C)

ROM:00003590 MOV R6, #0xFFFFFFFF

ROM:00003594 ADD R0, PC, R0 ; "header error"

ROM:00003598 BLX R10

ROM:0000359C B loc_3360

ROM:000035A0 ; ---------------------------------------------------------------------------

ROM:000035A0

ROM:000035A0 loc_35A0 ; CODE XREF: gzip_kernel_hearder+1DCj

ROM:000035A0 LDR R0, =(aReadError - 0x35B0)

ROM:000035A4 MOV R6, #0xFFFFFFFF

ROM:000035A8 ADD R0, PC, R0 ; "read error"

ROM:000035AC BLX R10

ROM:000035B0 B loc_34FC

ROM:000035B4 ; ---------------------------------------------------------------------------

ROM:000035B4

ROM:000035B4 loc_35B4 ; CODE XREF: gzip_kernel_hearder+240j

ROM:000035B4 MOV R7, R5

ROM:000035B8 B loc_331C

ok what can learn to this, mtk boot have kernel packed with something call gzip