fprintf(stderr, "valgrind: %s: bad ELF magic\n", filename);
return NULL;
}
- if (e->e.e_ident[EI_CLASS] != ELFCLASS32) {
- fprintf(stderr, "valgrind: Can only handle 32-bit executables\n");
+ if (e->e.e_ident[EI_CLASS] != VG_ELF_CLASS) {
+ fprintf(stderr, "valgrind: wrong executable class (eg. 32-bit instead\n"
+ "valgrind: of 64-bit)\n");
return NULL;
}
- if (e->e.e_ident[EI_DATA] != ELFDATA2LSB) {
- fprintf(stderr, "valgrind: Expecting little-endian\n");
+ if (e->e.e_ident[EI_DATA] != VG_ELF_ENDIANNESS) {
+ fprintf(stderr, "valgrind: wrong endian-ness\n");
return NULL;
}
if (!(e->e.e_type == ET_EXEC || e->e.e_type == ET_DYN)) {
return NULL;
}
- if (e->e.e_machine != EM_386) {
- fprintf(stderr, "valgrind: need x86\n");
+ if (e->e.e_machine != VG_ELF_MACHINE) {
+ fprintf(stderr, "valgrind: wrong architecture\n");
return NULL;
}
VG_(memset)(ehdr, 0, sizeof(ehdr));
VG_(memcpy)(ehdr->e_ident, ELFMAG, SELFMAG);
- ehdr->e_ident[EI_CLASS] = ELFCLASS32;
- ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
+ ehdr->e_ident[EI_CLASS] = VG_ELF_CLASS;
+ ehdr->e_ident[EI_DATA] = VG_ELF_ENDIANNESS;
ehdr->e_ident[EI_VERSION] = EV_CURRENT;
ehdr->e_type = ET_CORE;
- ehdr->e_machine = EM_386;
+ ehdr->e_machine = VG_ELF_MACHINE;
ehdr->e_version = EV_CURRENT;
ehdr->e_entry = 0;
ehdr->e_phoff = sizeof(Elf32_Ehdr);
&& ehdr->e_ident[EI_MAG1] == 'E'
&& ehdr->e_ident[EI_MAG2] == 'L'
&& ehdr->e_ident[EI_MAG3] == 'F');
- ok &= (ehdr->e_ident[EI_CLASS] == ELFCLASS32
- && ehdr->e_ident[EI_DATA] == ELFDATA2LSB
+ ok &= (ehdr->e_ident[EI_CLASS] == VG_ELF_CLASS
+ && ehdr->e_ident[EI_DATA] == VG_ELF_ENDIANNESS
&& ehdr->e_ident[EI_VERSION] == EV_CURRENT);
ok &= (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN);
- ok &= (ehdr->e_machine == EM_386);
+ ok &= (ehdr->e_machine == VG_ELF_MACHINE);
ok &= (ehdr->e_version == EV_CURRENT);
ok &= (ehdr->e_shstrndx != SHN_UNDEF);
ok &= (ehdr->e_shoff != 0 && ehdr->e_shnum != 0);
extern Int VGOFF_(helper_undefined_instruction);
+/* ---------------------------------------------------------------------
+ Elf stuff
+ ------------------------------------------------------------------ */
+
+#define VG_ELF_ENDIANNESS ELFDATA2LSB
+#define VG_ELF_MACHINE EM_386
+#define VG_ELF_CLASS ELFCLASS32
+
+
/* ---------------------------------------------------------------------
Exports of vg_helpers.S
------------------------------------------------------------------ */