After the commit of SVN rev 180236, wilko@ noticed that the approach

doesn't work on the Alpha platform: machine/elf.h doesn't include
sys/elf32.h there.

PR:		related to bin/124906
Approved by:	bde@
MFC after:	1 week
This commit is contained in:
Edwin Groothuis 2008-07-21 02:13:14 +00:00
parent 409d8ba5c7
commit 8bd833fff8

View File

@ -48,6 +48,18 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
/*
* Elf32_xhdr structures can only be used if sys/elf32.h is included, so
* check for the existence of one of the macros defined in sys/elf32.h.
*
* The presense of the ELF32_R_TYPE macro via machine/elf.h has been verified
* on amd64 6.3, ia64 7.0 and sparc64 7.0. The absence of the macro has been
* verified on alpha 6.2.
*/
#if defined(ELF32_R_TYPE)
#define ELF32_SUPPORTED
#endif
static int is_executable(const char *fname, int fd, int *is_shlib,
int *type);
static void usage(void);
@ -55,7 +67,7 @@ static void usage(void);
#define TYPE_UNKNOWN 0
#define TYPE_AOUT 1
#define TYPE_ELF 2 /* Architecture default */
#if __ELF_WORD_SIZE > 32
#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
#define TYPE_ELF32 3 /* Explicit 32 bits on architectures >32 bits */
#endif
@ -73,7 +85,7 @@ const char *envdef[ENV_LAST] = {
"LD_TRACE_LOADED_OBJECTS_PROGNAME",
"LD_TRACE_LOADED_OBJECTS_ALL",
};
#if __ELF_WORD_SIZE > 32
#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
const char *env32[ENV_LAST] = {
"LD_32_TRACE_LOADED_OBJECTS",
"LD_32_TRACE_LOADED_OBJECTS_FMT1",
@ -154,7 +166,7 @@ main(int argc, char *argv[])
case TYPE_AOUT:
env = envdef;
break;
#if __ELF_WORD_SIZE > 32
#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
case TYPE_ELF32:
env = env32;
break;
@ -229,7 +241,9 @@ is_executable(const char *fname, int fd, int *is_shlib, int *type)
{
union {
struct exec aout;
#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
Elf32_Ehdr elf32;
#endif
Elf_Ehdr elf;
} hdr;
int n;
@ -256,7 +270,7 @@ is_executable(const char *fname, int fd, int *is_shlib, int *type)
return (1);
}
#if __ELF_WORD_SIZE > 32
#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
if ((size_t)n >= sizeof(hdr.elf32) && IS_ELF(hdr.elf32) &&
hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) {
/* Handle 32 bit ELF objects */