From 0d209043382af3fb52c9371131ddefb434ca0b3d Mon Sep 17 00:00:00 2001 From: Juergen Gross Date: Fri, 7 Dec 2018 13:11:45 +0100 Subject: [PATCH] xen: Use elfnote defines instead of plain numbers In order to avoid using plain integers for the ELF notes use the available Xen include instead. Signed-off-by: Juergen Gross Reviewed-by: Daniel Kiper Tested-by: Hans van Kranenburg --- util/grub-mkimagexx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a483c674c..784ed1a52 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -48,6 +48,8 @@ #include #include +#include + #pragma GCC diagnostic ignored "-Wcast-align" #define GRUB_MKIMAGEXX @@ -341,7 +343,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof (PACKAGE_NAME)); - note_ptr->n_type = grub_host_to_target32 (6); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_GUEST_OS); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -352,7 +354,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof ("generic")); - note_ptr->n_type = grub_host_to_target32 (8); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_LOADER); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -363,7 +365,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof ("xen-3.0")); - note_ptr->n_type = grub_host_to_target32 (5); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_XEN_VERSION); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -374,7 +376,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof); - note_ptr->n_type = grub_host_to_target32 (1); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_ENTRY); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -385,7 +387,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof); - note_ptr->n_type = grub_host_to_target32 (3); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_VIRT_BASE); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4); @@ -398,7 +400,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc note_ptr = (Elf_Nhdr *) ptr; note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME)); note_ptr->n_descsz = grub_host_to_target32 (sizeof ("yes,bimodal")); - note_ptr->n_type = grub_host_to_target32 (9); + note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_PAE_MODE); ptr += sizeof (Elf_Nhdr); memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME)); ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);