Merge "QcomModulePkg: Update the System path info in Command line for LE "
diff --git a/AndroidBoot.mk b/AndroidBoot.mk
index 75a539b..e779e99 100644
--- a/AndroidBoot.mk
+++ b/AndroidBoot.mk
@@ -1,16 +1,15 @@
 #Android makefile to build bootloader as a part of Android Build
-ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/)
-  CLANG_BIN := $(SDCLANG_PATH)/
-else
-  CLANG_BIN := $(ANDROID_BUILD_TOP)/$(SDCLANG_PATH)/
-endif
+CLANG_BIN := $(ANDROID_BUILD_TOP)/$(LLVM_PREBUILTS_PATH)/
+ABL_USE_SDLLVM := false
 
-ifneq ($(wildcard $(SDCLANG_PATH_2)),)
-  ifeq ($(shell echo $(SDCLANG_PATH_2) | head -c 1),/)
-    CLANG_BIN := $(SDCLANG_PATH_2)/
+ifneq ($(wildcard $(SDCLANG_PATH)),)
+  ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/)
+    CLANG_BIN := $(SDCLANG_PATH)/
   else
-    CLANG_BIN := $(ANDROID_BUILD_TOP)/$(SDCLANG_PATH_2)/
+    CLANG_BIN := $(ANDROID_BUILD_TOP)/$(SDCLANG_PATH)/
   endif
+
+  ABL_USE_SDLLVM := true
 endif
 
 ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true)
@@ -77,6 +76,7 @@
 		$(USER_BUILD_VARIANT) \
 		CLANG_BIN=$(CLANG_BIN) \
 		CLANG_PREFIX=$(CLANG35_PREFIX)\
+		ABL_USE_SDLLVM=$(ABL_USE_SDLLVM) \
 		CLANG_GCC_TOOLCHAIN=$(CLANG35_GCC_TOOLCHAIN)\
 		TARGET_ARCHITECTURE=$(TARGET_ARCHITECTURE)
 
diff --git a/QcomModulePkg/Application/LinuxLoader/LinuxLoader.inf b/QcomModulePkg/Application/LinuxLoader/LinuxLoader.inf
index f3d261c..3de6230 100644
--- a/QcomModulePkg/Application/LinuxLoader/LinuxLoader.inf
+++ b/QcomModulePkg/Application/LinuxLoader/LinuxLoader.inf
@@ -1,5 +1,5 @@
 #/* @file
-#  Copyright (c) 2017, The Linux Foundation. All rights reserved.
+#  Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 #  Portions Copyright (c) 2011-2013, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
@@ -24,7 +24,7 @@
 	LinuxLoader.c
 
 [BuildOptions.AARCH64]
-	GCC:*_*_*_CC_FLAGS = --compile-and-analyze $(BUILD_REPORT_DIR)
+	GCC:*_*_*_CC_FLAGS = $(SDLLVM_COMPILE_ANALYZE) $(SDLLVM_ANALYZE_REPORT)
 	GCC:*_*_*_CC_FLAGS = $(UBSAN_UEFI_GCC_FLAG_UNDEFINED)
 	GCC:*_*_*_CC_FLAGS = $(UBSAN_UEFI_GCC_FLAG_ALIGNMENT)
 
diff --git a/QcomModulePkg/Include/Library/BootImage.h b/QcomModulePkg/Include/Library/BootImage.h
index f17827c..aacb210 100644
--- a/QcomModulePkg/Include/Library/BootImage.h
+++ b/QcomModulePkg/Include/Library/BootImage.h
@@ -38,9 +38,14 @@
 #define BOOT_IMG_EMMC_PAGE_SIZE 2048
 #define BOOT_IMG_MAX_PAGE_SIZE 4096
 #define KERNEL64_HDR_MAGIC 0x644D5241 /* ARM64 */
+#define BOOT_EXTRA_ARGS_SIZE 1024
 
-/*Struct def for boot image header*/
-typedef struct boot_img_hdr {
+#define BOOT_HEADER_VERSION_ZERO 0
+/* Struct def for boot image header
+ * Bootloader expects the structure of boot_img_hdr with header version
+ *  BOOT_HEADER_VERSION_ZERO to be as follows:
+ */
+struct boot_img_hdr_v0 {
   CHAR8 magic[BOOT_MAGIC_SIZE];
 
   UINT32 kernel_size; /* size in bytes */
@@ -54,7 +59,7 @@
 
   UINT32 tags_addr;  /* physical addr for kernel tags */
   UINT32 page_size;  /* flash page size we assume */
-  UINT32 dt_size;    /* device_tree in bytes */
+  UINT32 header_version; /* version for the boot image header */
   UINT32 os_version; /* version << 11 | patch_level */
 
   UINT8 name[BOOT_NAME_SIZE]; /* asciiz product name */
@@ -62,7 +67,24 @@
   UINT8 cmdline[BOOT_ARGS_SIZE];
 
   UINT32 id[8]; /* timestamp / checksum / sha1 / etc */
-} boot_img_hdr;
+
+  /* Supplemental command line data; kept here to maintain
+   * binary compatibility with older versions of mkbootimg
+   */
+  UINT8 extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
+} __attribute__((packed));
+
+/*
+ * It is expected that callers would explicitly specify which version of the
+ * boot image header they need to use.
+ */
+typedef struct boot_img_hdr_v0 boot_img_hdr;
+
+/**
+ * Offset of recovery DTBO length in a boot image header of version V1 or
+ * above.
+ */
+#define BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET sizeof (boot_img_hdr)
 
 /*
  * ** +-----------------+
@@ -74,13 +96,9 @@
  * ** +-----------------+
  * ** | second stage    | o pages
  * ** +-----------------+
- * ** | device tree     | p pages
- * ** +-----------------+
- * **
  * ** n = (kernel_size + page_size - 1) / page_size
  * ** m = (ramdisk_size + page_size - 1) / page_size
  * ** o = (second_size + page_size - 1) / page_size
- * ** p = (dt_size + page_size - 1) / page_size
  * ** 0. all entities are page_size aligned in flash
  * ** 1. kernel and ramdisk are required (size != 0)
  * ** 2. second is optional (second_size == 0 -> no second)
@@ -93,6 +111,47 @@
  * **    else: jump to kernel_addr
  * */
 
