aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-05-09 14:24:21 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-05-13 12:08:07 +0100
commit5de984d3f42258fb49cfb713002a2e2aae4b16a4 (patch)
treebbe519a2a9c846954d46330cf2c44e0435a9af0c
parentfe283b78c973268f2d1f0309826ceeb5c9e8978d (diff)
downloadsyslinux-5de984d3f42258fb49cfb713002a2e2aae4b16a4.tar.gz
syslinux-5de984d3f42258fb49cfb713002a2e2aae4b16a4.tar.xz
syslinux-5de984d3f42258fb49cfb713002a2e2aae4b16a4.zip
efi: Fill out MS-DOS header relocs field
The relocs field in the MS-DOS header actually indicates the size of the MS-DOS header and needs filling out with a value >= 0x40. See, http://www.ctyme.com/intr/rb-2939.htm#table1594 - "18h WORD offset within header of relocation table 40h or greater for new-format (NE,LE,LX,W3,PE,etc.) executable" Incidentally, file(1) checks the value of that field to differentiate MS-DOS executables from PE-COFF files, e.g. file(1) output before: MS-DOS executable file(1) output after: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--efi/wrapper.c8
-rw-r--r--efi/wrapper.h4
2 files changed, 11 insertions, 1 deletions
diff --git a/efi/wrapper.c b/efi/wrapper.c
index 0943534c..1b1d5d33 100644
--- a/efi/wrapper.c
+++ b/efi/wrapper.c
@@ -60,6 +60,14 @@ static void write_header(FILE *f, __uint32_t entry, __uint32_t so_size, __uint8_
memset(&hdr, 0, sizeof(hdr));
hdr.msdos_signature = MSDOS_SIGNATURE;
+
+ /*
+ * The relocs table pointer needs to be >= 0x40 for PE files. It
+ * informs things like file(1) that we are not an MS-DOS
+ * executable.
+ */
+ hdr.relocs_ptr = 0x40;
+
hdr.pe_hdr = OFFSETOF(struct header, pe_signature);
hdr.pe_signature = PE_SIGNATURE;
fwrite(&hdr, sizeof(hdr), 1, f);
diff --git a/efi/wrapper.h b/efi/wrapper.h
index 492c262b..4f769914 100644
--- a/efi/wrapper.h
+++ b/efi/wrapper.h
@@ -28,7 +28,9 @@
struct header {
__uint16_t msdos_signature;
- __uint8_t _pad1[0x3c - 2];
+ __uint8_t _pad1[0x16];
+ __uint16_t relocs_ptr;
+ __uint8_t __pad2[0x3c - 0x1a];
__uint32_t pe_hdr;
__uint16_t pe_signature;
__uint16_t _pad2;