From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 5 00:39:49 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F1C1016A4CF for ; Thu, 5 Feb 2004 00:39:48 -0800 (PST) Received: from genua.rfc-networks.ie (genua.rfc-networks.ie [62.77.182.178]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2F64943D2F for ; Thu, 5 Feb 2004 00:39:47 -0800 (PST) (envelope-from philip.reynolds@rfc-networks.ie) Received: from tear.domain (tear [10.0.1.254]) by genua.rfc-networks.ie (Postfix) with ESMTP id 453345CCE for ; Thu, 5 Feb 2004 08:40:38 +0000 (GMT) Received: by tear.domain (Postfix, from userid 1000) id 3210620F13; Thu, 5 Feb 2004 08:39:45 +0000 (GMT) Date: Thu, 5 Feb 2004 08:39:45 +0000 From: Philip Reynolds To: freebsd-hackers@freebsd.org Message-ID: <20040205083945.GB96509@rfc-networks.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 4.8-STABLE X-URL: http://www.rfc-networks.ie Subject: ELF branding / magic numbers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: philip.reynolds@rfc-networks.ie List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Feb 2004 08:39:49 -0000 Hi, At the moment, on both OpenBSD and FreeBSD (you're going to have to excuse my lack of familiarity with NetBSD but I presume this situation is similar) ELF files are branded via the CSU library, inside a PT_NOTE section. I've looked through as much documentation and list archives that I could manage at the moment and this seems to be due to the fact that "ELF was designed with the assumption that there would be only one system ABI". At the moment, ELF files still contain a magic number, rather like a.out(5). Readelf quickly shows this using ``-h'' $ readelf -h /bin/ls ELF Header: Magic: 7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00 If we break the hexidecimal values up, the first four denote the first four bytes of the magic number, which basically say it's an ELF binary. The next three are the class, data and version respectively and the eighth bit would seem to denote the ABI (elf(5) and /usr/include/sys/elf_common.h seem to agree with me). Does the magic number not then support multiple ABI's per system architecture, or is there some part of the puzzle I'm missing? OpenBSD, curiously, enough doesn't set the ABI within the magic number at all (it only supports the one type of branded elf as far as I'm aware anyways) which just leads me to believe it's only set for legacy reasons in FreeBSD? Any insight into the matter will be greatly appreciated. It's not something I'm questioning, more curious about, as reading the PT_NOTE section (e.g. from file(1)) is certainly more convaluted than looking at the mgaic number. There's obviously a good reason for that. -- Philip Reynolds | RFC Networks Ltd. philip.reynolds@rfc-networks.ie | +353 (0)1 8832063 http://people.rfc-networks.ie/~phil/ | www.rfc-networks.ie