aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Gault <sylvain.gault@gmail.com>2014-02-03 05:43:02 +0100
committerH. Peter Anvin <hpa@linux.intel.com>2014-02-14 16:31:42 -0800
commit8c9a43f9fbd69a022f4a0913192e7bbc847e1af5 (patch)
tree148ce42c285833d9cab306dee9966a47447c5d31
parent8c11d9231fa234ff30477ba9c958c9d3645abfa2 (diff)
downloadsyslinux-8c9a43f9fbd69a022f4a0913192e7bbc847e1af5.tar.gz
syslinux-8c9a43f9fbd69a022f4a0913192e7bbc847e1af5.tar.xz
syslinux-8c9a43f9fbd69a022f4a0913192e7bbc847e1af5.zip
efi: Fix PE header field rva_and_sizes_nr
The value of the field rva_and_sizes_nr is used by OVMF to check the consistency of the PE file with respect to the field optional_hdr_sz. It now have the right value. Signed-off-by: Sylvain Gault <sylvain.gault@gmail.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--efi/wrapper.c6
-rw-r--r--efi/wrapper.h28
2 files changed, 19 insertions, 15 deletions
diff --git a/efi/wrapper.c b/efi/wrapper.c
index 04c895f6..ec77271b 100644
--- a/efi/wrapper.c
+++ b/efi/wrapper.c
@@ -102,7 +102,7 @@ static void write_header(FILE *f, __uint32_t entry, size_t data_size,
e_hdr.image_sz = total_sz;
e_hdr.headers_sz = 512;
e_hdr.subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION;
- e_hdr.rva_and_sizes_nr = 1;
+ e_hdr.rva_and_sizes_nr = sizeof(e_hdr.data_directory) / sizeof(__uint64_t);
fwrite(&e_hdr, sizeof(e_hdr), 1, f);
}
else if (class == ELFCLASS64) {
@@ -130,7 +130,7 @@ static void write_header(FILE *f, __uint32_t entry, size_t data_size,
e_hdr_pe32p.image_sz = total_sz;
e_hdr_pe32p.headers_sz = 512;
e_hdr_pe32p.subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION;
- e_hdr_pe32p.rva_and_sizes_nr = 1;
+ e_hdr_pe32p.rva_and_sizes_nr = sizeof(e_hdr_pe32p.data_directory) / sizeof(__uint64_t);
fwrite(&e_hdr_pe32p, sizeof(e_hdr_pe32p), 1, f);
}
@@ -237,7 +237,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Unsupported architecture\n");
exit(EXIT_FAILURE);
}
-
+
if (id[EI_MAG0] != ELFMAG0 ||
id[EI_MAG1] != ELFMAG1 ||
id[EI_MAG2] != ELFMAG2 ||
diff --git a/efi/wrapper.h b/efi/wrapper.h
index 4f769914..0e6b38ea 100644
--- a/efi/wrapper.h
+++ b/efi/wrapper.h
@@ -102,12 +102,14 @@ struct extra_hdr {
__uint32_t heap_commit_sz;
__uint32_t loader_flags;
__uint32_t rva_and_sizes_nr;
- __uint64_t export_table;
- __uint64_t import_table;
- __uint64_t resource_table;
- __uint64_t exception_table;
- __uint64_t certification_table;
- __uint64_t base_relocation_table;
+ struct {
+ __uint64_t export_table;
+ __uint64_t import_table;
+ __uint64_t resource_table;
+ __uint64_t exception_table;
+ __uint64_t certification_table;
+ __uint64_t base_relocation_table;
+ } data_directory;
} __packed;
/* Extra header for PE32+ format
@@ -136,12 +138,14 @@ struct extra_hdr_pe32p {
__uint64_t heap_commit_sz;
__uint32_t loader_flags;
__uint32_t rva_and_sizes_nr;
- __uint64_t export_table;
- __uint64_t import_table;
- __uint64_t resource_table;
- __uint64_t exception_table;
- __uint64_t certification_table;
- __uint64_t base_relocation_table;
+ struct {
+ __uint64_t export_table;
+ __uint64_t import_table;
+ __uint64_t resource_table;
+ __uint64_t exception_table;
+ __uint64_t certification_table;
+ __uint64_t base_relocation_table;
+ } data_directory;
} __packed;
struct section {