Re: [HACKERS] Checking if a system is ELF

From: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Checking if a system is ELF
Date: 1999-07-27 22:27:52
Message-ID: 19990727172752.A14498@wallace.ece.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 27, 1999 at 05:58:33PM -0400, D'Arcy J.M. Cain wrote:
> Todd Vierling (tv(at)pobox(dot)com) suggested the following test for ELFness.
> Seems pretty portable to me.
>
> Thus spake Todd Vierling (tv(at)pobox(dot)com)
> >On NetBSD, the following will do it. This may even be platform independednt
> >if "grep -q" is replaced by "grep >/dev/null 2>&1".
> >
> >if echo __ELF__ | ${CC} -E - | grep -q __ELF__; then
> > ... a.out action ...
> >else
> > ... ELF action ...
> >fi

Uh, two problems:

One, it assumes ${CC} is really gcc - the native SGI MIPS compiler doesn't
like - for compiling stdin. Second, my linux box seems to #define __ELF__
as 1. I'm not sure if that is gcc version related, or platform.

tatabox% echo __ELF__ | cc -E -
cc ERROR parsing -: unknown flag
cc ERROR: no source or object file given
tatabox% cc -version
MIPSpro Compilers: Version 7.2.1.3m

tatabox% echo __ELF__ | gcc -E -
# 1 ""
__ELF__
tatabox% gcc -v
Reading specs from /usr/site/egcs-1.1.2/lib/gcc-lib/mips-sgi-irix6.5/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

wallace$ echo __ELF__ | gcc -E -
# 1 ""
1
wallace$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2.3/specs
gcc version 2.7.2.3

Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-07-27 22:58:01 Re: Selectivity of "=" (Re: [HACKERS] Index not used on simple select)
Previous Message Hub.Org News Admin 1999-07-27 21:59:17