aboutsummaryrefslogtreecommitdiff
path: root/src/util/elf2efi.c
diff options
context:
space:
mode:
authorMarvin Häuser <mhaeuser@posteo.de>2021-04-05 16:45:07 +0200
committerMichael Brown <mcb30@ipxe.org>2021-04-10 14:13:05 +0100
commit94245624e449d4d65223c00055be3d7ea04983f9 (patch)
tree08a90a6151b28f9a55eb3d4b424e42195371a6dc /src/util/elf2efi.c
parentf1e9e2b062fab46a6e3aec1f08d4554dd5dd2b98 (diff)
downloadipxe-94245624e449d4d65223c00055be3d7ea04983f9.zip
ipxe-94245624e449d4d65223c00055be3d7ea04983f9.tar.gz
ipxe-94245624e449d4d65223c00055be3d7ea04983f9.tar.bz2
[efi] Mark PE .reloc and .debug sections as discardable
After a PE image is fully loaded and relocated, the loader code may opt to zero discardable sections for security reasons. This includes relocation and debug information, as both contain hints about specific locations within the binary. Mark both generated sections as discardable, which follows the PE specification. Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
Diffstat (limited to 'src/util/elf2efi.c')
-rw-r--r--src/util/elf2efi.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c
index b0d5466..5542b99 100644
--- a/src/util/elf2efi.c
+++ b/src/util/elf2efi.c
@@ -758,6 +758,7 @@ create_reloc_section ( struct pe_header *pe_header,
reloc->hdr.VirtualAddress = pe_header->nt.OptionalHeader.SizeOfImage;
reloc->hdr.SizeOfRawData = section_filesz;
reloc->hdr.Characteristics = ( EFI_IMAGE_SCN_CNT_INITIALIZED_DATA |
+ EFI_IMAGE_SCN_MEM_DISCARDABLE |
EFI_IMAGE_SCN_MEM_NOT_PAGED |
EFI_IMAGE_SCN_MEM_READ );
@@ -822,6 +823,7 @@ create_debug_section ( struct pe_header *pe_header, const char *filename ) {
debug->hdr.VirtualAddress = pe_header->nt.OptionalHeader.SizeOfImage;
debug->hdr.SizeOfRawData = section_filesz;
debug->hdr.Characteristics = ( EFI_IMAGE_SCN_CNT_INITIALIZED_DATA |
+ EFI_IMAGE_SCN_MEM_DISCARDABLE |
EFI_IMAGE_SCN_MEM_NOT_PAGED |
EFI_IMAGE_SCN_MEM_READ );
debug->fixup = fixup_debug_section;