]> git.proxmox.com Git - fwupd-efi.git/commitdiff
Rework objcopy-manualsymbols argument to generate-binary
authorCallum Farmer <gmbr3@opensuse.org>
Fri, 6 Jan 2023 15:29:34 +0000 (15:29 +0000)
committerMario Limonciello <superm1@gmail.com>
Wed, 25 Jan 2023 04:01:39 +0000 (22:01 -0600)
Use store_true action instead of an integer value

efi/generate_binary.py
efi/generate_sbat.py
efi/meson.build

index b1336a009e2371de33ec9555317fc2d704993cd0..042b7d3d9fec58cc55c18685bb73fab25f9ffec6 100755 (executable)
@@ -77,7 +77,7 @@ if __name__ == "__main__":
     parser.add_argument("--os", help="OS type")
     parser.add_argument(
         "--objcopy-manualsymbols",
-        type=int,
+        action="store_true",
         help="whether adding symbols direct to binary",
     )
     parser.add_argument("infile", help="Input file")
index f445e13fcae9c4d06512a64613e2c9b20a484c0b..6c904e505f2e020578aa47d3877411ff47c28a23 100755 (executable)
@@ -18,7 +18,11 @@ def _generate_sbat(args):
     FWUPD_SUMMARY = "Firmware update daemon"
     FWUPD_URL = "https://github.com/fwupd/fwupd-efi"
 
-    cmd = args.cc.split() + ["-x", "c", "-c", "-o", args.outfile, "/dev/null"] + args.cflags.split(" ")
+    cmd = (
+        args.cc.split()
+        + ["-x", "c", "-c", "-o", args.outfile, "/dev/null"]
+        + args.cflags.split(" ")
+    )
     subprocess.run(cmd, check=True)
 
     # not specified
index b4341796933b1807df878220d9b86202c467c432..0311f8a9d47e9ef158d3b6f20b107b3e7c492369 100644 (file)
@@ -34,6 +34,16 @@ if host_cpu == 'x86_64' and host_machine.system() == 'freebsd'
   lds_os = '_fbsd'
 endif
 
+# older objcopy for Aarch64 and ARM32 are not EFI capable.
+# Use 'binary' instead, and add required symbols manually.
+if host_cpu == 'arm' or (objcopy_version.version_compare ('< 2.38') and host_cpu == 'aarch64')
+  objcopy_manualsymbols = true
+  generate_binary_extra = ['--objcopy-manual-symbols']
+else
+  objcopy_manualsymbols = false
+  generate_binary_extra = []
+endif
+
 arch_lds = 'efi.lds'
 arch_crt = 'crt0.o'
 if efi_ldsdir == ''
@@ -76,7 +86,7 @@ if get_option('efi_sbat_distro_id') != ''
 endif
 
 # is the system crt0 for arm and aarch64 new enough to know about SBAT?
-if host_cpu == 'arm' or (objcopy_version.version_compare ('< 2.38') and host_cpu == 'aarch64')
+if objcopy_manualsymbols
   if get_option('efi_sbat_distro_id') != ''
     arch_crt_source = 'crt0-efi-@0@.S'.format(gnu_efi_path_arch)
     cmd = run_command('grep', '-q', 'sbat', join_paths(efi_crtdir, arch_crt))
@@ -145,11 +155,10 @@ efi_ldflags = ['-T',
                '-L', efi_crtdir,
                '-L', efi_libdir,
                join_paths(efi_crtdir, arch_crt)]
-objcopy_manualsymbols = '0'
-if host_cpu == 'arm' or (objcopy_version.version_compare ('< 2.38') and host_cpu == 'aarch64')
+
+if objcopy_manualsymbols
   # older objcopy for Aarch64 and ARM32 are not EFI capable.
   # Use 'binary' instead, and add required symbols manually.
-  objcopy_manualsymbols = '1'
   efi_ldflags += ['--defsym=EFI_SUBSYSTEM=0xa']
   efi_format = ['-O', 'binary']
 else
@@ -224,9 +233,9 @@ app = custom_target(efi_name,
                       '--arch', gnu_efi_arch,
                       '--os', host_machine.system(),
                       '--objcopy', objcopy,
-                      '--objcopy-manualsymbols', objcopy_manualsymbols,
                       '--genpeimg', genpeimg.found() ? genpeimg : ''
-                    ],
+                    ]
+                    + generate_binary_extra,
                     install : true,
                     install_dir : efi_app_location)