From: Julian Seward Date: Sun, 10 Jul 2005 00:53:42 +0000 (+0000) Subject: Clean up endianness macros a bit. Now pub_tool_basics.h defines X-Git-Tag: svn/VALGRIND_3_0_0~176 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f13ea11bf89ca5c8e67df46ccf639f41142c1995;p=thirdparty%2Fvalgrind.git Clean up endianness macros a bit. Now pub_tool_basics.h defines VG_LITTLEENDIAN or VG_BIGENDIAN and that's what should be used. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4142 --- diff --git a/coregrind/m_debuginfo/symtab.c b/coregrind/m_debuginfo/symtab.c index a807ee8820..80d2539060 100644 --- a/coregrind/m_debuginfo/symtab.c +++ b/coregrind/m_debuginfo/symtab.c @@ -906,7 +906,7 @@ 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] == VG_ELF_CLASS - && ehdr->e_ident[EI_DATA] == VG_ELF_ENDIANNESS + && ehdr->e_ident[EI_DATA] == VG_ELF_DATA2XXX && ehdr->e_ident[EI_VERSION] == EV_CURRENT); ok &= (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN); ok &= (ehdr->e_machine == VG_ELF_MACHINE); diff --git a/coregrind/m_ume.c b/coregrind/m_ume.c index 8bf91d18e5..6b0cbd17c9 100644 --- a/coregrind/m_ume.c +++ b/coregrind/m_ume.c @@ -288,7 +288,7 @@ struct elfinfo *readelf(int fd, const char *filename) "(eg. 32-bit instead of 64-bit)\n"); goto bad; } - if (e->e.e_ident[EI_DATA] != VG_ELF_ENDIANNESS) { + if (e->e.e_ident[EI_DATA] != VG_ELF_DATA2XXX) { fprintf(stderr, "valgrind: executable has wrong endian-ness\n"); goto bad; } diff --git a/coregrind/pub_core_machine.h b/coregrind/pub_core_machine.h index 3604ea41a7..8b9cdba27f 100644 --- a/coregrind/pub_core_machine.h +++ b/coregrind/pub_core_machine.h @@ -40,15 +40,15 @@ #include "pub_tool_machine.h" #if defined(VGA_x86) -# define VG_ELF_ENDIANNESS ELFDATA2LSB +# define VG_ELF_DATA2XXX ELFDATA2LSB # define VG_ELF_MACHINE EM_386 # define VG_ELF_CLASS ELFCLASS32 #elif defined(VGA_amd64) -# define VG_ELF_ENDIANNESS ELFDATA2LSB +# define VG_ELF_DATA2XXX ELFDATA2LSB # define VG_ELF_MACHINE EM_X86_64 # define VG_ELF_CLASS ELFCLASS64 #elif defined(VGA_ppc32) -# define VG_ELF_ENDIANNESS ELFDATA2MSB +# define VG_ELF_DATA2XXX ELFDATA2MSB # define VG_ELF_MACHINE EM_PPC # define VG_ELF_CLASS ELFCLASS32 #else diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index 67345b8531..90882e43ae 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -109,13 +109,24 @@ typedef struct { SysRes; /* --------------------------------------------------------------------- - Miscellaneous + Miscellaneous (word size, endianness, regparmness) ------------------------------------------------------------------ */ -/* This is going to be either 4 or 8. */ +/* Word size: this is going to be either 4 or 8. */ // It should probably be in m_machine. #define VG_WORDSIZE VEX_HOST_WORDSIZE +/* Endianness */ +#undef VG_BIGENDIAN +#undef VG_LITTLEENDIAN + +#if defined(VGA_x86) || defined(VGA_amd64) +# define VG_LITTLEENDIAN 1 +#elif defined(VGA_ppc32) +# define VG_BIGENDIAN 1 +#endif + +/* Regparmness */ #if defined(VGA_x86) # define VG_REGPARM(n) __attribute__((regparm(n))) #elif defined(VGA_amd64) || defined(VGA_ppc32) diff --git a/memcheck/mc_translate.c b/memcheck/mc_translate.c index 49590ee598..0579897b08 100644 --- a/memcheck/mc_translate.c +++ b/memcheck/mc_translate.c @@ -2367,9 +2367,9 @@ void do_shadow_Dirty ( MCEnv* mce, IRDirty* d ) IREndness end; /* What's the native endianness? We need to know this. */ -# if defined(VKI_BIG_ENDIAN) +# if defined(VG_BIGENDIAN) end = Iend_BE; -# elif defined(VKI_LITTLE_ENDIAN) +# elif defined(VG_LITTLEENDIAN) end = Iend_LE; # else # error "Unknown endianness"