+#define BOOT_HEADER_VERSION_ONE 1
+
+struct boot_img_hdr_v1 {
+  UINT32 recovery_dtbo_size;   /* size in bytes for recovery DTBO image */
+  UINT64 recovery_dtbo_offset; /* physical load addr */
+  UINT32 header_size;
+} __attribute__((packed));
+
+/* When the boot image header has a version of BOOT_HEADER_VERSION_ONE,
+ * the structure of the boot image is as follows:
+ *
+ * +-----------------+
+ * | boot header     | 1 page
+ * +-----------------+
+ * | kernel          | n pages
+ * +-----------------+
+ * | ramdisk         | m pages
+ * +-----------------+
+ * | second stage    | o pages
+ * +-----------------+
+ * | recovery dtbo   | p pages
+ * +-----------------+
+ * n = (kernel_size + page_size - 1) / page_size
+ * m = (ramdisk_size + page_size - 1) / page_size
+ * o = (second_size + page_size - 1) / page_size
+ * p = (recovery_dtbo_size + page_size - 1) / page_size
+ *
+ * 0. all entities are page_size aligned in flash
+ * 1. kernel and ramdisk are required (size != 0)
+ * 2. recovery_dtbo is required for recovery.img
+ *    in non-A/B devices(recovery_dtbo_size != 0)
+ * 3. second is optional (second_size == 0 -> no second)
+ * 4. load each element (kernel, ramdisk, second, recovery_dtbo) at
+ *    the specified physical address (kernel_addr, etc)
+ * 5. prepare tags at tag_addr.  kernel_args[] is
+ *    appended to the kernel commandline in the tags.
+ * 6. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
+ * 7. if second_size != 0: jump to second_addr
+ *    else: jump to kernel_addr
+ */
+
 struct kernel64_hdr {
   UINT32 Code0;       /* Executable code */
   UINT32 Code1;       /* Executable code */
diff --git a/QcomModulePkg/Include/Library/BootLinux.h b/QcomModulePkg/Include/Library/BootLinux.h
index 55904d9..e742393 100644
--- a/QcomModulePkg/Include/Library/BootLinux.h
+++ b/QcomModulePkg/Include/Library/BootLinux.h
@@ -115,6 +115,7 @@
   UINT32 VBCmdLineLen;
   UINT32 VBCmdLineFilledLen;
   VOID *VBData;
+  UINT32 HeaderVersion;
 } BootInfo;
 
 typedef struct BootLinuxParamlist {
@@ -133,6 +134,7 @@
   BOOLEAN BootingWith32BitKernel;
   UINT32 KernelSizeActual;
   VOID *ImageBuffer;
+  UINT64 ImageSize;
   VOID *DtboImgBuffer;
 } BootParamlist;
 
@@ -155,7 +157,8 @@
           UINTN *ImageSize,
           CHAR8 *ImageName);
 BOOLEAN
-LoadAndValidateDtboImg (BootInfo *Info, VOID **DtboImgBuffer);
+LoadAndValidateDtboImg (BootInfo *Info,
+                        BootParamlist *BootParamlistPtr);
 VOID SetBootDevImage (VOID);
 VOID ResetBootDevImage (VOID);
 BOOLEAN IsBootDevImage (VOID);
