arm: Move trampolines into code section

When creating T32->A32 transition jumps, the relocation code in grub
will generate trampolines. These trampolines live in the .data section
of our PE binary which means they are not marked as executable.

This misbehavior was unmasked by commit a51f953f4e ("mkimage: Align
efi sections on 4k boundary") which made the X/NX boundary more obvious
because everything became page aligned.

To put things into proper order, let's move the arm trampolines into the
.text section instead. That way everyone knows they are executable.

Fixes: a51f953f4e ("mkimage: Align efi sections on 4k boundary")
Reported-by: Julien ROBIN <julien.robin28@free.fr>
Reported-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Alexander Graf <agraf@csgraf.de>
Tested-by: Julien ROBIN <julien.robin28@free.fr>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Alexander Graf 2019-04-30 22:43:56 +02:00 committed by Vincent Batts
parent 35e918e7c9
commit 497438f0f5
1 changed files with 15 additions and 17 deletions

View File

@ -2197,6 +2197,21 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path,
}
}
#ifdef MKIMAGE_ELF32
if (image_target->elf_target == EM_ARM)
{
grub_size_t tramp;
layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize,
smd->num_sections, image_target);
layout->tramp_off = layout->kernel_size;
layout->kernel_size += ALIGN_UP (tramp, 16);
}
#endif
layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset,
image_target->section_align)
- image_target->vaddr_offset;
@ -2210,23 +2225,6 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path,
layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, smd,
image_target);
#ifdef MKIMAGE_ELF32
if (image_target->elf_target == EM_ARM)
{
grub_size_t tramp;
layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset,
image_target->section_align) - image_target->vaddr_offset;
layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize,
smd->num_sections, image_target);
layout->tramp_off = layout->kernel_size;
layout->kernel_size += ALIGN_UP (tramp, 16);
}
#endif
layout->bss_start = layout->kernel_size;
layout->end = layout->kernel_size;