mirror of
https://github.com/ipxe/ipxe
synced 2025-12-18 02:20:19 +03:00
[efi] Treat writable sections as data sections
Hybrid bzImage and UEFI binaries (such as wimboot) may include 16-bit
executable code that is opaque data from the perspective of a UEFI PE
binary, as described in wimboot commit fe456ca ("[efi] Use separate
.text and .data PE sections").
The ELF section will be marked as containing both executable code and
writable data. Choose to treat such a section as a data section
rather than a code section, since that matches the expected semantics
for ELF files that we expect to process.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -591,17 +591,7 @@ static struct pe_section * process_section ( struct elf_file *elf,
|
|||||||
|
|
||||||
/* Fill in section characteristics and update RVA limits */
|
/* Fill in section characteristics and update RVA limits */
|
||||||
if ( ( shdr->sh_type == SHT_PROGBITS ) &&
|
if ( ( shdr->sh_type == SHT_PROGBITS ) &&
|
||||||
( shdr->sh_flags & SHF_EXECINSTR ) ) {
|
( shdr->sh_flags & SHF_WRITE ) ) {
|
||||||
/* .text-type section */
|
|
||||||
new->hdr.Characteristics =
|
|
||||||
( EFI_IMAGE_SCN_CNT_CODE |
|
|
||||||
EFI_IMAGE_SCN_MEM_NOT_PAGED |
|
|
||||||
EFI_IMAGE_SCN_MEM_EXECUTE |
|
|
||||||
EFI_IMAGE_SCN_MEM_READ );
|
|
||||||
applicable_start = &code_start;
|
|
||||||
applicable_end = &code_end;
|
|
||||||
} else if ( ( shdr->sh_type == SHT_PROGBITS ) &&
|
|
||||||
( shdr->sh_flags & SHF_WRITE ) ) {
|
|
||||||
/* .data-type section */
|
/* .data-type section */
|
||||||
new->hdr.Characteristics =
|
new->hdr.Characteristics =
|
||||||
( EFI_IMAGE_SCN_CNT_INITIALIZED_DATA |
|
( EFI_IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||||
@@ -610,6 +600,16 @@ static struct pe_section * process_section ( struct elf_file *elf,
|
|||||||
EFI_IMAGE_SCN_MEM_WRITE );
|
EFI_IMAGE_SCN_MEM_WRITE );
|
||||||
applicable_start = &data_start;
|
applicable_start = &data_start;
|
||||||
applicable_end = &data_mid;
|
applicable_end = &data_mid;
|
||||||
|
} else if ( ( shdr->sh_type == SHT_PROGBITS ) &&
|
||||||
|
( shdr->sh_flags & SHF_EXECINSTR ) ) {
|
||||||
|
/* .text-type section */
|
||||||
|
new->hdr.Characteristics =
|
||||||
|
( EFI_IMAGE_SCN_CNT_CODE |
|
||||||
|
EFI_IMAGE_SCN_MEM_NOT_PAGED |
|
||||||
|
EFI_IMAGE_SCN_MEM_EXECUTE |
|
||||||
|
EFI_IMAGE_SCN_MEM_READ );
|
||||||
|
applicable_start = &code_start;
|
||||||
|
applicable_end = &code_end;
|
||||||
} else if ( shdr->sh_type == SHT_PROGBITS ) {
|
} else if ( shdr->sh_type == SHT_PROGBITS ) {
|
||||||
/* .rodata-type section */
|
/* .rodata-type section */
|
||||||
new->hdr.Characteristics =
|
new->hdr.Characteristics =
|
||||||
|
|||||||
Reference in New Issue
Block a user