diff --git a/QcomModulePkg/Include/Library/LEOEMCertificate.h b/QcomModulePkg/Include/Library/LEOEMCertificate.h
index 23d77b9..511dfca 100644
--- a/QcomModulePkg/Include/Library/LEOEMCertificate.h
+++ b/QcomModulePkg/Include/Library/LEOEMCertificate.h
@@ -54,77 +54,79 @@
 */
 
 static CONST UINT8 LeOemCertificate[] = {
-    0x30, 0x82, 0x03, 0x4F, 0x30, 0x82, 0x02, 0x37, 0xA0, 0x03, 0x02, 0x01,
-    0x02, 0x02, 0x09, 0x00, 0xED, 0x2C, 0x2E, 0x88, 0xA4, 0xC8, 0xF4, 0x60,
+    0x30, 0x82, 0x03, 0x5D, 0x30, 0x82, 0x02, 0x45, 0xA0, 0x03, 0x02, 0x01,
+    0x02, 0x02, 0x09, 0x00, 0xFA, 0xCD, 0x18, 0x11, 0xED, 0xD3, 0x4D, 0xC8,
     0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01,
-    0x0B, 0x05, 0x00, 0x30, 0x3E, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55,
-    0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03,
-    0x55, 0x04, 0x08, 0x0C, 0x02, 0x43, 0x41, 0x31, 0x0C, 0x30, 0x0A, 0x06,
-    0x03, 0x55, 0x04, 0x0A, 0x0C, 0x03, 0x51, 0x54, 0x49, 0x31, 0x14, 0x30,
-    0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0B, 0x4C, 0x45, 0x20, 0x54,
-    0x65, 0x73, 0x74, 0x20, 0x4B, 0x65, 0x79, 0x30, 0x1E, 0x17, 0x0D, 0x31,
-    0x37, 0x30, 0x36, 0x31, 0x34, 0x32, 0x32, 0x32, 0x34, 0x34, 0x33, 0x5A,
-    0x17, 0x0D, 0x31, 0x38, 0x30, 0x36, 0x31, 0x34, 0x32, 0x32, 0x32, 0x34,
-    0x34, 0x33, 0x5A, 0x30, 0x3E, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55,
-    0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03,
-    0x55, 0x04, 0x08, 0x0C, 0x02, 0x43, 0x41, 0x31, 0x0C, 0x30, 0x0A, 0x06,
-    0x03, 0x55, 0x04, 0x0A, 0x0C, 0x03, 0x51, 0x54, 0x49, 0x31, 0x14, 0x30,
-    0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0B, 0x4C, 0x45, 0x20, 0x54,
-    0x65, 0x73, 0x74, 0x20, 0x4B, 0x65, 0x79, 0x30, 0x82, 0x01, 0x22, 0x30,
-    0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
-    0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02,
-    0x82, 0x01, 0x01, 0x00, 0xCD, 0x4E, 0xC2, 0x72, 0xAE, 0x2F, 0xF8, 0xE2,
-    0xF2, 0xEB, 0x96, 0xC8, 0xDE, 0xDB, 0xBC, 0x5F, 0x03, 0xF1, 0x8B, 0x36,
-    0xBB, 0x5E, 0xAC, 0x4B, 0x75, 0x44, 0xF2, 0x8C, 0xB2, 0x46, 0xF3, 0x73,
-    0xF2, 0xDC, 0xCE, 0x5D, 0x7E, 0xE6, 0x9C, 0x18, 0xF5, 0x04, 0x4D, 0xA3,
-    0x1E, 0x25, 0xDB, 0xD9, 0x81, 0x09, 0x1A, 0xE6, 0xA2, 0x8E, 0xF1, 0xFA,
-    0x72, 0x5C, 0xAA, 0xC4, 0x2C, 0xC3, 0x58, 0x70, 0xC1, 0xE1, 0x94, 0xCC,
-    0x5D, 0x32, 0x92, 0xD0, 0xBA, 0x18, 0x82, 0xF0, 0x2B, 0xA1, 0xA4, 0x94,
-    0x64, 0x03, 0x59, 0xD2, 0x3D, 0x39, 0x0B, 0xE7, 0x1A, 0x7D, 0xF2, 0xC1,
-    0x78, 0x6B, 0x5F, 0x51, 0x74, 0x4B, 0x63, 0x30, 0xCB, 0xF6, 0x04, 0xCB,
-    0xE8, 0x18, 0x3F, 0x5C, 0x31, 0xCC, 0x10, 0x5C, 0xAF, 0xFB, 0xC3, 0x50,
-    0x47, 0x9F, 0x4A, 0xCA, 0x64, 0xA9, 0xB3, 0x80, 0xA7, 0x35, 0x33, 0xC7,
-    0x1C, 0x0D, 0x0B, 0xAA, 0x48, 0x2F, 0x59, 0x66, 0xC8, 0x76, 0xB4, 0x9C,
-    0x01, 0xFB, 0xA2, 0xF3, 0x2B, 0xC4, 0x0F, 0xE8, 0x82, 0x3D, 0x31, 0xBE,
-    0x6C, 0xA2, 0x5B, 0xC3, 0x5F, 0xB0, 0x6F, 0x90, 0xB1, 0xD3, 0xB3, 0x54,
-    0xED, 0x7A, 0x4B, 0x42, 0x03, 0xB5, 0x85, 0x93, 0x9E, 0x6C, 0x64, 0x9D,
-    0xB2, 0x83, 0x4B, 0x0C, 0xCD, 0xD3, 0x27, 0x6F, 0x37, 0xA7, 0x99, 0x44,
-    0xFA, 0x63, 0x2B, 0x2E, 0xAE, 0x48, 0x0A, 0xEF, 0x6C, 0x26, 0x03, 0x2D,
-    0x35, 0xA3, 0xFC, 0x00, 0xCF, 0xE3, 0x45, 0xF1, 0x80, 0x4A, 0xAD, 0x52,
-    0xE0, 0xD9, 0x84, 0x5E, 0xD5, 0x1D, 0xEE, 0xDD, 0xCA, 0x99, 0x7A, 0x8F,
-    0xE5, 0x54, 0x5A, 0x2D, 0xF5, 0xC2, 0x90, 0xD2, 0xED, 0xB1, 0xBC, 0xD8,
-    0x56, 0x22, 0xFE, 0x25, 0x30, 0x77, 0xB2, 0x77, 0xDD, 0xDA, 0xF3, 0x83,
-    0x7C, 0xC2, 0xD9, 0x21, 0x9D, 0x52, 0x32, 0x1B, 0x02, 0x03, 0x01, 0x00,
-    0x01, 0xA3, 0x50, 0x30, 0x4E, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E,
-    0x04, 0x16, 0x04, 0x14, 0x16, 0x26, 0x6C, 0x02, 0xEC, 0x9E, 0x88, 0x19,
-    0xF4, 0x7A, 0x19, 0xA8, 0x90, 0x08, 0x72, 0xB4, 0x4B, 0x18, 0x21, 0x3D,
-    0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80,
-    0x14, 0x16, 0x26, 0x6C, 0x02, 0xEC, 0x9E, 0x88, 0x19, 0xF4, 0x7A, 0x19,
-    0xA8, 0x90, 0x08, 0x72, 0xB4, 0x4B, 0x18, 0x21, 0x3D, 0x30, 0x0C, 0x06,
-    0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30,
-    0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
-    0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x79, 0x03, 0x42, 0x8F, 0x25,
-    0x8C, 0xC7, 0x75, 0xF8, 0x91, 0x20, 0x76, 0x5C, 0x45, 0xD1, 0x88, 0x22,
-    0x6B, 0xDC, 0xFC, 0xAB, 0x65, 0x7D, 0x39, 0x46, 0xAD, 0xC4, 0x18, 0x1D,
-    0xFB, 0x6A, 0x67, 0x50, 0xC6, 0xE4, 0xBC, 0x73, 0xD2, 0xE6, 0xB6, 0x3A,
-    0xC9, 0xB8, 0x41, 0x24, 0x13, 0x3E, 0xF3, 0xBC, 0x0C, 0xC7, 0xE2, 0x2D,
-    0xB4, 0x3C, 0x33, 0xA6, 0x66, 0x0D, 0xD6, 0x3D, 0x8E, 0x3C, 0x2D, 0xFA,
-    0x78, 0xF1, 0x30, 0xB5, 0x11, 0xF9, 0x73, 0x52, 0x56, 0x03, 0x84, 0x75,
-    0x27, 0x16, 0xF3, 0x8E, 0x17, 0xFD, 0xAA, 0xC1, 0x89, 0x4D, 0x6F, 0xA7,
-    0x28, 0xE4, 0x56, 0xC1, 0x2B, 0x8F, 0xC7, 0x4D, 0xF2, 0xC8, 0x65, 0xA7,
-    0xD1, 0x77, 0x11, 0x16, 0x03, 0x62, 0xB4, 0x22, 0xA8, 0x0F, 0x1A, 0x4B,
-    0x1B, 0x22, 0x29, 0x9B, 0x56, 0xEF, 0xAC, 0x64, 0xDB, 0x2A, 0x70, 0x0A,
-    0x7B, 0x1D, 0x31, 0x4E, 0xC6, 0xAF, 0x32, 0x63, 0xEE, 0xD8, 0x20, 0x0F,
-    0x8B, 0x7E, 0xC4, 0x6F, 0x04, 0x71, 0x10, 0x01, 0x3D, 0x17, 0x50, 0xF9,
-    0x70, 0xB2, 0x2B, 0x01, 0x8F, 0xE2, 0xA5, 0x5C, 0xEB, 0xD8, 0x74, 0xBC,
-    0x22, 0x8C, 0xF4, 0xEF, 0x10, 0xD4, 0xD5, 0x49, 0xCD, 0xB3, 0x7C, 0x8F,
-    0xEF, 0x23, 0x88, 0xCE, 0xBC, 0xBA, 0xA8, 0x3B, 0x9C, 0x48, 0xE0, 0x50,
-    0x9A, 0x70, 0x7D, 0xAE, 0xAF, 0x8C, 0xDA, 0x53, 0xBD, 0x40, 0x49, 0x17,
-    0x3F, 0xD5, 0x19, 0x77, 0x9C, 0xD5, 0x52, 0xEF, 0xB7, 0xD6, 0x00, 0x0A,
-    0xED, 0x9D, 0x4C, 0x81, 0x25, 0x3B, 0x6A, 0x66, 0xDC, 0xA6, 0xBB, 0x80,
-    0x60, 0x1E, 0xA6, 0x7E, 0x55, 0xF2, 0xC9, 0x07, 0xAA, 0x04, 0x89, 0x99,
-    0x76, 0xCC, 0x37, 0xB8, 0xAD, 0x78, 0x03, 0x81, 0x8A, 0x7B, 0x7B, 0x44,
-    0x59, 0x20, 0x84, 0x78, 0xD8, 0x77, 0x6D, 0xF9, 0x80, 0x94, 0xCF
+    0x0B, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55,
+    0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
+    0x55, 0x04, 0x08, 0x0C, 0x0A, 0x53, 0x6F, 0x6D, 0x65, 0x2D, 0x53, 0x74,
+    0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x0A,
+    0x0C, 0x18, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x65, 0x74, 0x20, 0x57,
+    0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4C,
+    0x74, 0x64, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x37, 0x30, 0x38, 0x30, 0x35,
+    0x30, 0x36, 0x33, 0x39, 0x32, 0x32, 0x5A, 0x17, 0x0D, 0x31, 0x38, 0x30,
+    0x38, 0x30, 0x35, 0x30, 0x36, 0x33, 0x39, 0x32, 0x32, 0x5A, 0x30, 0x45,
+    0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41,
+    0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x0A,
+    0x53, 0x6F, 0x6D, 0x65, 0x2D, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21,
+    0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x18, 0x49, 0x6E, 0x74,
+    0x65, 0x72, 0x6E, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74,
+    0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4C, 0x74, 0x64, 0x30, 0x82, 0x01,
+    0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
+    0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01,
+    0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xA6, 0xC6, 0x48, 0xE4, 0xF6, 0x8B,
+    0x42, 0x2A, 0xFC, 0xB0, 0x4A, 0x7A, 0x0F, 0x1A, 0x5E, 0x40, 0x78, 0x8B,
+    0xBD, 0x30, 0xBD, 0xA1, 0xBF, 0xDC, 0xB4, 0x53, 0x48, 0x31, 0x42, 0x11,
+    0xCD, 0x83, 0x70, 0x48, 0x75, 0x58, 0x00, 0x82, 0x50, 0x43, 0x4B, 0xA9,
+    0xCF, 0xEE, 0x81, 0x8C, 0xA4, 0x57, 0xA2, 0x55, 0xB2, 0x84, 0x5C, 0xAA,
+    0xC9, 0x3F, 0xBA, 0xDE, 0x4C, 0x1B, 0x54, 0xDE, 0xF0, 0x06, 0x3E, 0x3F,
+    0x3B, 0x5F, 0x6D, 0x78, 0xA3, 0xEB, 0x8F, 0x6F, 0xAC, 0xFC, 0x2F, 0x1F,
+    0xFC, 0x20, 0x58, 0xDB, 0x5D, 0x86, 0x04, 0xE1, 0x45, 0xF2, 0x98, 0x9A,
+    0x41, 0x00, 0x46, 0x45, 0x6C, 0x05, 0x5C, 0xE7, 0x7C, 0xC0, 0x25, 0x6F,
+    0x22, 0xE2, 0xDE, 0x76, 0xA1, 0xAC, 0xC8, 0x82, 0xF7, 0x15, 0x5B, 0x0C,
+    0xFF, 0xC1, 0xB1, 0xA8, 0x17, 0xB4, 0xFC, 0x0B, 0x98, 0x89, 0xBA, 0x2C,
+    0xFC, 0xAD, 0xDB, 0x03, 0xD8, 0x48, 0xDD, 0x38, 0x1B, 0xC6, 0x6E, 0x1A,
+    0x6D, 0xD9, 0x8B, 0x19, 0x73, 0x79, 0x33, 0xFC, 0x7C, 0x5F, 0x9B, 0x9C,
+    0x91, 0x4F, 0xDC, 0x65, 0x1B, 0x1C, 0xBF, 0x66, 0xF3, 0xDA, 0x79, 0x7C,
+    0x7F, 0x19, 0xE9, 0xAF, 0x75, 0x34, 0xB2, 0xA0, 0x2F, 0xA7, 0xF4, 0x2B,
+    0x9C, 0x4D, 0xF5, 0xC8, 0x68, 0xC5, 0xCB, 0x89, 0x6E, 0xA0, 0x72, 0x8E,
+    0x14, 0x22, 0x4F, 0x1A, 0xD8, 0x32, 0x04, 0x93, 0x91, 0x54, 0xD2, 0x54,
+    0xDA, 0x5E, 0x62, 0xAB, 0xB6, 0x53, 0x56, 0xAA, 0x8E, 0x17, 0x6D, 0xE7,
+    0x20, 0x28, 0xBE, 0x50, 0x68, 0x04, 0x8D, 0x38, 0xF6, 0x6F, 0x3E, 0x32,
+    0x6F, 0x61, 0x47, 0xBA, 0xE7, 0x5E, 0xDD, 0x33, 0x5A, 0xD9, 0x97, 0x8E,
+    0xD3, 0x9D, 0x0A, 0x78, 0x4B, 0x31, 0xFE, 0x74, 0x41, 0xC8, 0x7D, 0x77,
+    0x1D, 0x8B, 0x63, 0x67, 0x7C, 0x2D, 0xE1, 0xD3, 0xF1, 0x21, 0x02, 0x03,
+    0x01, 0x00, 0x01, 0xA3, 0x50, 0x30, 0x4E, 0x30, 0x1D, 0x06, 0x03, 0x55,
+    0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0x8E, 0x52, 0xC7, 0xA0, 0x78, 0xAD,
+    0xCF, 0xE3, 0x9D, 0xF9, 0xD5, 0x26, 0xE0, 0xDB, 0x80, 0x1A, 0xB8, 0xE2,
+    0x2D, 0xD1, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30,
+    0x16, 0x80, 0x14, 0x8E, 0x52, 0xC7, 0xA0, 0x78, 0xAD, 0xCF, 0xE3, 0x9D,
+    0xF9, 0xD5, 0x26, 0xE0, 0xDB, 0x80, 0x1A, 0xB8, 0xE2, 0x2D, 0xD1, 0x30,
+    0x0C, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
+    0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
+    0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x65, 0x5A, 0x8E,
+    0x9F, 0xC3, 0x52, 0xC9, 0x52, 0xCE, 0x6B, 0xF0, 0xAA, 0x8D, 0x78, 0xA0,
+    0x85, 0xB3, 0x0E, 0xEB, 0x8B, 0x17, 0xC2, 0xB4, 0xFA, 0xF4, 0x20, 0x52,
+    0x98, 0xCC, 0x1D, 0x45, 0x6F, 0x83, 0x9F, 0xCF, 0xA1, 0x4D, 0x91, 0xBA,
+    0xE2, 0x29, 0xC2, 0xAA, 0x9A, 0x07, 0xE0, 0xC3, 0xCE, 0x39, 0xDB, 0x5F,
+    0x5F, 0x96, 0xF1, 0x77, 0x8F, 0x73, 0x6D, 0xDD, 0x83, 0x0C, 0x1D, 0x8C,
+    0xCC, 0xC0, 0xC9, 0x65, 0x64, 0x67, 0x8F, 0x90, 0x3D, 0x53, 0x24, 0xED,
+    0x49, 0x18, 0x8A, 0x06, 0xDC, 0x96, 0xC1, 0x40, 0x9C, 0x11, 0x41, 0x70,
+    0x91, 0x7D, 0x7C, 0xFD, 0x63, 0x81, 0x73, 0x9F, 0xD9, 0x50, 0xF2, 0xA5,
+    0x86, 0x6A, 0x31, 0xA5, 0x43, 0x66, 0x7D, 0xB2, 0x88, 0x4C, 0x96, 0x08,
+    0x8B, 0x36, 0xA8, 0x21, 0x47, 0x17, 0xD4, 0x1D, 0xDE, 0xD9, 0x58, 0x45,
+    0x36, 0x1B, 0x2A, 0x82, 0x46, 0x40, 0x6F, 0x16, 0x41, 0xFB, 0xF2, 0x17,
+    0x49, 0x2A, 0x13, 0x8E, 0xCC, 0xB8, 0x5B, 0xD3, 0xDA, 0xCA, 0xB3, 0x48,
+    0xFC, 0xC7, 0x5C, 0x3B, 0x2B, 0xAC, 0x56, 0x41, 0x5F, 0x2B, 0x61, 0x15,
+    0x08, 0x9D, 0xDA, 0x72, 0x13, 0x43, 0x51, 0x00, 0xCE, 0xA1, 0x4C, 0x98,
+    0xC6, 0xC3, 0xD4, 0xEE, 0xEF, 0x51, 0xAF, 0xFC, 0x03, 0x86, 0x77, 0xB7,
+    0xB9, 0x14, 0x8A, 0x79, 0xCB, 0xC8, 0xA9, 0x0D, 0x82, 0xE3, 0xED, 0x05,
+    0x99, 0x10, 0xFD, 0x80, 0x0D, 0x24, 0x72, 0x1F, 0x1C, 0xB0, 0xCA, 0x64,
+    0x1D, 0x10, 0x5D, 0x3E, 0x48, 0x5B, 0x54, 0x56, 0x4E, 0xEE, 0x5D, 0x02,
+    0xEC, 0xEE, 0x0B, 0x2E, 0x77, 0x74, 0xB2, 0x8C, 0xD5, 0x7C, 0xF3, 0xA4,
+    0x0E, 0x1A, 0x48, 0x04, 0x81, 0x32, 0xF1, 0x39, 0x9B, 0x57, 0xC9, 0xBB,
+    0xFF, 0x15, 0xB6, 0xE5, 0x20, 0x0D, 0x03, 0x60, 0xBD, 0x3F, 0x29, 0x03,
+    0xEF
 };
 
 #endif
