[sw, lib] Move logger format fields to .rodata for CHERIoT

Collecting the format field records in a ".logs.fields" ELF segment
results in the data being written to an ELF segment that the CHERIoT
toolchain thinks is a compartment. This results in cap relocation records
(due to the embedded pointers) that point to a non-existent compartment
that the cheriot-rtos loader rejects. Work around this by collecting the
records in a ".rodata.fields" ELF segment that gets collected into the
ROM when building the boot_rom or the ".rodata" segment for 2nd-stage
firmware use.

Change-Id: I6089ed9d45f8d1080e52234de0d1e94b50f521f5
diff --git a/sw/device/lib/runtime/log.h b/sw/device/lib/runtime/log.h
index e5b98df..c9cd78b 100644
--- a/sw/device/lib/runtime/log.h
+++ b/sw/device/lib/runtime/log.h
@@ -108,7 +108,15 @@
  *               string literal.
  * @param ... format parameters matching the format string.
  */
-#define LOG(severity, format, ...)                               \
+#if __has_feature(capabilities)
+#define LOG(severity, format, ...) \
+  LOG_TO_SECTION(".rodata.fields", severity, format, ##__VA_ARGS__)
+#else
+#define LOG(severity, format, ...) \
+  LOG_TO_SECTION(".logs.fields", severity, format, ##__VA_ARGS__)
+#endif
+
+#define LOG_TO_SECTION(elf_section, severity, format, ...)       \
   do {                                                           \
     if (kDeviceLogBypassUartAddress != 0) {                      \
       /* clang-format off */                                     \
@@ -116,7 +124,7 @@
        * the linker will dutifully discard.
        * Unfortunately, clang-format really mangles these
        * declarations, so we format them manually. */            \
-      __attribute__((section(".logs.fields")))                   \
+      __attribute__((section(elf_section)))                      \
       static const log_fields_t kLogFields =                     \
           LOG_MAKE_FIELDS_(severity, format, ##__VA_ARGS__);     \
       base_log_internal_dv(&kLogFields,                          \