Coverity flagged the switch checks for R_AARCH64_* as being logically
dead code, since it could never happen on x86 due to the masking of the
values earlier in the code.

A check for building on __ARM_ARCH (which gcc and clang define) and for
MKIMAGE_ELF64 (which GRUB defines) has been added to avoid this dead
code being built in.

Fixes: CID 158599

Signed-off-by: Darren Kenny <darren.ke...@oracle.com>
---
 util/grub-mkimagexx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index 9762bc80e40d..9ff31083f746 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -1631,6 +1631,7 @@ translate_relocation_pe (struct translate_context *ctx,
        }
       break;
     case EM_AARCH64:
+#if defined(MKIMAGE_ELF64) && defined(__ARM_ARCH)
       switch (ELF_R_TYPE (info))
        {
        case R_AARCH64_ABS64:
@@ -1666,6 +1667,7 @@ translate_relocation_pe (struct translate_context *ctx,
                           (unsigned int) ELF_R_TYPE (info));
          break;
        }
+#endif /* defined(MKIMAGE_ELF64) && define(__ARM_ARCH) */
       break;
       break;
 #if defined(MKIMAGE_ELF32)
-- 
2.27.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to