diff --git a/QcomModulePkg/Library/BootLib/BootLib.inf b/QcomModulePkg/Library/BootLib/BootLib.inf
index 4910db2..8e6202e 100644
--- a/QcomModulePkg/Library/BootLib/BootLib.inf
+++ b/QcomModulePkg/Library/BootLib/BootLib.inf
@@ -37,7 +37,7 @@
 	LIBRARY_CLASS                  = BootLib
 
 [BuildOptions.AARCH64]
-	GCC:*_*_*_CC_FLAGS = -O2 --compile-and-analyze $(BUILD_REPORT_DIR)
+	GCC:*_*_*_CC_FLAGS = -O2 $(SDLLVM_COMPILE_ANALYZE) $(SDLLVM_ANALYZE_REPORT)
 	GCC:*_*_*_CC_FLAGS = $(UBSAN_UEFI_GCC_FLAG_UNDEFINED)
 	GCC:*_*_*_CC_FLAGS = $(UBSAN_UEFI_GCC_FLAG_ALIGNMENT)
 
diff --git a/QcomModulePkg/Library/BootLib/BootLinux.c b/QcomModulePkg/Library/BootLib/BootLinux.c
index 8e569c6..3ad2848 100644
--- a/QcomModulePkg/Library/BootLib/BootLinux.c
+++ b/QcomModulePkg/Library/BootLib/BootLinux.c
@@ -177,10 +177,8 @@
     return EFI_INVALID_PARAMETER;
   }
 
