|
From: Nicholas N. <nj...@ca...> - 2004-10-09 19:08:11
|
CVS commit by nethercote:
Arch-abstraction:
- abstract out three ELF constants
M +7 -6 ume.c 1.29 [POSSIBLY UNSAFE: printf]
M +3 -3 vg_signals.c 1.90
M +3 -3 vg_symtab2.c 1.90
M +9 -0 x86/core_arch.h 1.9
--- valgrind/coregrind/ume.c #1.28:1.29
@@ -278,10 +278,11 @@ struct elfinfo *readelf(int fd, const ch
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;
}
@@ -291,6 +292,6 @@ struct elfinfo *readelf(int fd, const ch
}
- 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;
}
--- valgrind/coregrind/vg_signals.c #1.89:1.90
@@ -1015,10 +1015,10 @@ static void fill_ehdr(Elf32_Ehdr *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;
--- valgrind/coregrind/vg_symtab2.c #1.89:1.90
@@ -759,9 +759,9 @@ Bool VG_(is_object_file)(const void *buf
&& 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);
--- valgrind/coregrind/x86/core_arch.h #1.8:1.9
@@ -130,4 +130,13 @@ extern Int VGOFF_(helper_undefined_instr
/* ---------------------------------------------------------------------
+ Elf stuff
+ ------------------------------------------------------------------ */
+
+#define VG_ELF_ENDIANNESS ELFDATA2LSB
+#define VG_ELF_MACHINE EM_386
+#define VG_ELF_CLASS ELFCLASS32
+
+
+/* ---------------------------------------------------------------------
Exports of vg_helpers.S
------------------------------------------------------------------ */
|