Convert BOOT_MAGIC_SZ to #define

Convert this `extern const uint32_t` to a simple define.  Provide an
accessor function so that the simulator is able to access the value as
well.  This has a minor improvement on the generated code within MCUboot
itself.

Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c
index ee89444..414306b 100644
--- a/boot/bootutil/src/bootutil_misc.c
+++ b/boot/bootutil/src/bootutil_misc.c
@@ -52,8 +52,6 @@
 #define BOOT_MAGIC_ARR_SZ \
     (sizeof boot_img_magic / sizeof boot_img_magic[0])
 
-const uint32_t BOOT_MAGIC_SZ = sizeof boot_img_magic;
-
 struct boot_swap_table {
     uint8_t magic_primary_slot;
     uint8_t magic_secondary_slot;
diff --git a/boot/bootutil/src/bootutil_priv.h b/boot/bootutil/src/bootutil_priv.h
index eb839a6..968bee4 100644
--- a/boot/bootutil/src/bootutil_priv.h
+++ b/boot/bootutil/src/bootutil_priv.h
@@ -185,7 +185,7 @@
 #define BOOT_STATUS_SOURCE_SCRATCH      1
 #define BOOT_STATUS_SOURCE_PRIMARY_SLOT 2
 
-extern const uint32_t BOOT_MAGIC_SZ;
+#define BOOT_MAGIC_SZ (sizeof boot_img_magic)
 
 /**
  * Compatibility shim for flash sector type.
diff --git a/sim/mcuboot-sys/csupport/run.c b/sim/mcuboot-sys/csupport/run.c
index dd63d55..5697948 100644
--- a/sim/mcuboot-sys/csupport/run.c
+++ b/sim/mcuboot-sys/csupport/run.c
@@ -454,3 +454,8 @@
 {
     return BOOT_MAX_ALIGN;
 }
+
+uint32_t boot_magic_sz(void)
+{
+    return BOOT_MAGIC_SZ;
+}
diff --git a/sim/mcuboot-sys/src/c.rs b/sim/mcuboot-sys/src/c.rs
index 3d2f3ea..f3de302 100644
--- a/sim/mcuboot-sys/src/c.rs
+++ b/sim/mcuboot-sys/src/c.rs
@@ -41,7 +41,7 @@
 }
 
 pub fn boot_magic_sz() -> usize {
-    unsafe { raw::BOOT_MAGIC_SZ as usize }
+    unsafe { raw::boot_magic_sz() as usize }
 }
 
 pub fn boot_max_align() -> usize {
@@ -83,7 +83,7 @@
 
         pub fn boot_trailer_sz(min_write_sz: u8) -> u32;
 
-        pub static BOOT_MAGIC_SZ: u32;
+        pub fn boot_magic_sz() -> u32;
         pub fn boot_max_align() -> u32;
 
         pub fn rsa_oaep_encrypt_(pubkey: *const u8, pubkey_len: libc::c_uint,