-  DtboImgInvalid = LoadAndValidateDtboImg (Info,
-                                           &(BootParamlistPtr->DtboImgBuffer));
-
-if (!DtboImgInvalid) {
+  DtboImgInvalid = LoadAndValidateDtboImg (Info, BootParamlistPtr);
+  if (!DtboImgInvalid) {
     // appended device tree
     Dtb = DeviceTreeAppended ((VOID *)(BootParamlistPtr->ImageBuffer +
                              BootParamlistPtr->PageSize +
@@ -466,7 +464,6 @@
 {
 
   EFI_STATUS Status;
-  UINTN ImageSize = 0;
   CHAR16 *PartitionName = NULL;
   BOOLEAN Recovery = FALSE;
   BOOLEAN AlarmBoot = FALSE;
@@ -503,12 +500,12 @@
 
   Status = GetImage (Info,
                      &BootParamlistPtr.ImageBuffer,
-                     &ImageSize,
+                     (UINTN *)&BootParamlistPtr.ImageSize,
                      (!Info->MultiSlotBoot &&
                       Recovery)? "recovery" : "boot");
   if (Status != EFI_SUCCESS ||
       BootParamlistPtr.ImageBuffer == NULL ||
-      ImageSize <= 0) {
+      BootParamlistPtr.ImageSize <= 0) {
     DEBUG ((EFI_D_ERROR, "BootLinux: Get%aImage failed!\n",
             (!Info->MultiSlotBoot &&
              Recovery)? "Recovery" : "Boot"));
@@ -611,6 +608,8 @@
     return Status;
   }
 
+  Info->HeaderVersion = ((boot_img_hdr *)
+                         (BootParamlistPtr.ImageBuffer))->header_version;
   Status = DTBImgCheckAndAppendDT (Info, &BootParamlistPtr,
                                    DtbOffset);
   if (Status != EFI_SUCCESS) {
@@ -702,10 +701,10 @@
   UINT32 RamdiskSizeActual = 0;
 
   // Boot Image header information variables
+  UINT32 HeaderVersion = 0;
   UINT32 KernelSize = 0;
   UINT32 RamdiskSize = 0;
   UINT32 SecondSize = 0;
-  UINT32 DeviceTreeSize = 0;
   UINT32 tempImgSize = 0;
 
   if (CompareMem ((void *)((boot_img_hdr *)(ImageHdrBuffer))->magic, BOOT_MAGIC,
@@ -714,11 +713,11 @@
     return EFI_NO_MEDIA;
   }
 
+  HeaderVersion = ((boot_img_hdr *)(ImageHdrBuffer))->header_version;
   KernelSize = ((boot_img_hdr *)(ImageHdrBuffer))->kernel_size;
   RamdiskSize = ((boot_img_hdr *)(ImageHdrBuffer))->ramdisk_size;
   SecondSize = ((boot_img_hdr *)(ImageHdrBuffer))->second_size;
   *PageSize = ((boot_img_hdr *)(ImageHdrBuffer))->page_size;
-  DeviceTreeSize = ((boot_img_hdr *)(ImageHdrBuffer))->dt_size;
 
   if (!KernelSize || !*PageSize) {
     DEBUG ((EFI_D_ERROR, "Invalid image Sizes\n"));
@@ -746,13 +745,6 @@
     return EFI_BAD_BUFFER_SIZE;
   }
 
-  DtSizeActual = ROUND_TO_PAGE (DeviceTreeSize, *PageSize - 1);
-  if (DeviceTreeSize && !(DtSizeActual)) {
-    DEBUG (
-        (EFI_D_ERROR, "Integer Oveflow: Device Tree = %u\n", DeviceTreeSize));
-    return EFI_BAD_BUFFER_SIZE;
-  }
-
   *ImageSizeActual = ADD_OF (*PageSize, KernelSizeActual);
   if (!*ImageSizeActual) {
     DEBUG ((EFI_D_ERROR, "Integer Oveflow: Actual Kernel size = %u\n",
@@ -780,9 +772,8 @@
   DEBUG ((EFI_D_VERBOSE, "Boot Image Header Info...\n"));
   DEBUG ((EFI_D_VERBOSE, "Kernel Size 1            : 0x%x\n", KernelSize));
   DEBUG ((EFI_D_VERBOSE, "Kernel Size 2            : 0x%x\n", SecondSize));
-  DEBUG ((EFI_D_VERBOSE, "Device Tree Size         : 0x%x\n", DeviceTreeSize));
   DEBUG ((EFI_D_VERBOSE, "Ramdisk Size             : 0x%x\n", RamdiskSize));
-  DEBUG ((EFI_D_VERBOSE, "Device Tree Size         : 0x%x\n", DeviceTreeSize));
+  DEBUG ((EFI_D_VERBOSE, "Image Header version     : 0x%x\n", HeaderVersion));
 
   return Status;
 }
diff --git a/QcomModulePkg/Library/BootLib/PartitionTableUpdate.c b/QcomModulePkg/Library/BootLib/PartitionTableUpdate.c
old mode 100755
new mode 100644
index 937f4ad..79dafd1
--- a/QcomModulePkg/Library/BootLib/PartitionTableUpdate.c
+++ b/QcomModulePkg/Library/BootLib/PartitionTableUpdate.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -1533,27 +1533,107 @@
   return Status;
 }
 
+/* This functions should be called only if header revision > 0 */
+STATIC EFI_STATUS GetRecoveryDtboInfo (BootInfo *Info,
+                                       BootParamlist *BootParamlistPtr,
+                                       UINT64 *DtboImageSize)
+{
+  UINT32 HeaderVersion = 0;
+  UINT64 RecoveryDtboOffset = 0;
+  UINT32 RecoveryDtboSize = 0;
+  UINT32 ImageHeaderSize = 0;
+  struct boot_img_hdr_v1 *BootImgHdrV1Addr;
+
+  if (Info == NULL ||
+    BootParamlistPtr == NULL ||
+    DtboImageSize == NULL) {
+    DEBUG ((EFI_D_ERROR, "Invalid input parameters\n"));
+    return EFI_INVALID_PARAMETER;
+  }
+
+  HeaderVersion = Info->HeaderVersion;
+
+  /* Finds out the location of recovery dtbo size and offset */
+  BootImgHdrV1Addr = (struct boot_img_hdr_v1 *)
+                     ((UINT64) BootParamlistPtr->ImageBuffer +
+                     BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET);
+
+  if (HeaderVersion == BOOT_HEADER_VERSION_ONE) {
+    ImageHeaderSize = BootImgHdrV1Addr->header_size;
+
+    if ((ImageHeaderSize != (sizeof (struct boot_img_hdr_v1) +
+         BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET)) ||
+         ImageHeaderSize > BootParamlistPtr->PageSize) {
+      DEBUG ((EFI_D_ERROR,
+             "Invalid boot image header: %d\n", ImageHeaderSize));
+      return EFI_BAD_BUFFER_SIZE;
+    }
+  }
+
+  RecoveryDtboOffset = BootImgHdrV1Addr->recovery_dtbo_offset;
+  RecoveryDtboSize = ROUND_TO_PAGE (BootImgHdrV1Addr->recovery_dtbo_size,
+                     BootParamlistPtr->PageSize - 1);
+
+  if (CHECK_ADD64 (RecoveryDtboOffset, RecoveryDtboSize)) {
+    DEBUG ((EFI_D_ERROR, "Integer Oveflow: RecoveryDtboOffset=%u "
+           "RecoveryDtboSize=%u\n", RecoveryDtboOffset, RecoveryDtboSize));
+    return EFI_BAD_BUFFER_SIZE;
+  }
+
+  if (RecoveryDtboOffset + RecoveryDtboSize >
+      BootParamlistPtr->ImageSize) {
+    DEBUG ((EFI_D_ERROR, "Invalid recovery dtbo: RecoveryDtboOffset=%u,"
+            " RecoveryDtboSize=%u, ImageSize=%u\n",
+            RecoveryDtboOffset, RecoveryDtboSize,
+            BootParamlistPtr->ImageSize));
+    return EFI_BAD_BUFFER_SIZE;
+  }
+
+  BootParamlistPtr->DtboImgBuffer = (VOID *)
+                   ((UINT64) BootParamlistPtr->ImageBuffer +
+                    RecoveryDtboOffset);
+
+  *DtboImageSize = RecoveryDtboSize;
+
+  DEBUG ((EFI_D_VERBOSE, "Image Header Version: 0x%x\n", HeaderVersion));
+  DEBUG ((EFI_D_VERBOSE, "Recovery Dtbo Offset: 0x%x\n",
+          RecoveryDtboOffset));
+  DEBUG ((EFI_D_VERBOSE, "Recovery Dtbo Size: 0x%x\n", *DtboImageSize));
+
+  return EFI_SUCCESS;
+}
+
 /*Function to provide Dtbo Present info
  *return: TRUE or FALSE.
  */
 BOOLEAN
-LoadAndValidateDtboImg (BootInfo *Info, VOID **DtboImgBuffer)
+LoadAndValidateDtboImg (BootInfo *Info,
+                         BootParamlist *BootParamlistPtr)
 {
-  UINTN DtboImgSize = 0;
+  UINT64 DtboImgSize = 0;
   EFI_STATUS Status = EFI_SUCCESS;
   struct DtboTableHdr *DtboTableHdr = NULL;
 
-  Status = GetImage (Info, DtboImgBuffer, &DtboImgSize, "dtbo");
+  if (!Info->MultiSlotBoot &&
+      Info->BootIntoRecovery &&
+      Info->HeaderVersion > BOOT_HEADER_VERSION_ZERO) {
+    Status = GetRecoveryDtboInfo (Info, BootParamlistPtr, &DtboImgSize);
+  } else {
+    Status = GetImage (Info, &BootParamlistPtr->DtboImgBuffer,
+                       (UINTN *)&DtboImgSize, "dtbo");
+  }
+
   if (Status != EFI_SUCCESS) {
-    DEBUG ((EFI_D_ERROR, "BootLinux: GetImage dtbo failed!\n"));
+    DEBUG ((EFI_D_ERROR, "BootLinux: failed to get dtbo image\n"));
     return FALSE;
   }
-  if (!*DtboImgBuffer) {
+
+  if (!BootParamlistPtr->DtboImgBuffer) {
     DEBUG ((EFI_D_ERROR, "DtboImgBuffer is NULL"));
     return FALSE;
   }
 
-  DtboTableHdr = *DtboImgBuffer;
+  DtboTableHdr = BootParamlistPtr->DtboImgBuffer;
   if (fdt32_to_cpu (DtboTableHdr->Magic) != DTBO_TABLE_MAGIC) {
     DEBUG ((EFI_D_ERROR, "Dtbo hdr magic mismatch %x, with %x\n",
             DtboTableHdr->Magic, DTBO_TABLE_MAGIC));
diff --git a/QcomModulePkg/Library/FastbootLib/FastbootCmds.c b/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
index d955706..c8c3827 100644
--- a/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
+++ b/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
@@ -2233,7 +2233,7 @@
 STATIC VOID
 CmdBoot (CONST CHAR8 *Arg, VOID *Data, UINT32 Size)
 {
-  struct boot_img_hdr *hdr = (struct boot_img_hdr *)Data;
+  boot_img_hdr *hdr = Data;
   EFI_STATUS Status = EFI_SUCCESS;
   UINT32 ImageSizeActual = 0;
   UINT32 ImageHdrSize = 0;
@@ -2259,7 +2259,7 @@
     }
   }
 
-  if (Size < sizeof (struct boot_img_hdr)) {
+  if (Size < sizeof (boot_img_hdr)) {
     FastbootFail ("Invalid Boot image Header");
     return;
   }
diff --git a/QcomModulePkg/Library/FastbootLib/FastbootLib.inf b/QcomModulePkg/Library/FastbootLib/FastbootLib.inf
index 1dda004..b4968b4 100644
--- a/QcomModulePkg/Library/FastbootLib/FastbootLib.inf
+++ b/QcomModulePkg/Library/FastbootLib/FastbootLib.inf
@@ -42,7 +42,7 @@
 #
 
 [BuildOptions.AARCH64]
-  GCC:*_*_*_CC_FLAGS = --compile-and-analyze $(BUILD_REPORT_DIR)
+  GCC:*_*_*_CC_FLAGS = $(SDLLVM_COMPILE_ANALYZE) $(SDLLVM_ANALYZE_REPORT)
 
 [Sources]
   FastbootMain.c
diff --git a/QcomModulePkg/Library/StackCanary/StackCanary.inf b/QcomModulePkg/Library/StackCanary/StackCanary.inf
index 1013996..6de63d2 100644
--- a/QcomModulePkg/Library/StackCanary/StackCanary.inf
+++ b/QcomModulePkg/Library/StackCanary/StackCanary.inf
@@ -40,8 +40,8 @@
 	StackCanary.c
 
 [BuildOptions.AARCH64]
-	GCC:*_*_*_CC_FLAGS = -fno-stack-protector --compile-and-analyze $(BUILD_REPORT_DIR)
-
+	GCC:*_*_*_CC_FLAGS = -fno-stack-protector
+	GCC:*_*_*_CC_FLAGS = $(SDLLVM_COMPILE_ANALYZE) $(SDLLVM_ANALYZE_REPORT)
 [BuildOptions.ARM]
 	GCC:*_*_*_CC_FLAGS = -fno-stack-protector
 
diff --git a/QcomModulePkg/Library/avb/AvbLib.inf b/QcomModulePkg/Library/avb/AvbLib.inf
index ce0ba4f..bfb3a75 100644
--- a/QcomModulePkg/Library/avb/AvbLib.inf
+++ b/QcomModulePkg/Library/avb/AvbLib.inf
@@ -40,7 +40,7 @@
 	GCC:*_*_*_CC_FLAGS = -DAVB_COMPILATION -DAVB_ENABLE_DEBUG
 
 [BuildOptions.AARCH64]
-	GCC:*_*_*_CC_FLAGS = --compile-and-analyze $(BUILD_REPORT_DIR)
+	GCC:*_*_*_CC_FLAGS = $(SDLLVM_COMPILE_ANALYZE) $(SDLLVM_ANALYZE_REPORT)
 
 [Sources]
    libavb/avb_chain_partition_descriptor.c
diff --git a/QcomModulePkg/Library/avb/VerifiedBoot.c b/QcomModulePkg/Library/avb/VerifiedBoot.c
index ed92037..8a09748 100644
--- a/QcomModulePkg/Library/avb/VerifiedBoot.c
+++ b/QcomModulePkg/Library/avb/VerifiedBoot.c
@@ -204,8 +204,8 @@
   CHAR16 Pname[MAX_GPT_NAME_SIZE];
 
   if (Info->Images[0].ImageBuffer != NULL && Info->Images[0].ImageSize > 0) {
-    /* fastboot boot option image already loaded */
-    return Status;
+    /* fastboot boot option, boot image is already loaded, check for dtbo */
+    goto load_dtbo;
   }
 
   Status = LoadImage (Info->Pname, (VOID **)&(Info->Images[0].ImageBuffer),
@@ -219,6 +219,8 @@
   Info->Images[0].Name = AllocatePool (StrLen (Info->Pname) + 1);
   UnicodeStrToAsciiStr (Info->Pname, Info->Images[0].Name);
 
+
+load_dtbo:
   /*load dt overlay when avb is disabled*/
   Status = NoAVBLoadDtboImage (Info, (VOID **)&(Info->Images[1].ImageBuffer),
           (UINT32 *)&(Info->Images[1].ImageSize), Pname);
@@ -838,7 +840,7 @@
   Data.PublicKeyLength = UserData->PublicKeyLen;
   Data.PublicKey = UserData->PublicKey;
 
-  BootImgHdr = (struct boot_img_hdr *)ImageBuffer;
+  BootImgHdr = (boot_img_hdr *)ImageBuffer;
   Data.SystemSecurityLevel = (BootImgHdr->os_version & 0x7FF);
   Data.SystemVersion = (BootImgHdr->os_version & 0xFFFFF800) >> 11;
 
diff --git a/QcomModulePkg/Library/zlib/zlib.inf b/QcomModulePkg/Library/zlib/zlib.inf
index 4ca0117..b25af58 100644
--- a/QcomModulePkg/Library/zlib/zlib.inf
+++ b/QcomModulePkg/Library/zlib/zlib.inf
@@ -8,7 +8,8 @@
 
 
 [BuildOptions.AARCH64]
-  GCC:*_*_*_CC_FLAGS = -O2 -DZ_SOLO --compile-and-analyze $(BUILD_REPORT_DIR)
+  GCC:*_*_*_CC_FLAGS = -O2 -DZ_SOLO
+  GCC:*_*_*_CC_FLAGS = $(SDLLVM_COMPILE_ANALYZE) $(SDLLVM_ANALYZE_REPORT)
 
 [Sources]
   zutil.c
diff --git a/makefile b/makefile
index e46e6f6..f468805 100644
--- a/makefile
+++ b/makefile
@@ -55,6 +55,16 @@
 	ENABLE_LE_VARIANT := 0
 endif
 
+ifeq "$(ABL_USE_SDLLVM)" "true"
+	SDLLVM_COMPILE_ANALYZE := --compile-and-analyze
+	SDLLVM_ANALYZE_REPORT := $(BUILD_REPORT_DIR)
+else
+	SDLLVM_COMPILE_ANALYZE :=
+	SDLLVM_ANALYZE_REPORT :=
+endif
+export SDLLVM_COMPILE_ANALYZE := $(SDLLVM_COMPILE_ANALYZE)
+export SDLLVM_ANALYZE_REPORT := $(SDLLVM_ANALYZE_REPORT)
+
 .PHONY: all cleanall
 
 all: ABL_FV_ELF