Date: Thu, 03 Sep 1998 09:39:45 -0700 From: John Polstra <jdp@polstra.com> To: abial@nask.pl Cc: current@FreeBSD.ORG Subject: Re: ELF broke crunchgen/crunchide Message-ID: <199809031639.JAA02670@austin.polstra.com> In-Reply-To: <Pine.BSF.4.02A.9809031151070.3219-100000@korin.warman.org.pl> References: <Pine.BSF.4.02A.9809031151070.3219-100000@korin.warman.org.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <Pine.BSF.4.02A.9809031151070.3219-100000@korin.warman.org.pl>, Andrzej Bialecki <abial@nask.pl> 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: <sys/elf32.h> declares most of the data structures for 32-bit arch <sys/elf_common.h> #defines for common constants <sys/elf_generic.h> cpp magic to hide the details of 32- vs. 64-bit architectures <sys/elf64.h> like <sys/elf32.h>, but for 64-bit arch <machine/elf.h> architecture-specific stuff Most of what you'll need to look at is in <sys/elf32.h> and <sys/elf_common.h>. However, in your application you should just include <elf.h>, 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809031639.JAA02670>