a.out.h for 64-bit Cygwin?
Ken Brown
kbrown@cornell.edu
Sun Mar 10 03:44:00 GMT 2013
It may be too soon to expect this to work, but I'm trying to build emacs
for 64-bit Cygwin. Part of the build process involves direct
manipulation of a .exe file, based on the structures defined in
/usr/include/a.out.h. I'm wondering whether this file needs to be
updated before it will work with 64-bit .exe files.
I'm appending below some excerpts from the code that produce lots of
assertion failures when I try to build emacs. Suggestions for fixing
this would be appreciated.
I can give more details, but I thought I'd start by just making sure I
have a reasonable a.out.h to work with. Also, I suspect that some of
the magic numbers in the code below need to be changed.
Ken
#include <a.out.h>
typedef struct
{
FILHDR file_header;
PEAOUTHDR file_optional_header;
SCNHDR section_header[32];
} exe_header_t;
static exe_header_t *
read_exe_header (int fd, exe_header_t * exe_header_buffer)
{
int i;
int ret;
assert (fd >= 0);
assert (exe_header_buffer != 0);
ret = lseek (fd, 0L, SEEK_SET);
assert (ret != -1);
ret =
read (fd, &exe_header_buffer->file_header,
sizeof (exe_header_buffer->file_header));
assert (ret == sizeof (exe_header_buffer->file_header));
assert (exe_header_buffer->file_header.e_magic == 0x5a4d);
assert (exe_header_buffer->file_header.nt_signature == 0x4550);
assert (exe_header_buffer->file_header.f_magic == 0x014c);
assert (exe_header_buffer->file_header.f_nscns > 0);
assert (exe_header_buffer->file_header.f_nscns <=
sizeof (exe_header_buffer->section_header) /
sizeof (exe_header_buffer->section_header[0]));
assert (exe_header_buffer->file_header.f_opthdr > 0);
ret =
read (fd, &exe_header_buffer->file_optional_header,
sizeof (exe_header_buffer->file_optional_header));
assert (ret == sizeof (exe_header_buffer->file_optional_header));
assert (exe_header_buffer->file_optional_header.magic == 0x010b);
for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i)
{
ret =
read (fd, &exe_header_buffer->section_header[i],
sizeof (exe_header_buffer->section_header[i]));
assert (ret == sizeof (exe_header_buffer->section_header[i]));
}
return (exe_header_buffer);
}
More information about the Cygwin-apps
mailing list