From owner-freebsd-current Thu Sep 3 09:41:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA11075 for freebsd-current-outgoing; Thu, 3 Sep 1998 09:41:30 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA11063 for ; Thu, 3 Sep 1998 09:41:26 -0700 (PDT) (envelope-from jdp@austin.polstra.com) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.8/8.8.8) with ESMTP id JAA02670; Thu, 3 Sep 1998 09:39:46 -0700 (PDT) (envelope-from jdp) Message-Id: <199809031639.JAA02670@austin.polstra.com> To: abial@nask.pl Subject: Re: ELF broke crunchgen/crunchide In-Reply-To: References: Organization: Polstra & Co., Seattle, WA Cc: current@FreeBSD.ORG Date: Thu, 03 Sep 1998 09:39:45 -0700 From: John Polstra Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article , Andrzej Bialecki wrote: > Today I tried to use crunchgen, and it fails miserably, because it plays > directly with a.out format. I guess we need to teach it about elves... > > I could do with some pointers to the ELF format and the way ld shuffles > symbols - then I'd try to fix it, and probably then I'd cry for more > help... :-) As far I know, the original published ELF specs are out of print. I can help you with it. Briefly, an ELF file consists of: A file header (the starting point for everything) An optional program header, with information for the kernel's image loader An array of section headers, where everything else resides An array of section contents Sections are used to represent almost everything. Besides the usual text, data, and bss, sections are also used to contain symbols, relocations, the string table, etc. Start by taking a look at the ELF include files: declares most of the data structures for 32-bit arch #defines for common constants cpp magic to hide the details of 32- vs. 64-bit architectures like , but for 64-bit arch architecture-specific stuff Most of what you'll need to look at is in and . However, in your application you should just include , which Does The Right Thing for the native machine, while allowing the application to be ignorant of its word size. It might also be worthwhile to look at the dynamic linker in "src/libexec/rtld-elf". It only deals with dynamic symbols, but it's a lot easier to navigate than binutils is. After you've looked at the headers, contact me privately and I'll answer any questions you might have. -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message