From d9967378f9b0ba735550f917e4140dd99adc3155 Mon Sep 17 00:00:00 2001
From: herengui <herengui@kylinsec.com.cn>
Date: Sat, 13 May 2023 16:55:11 +0800
Subject: [PATCH] add loongarch64 support

Signed-off-by: herengui <herengui@kylinsec.com.cn>
---
 meson.build                                 | 3 +++
 plugins/uefi-capsule/efi/generate_binary.py | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 0c768a2..d6c88cc 100644
--- a/meson.build
+++ b/meson.build
@@ -374,6 +374,9 @@ if build_standalone and get_option('plugin_uefi_capsule')
   elif host_cpu == 'aarch64'
           EFI_MACHINE_TYPE_NAME = 'aa64'
           gnu_efi_arch = 'aarch64'
+  elif host_cpu == 'loongarch64'
+          EFI_MACHINE_TYPE_NAME = 'la464'
+          gnu_efi_arch = 'loongarch64'
   else
           EFI_MACHINE_TYPE_NAME = ''
           gnu_efi_arch = ''
diff --git a/plugins/uefi-capsule/efi/generate_binary.py b/plugins/uefi-capsule/efi/generate_binary.py
index 3d1c44c..d263d38 100755
--- a/plugins/uefi-capsule/efi/generate_binary.py
+++ b/plugins/uefi-capsule/efi/generate_binary.py
@@ -34,9 +34,9 @@ def _run_objcopy(args):
         args.outfile,
     ]
 
-    # aarch64 and arm32 don't have an EFI capable objcopy
+    # aarch64, arm32 and loongarch64 don't have an EFI capable objcopy
     # Use 'binary' instead, and add required symbols manually
-    if args.arch in ["aarch64", "arm"]:
+    if args.arch in ["aarch64", "arm", "loongarch64"]:
         argv.extend(["-O", "binary"])
     else:
         argv.extend(["--target", "efi-app-{}".format(args.arch)])
-- 
2.39.2

