C/elf library and object formats?

C/elf library and object formats?

Post by Markus Gutsch » Wed, 20 Mar 1996 04:00:00



-----BEGIN PGP SIGNED MESSAGE-----


> Yo can anyone suggest suitable references and or sources for file
> formats for C librarys and object files. Particularly elf format
> libraries and the mechanism for dynamic linkage. I guess i'm looking
> for these details solely in connection with linux.

I do not know, if there is any good documentation available, but you
could always try to reverse-engineer the bfd code in the binutils
source. But, maybe, if you provide more details on why you need this
information, somebody could suggest a more appropriate reference.

Markus

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.3, an Emacs/PGP interface

iQCVAgUBMU7r1BqJqDLErwMxAQE61QP/WVNs6vyuwogf6GyqgLWdplH4vCJlBTra
FEVF6BdhBMPsnkkAmjm9qODbidw1v6HCN4YV5Ep6MsuXIasIzdkXjbICkRi6/6gO
BixK0K2tzZkgWzAf+YTLjoIcwErOjd3yEjyaxBuk0v348l5QHIwFLDF5hOIOBdAO
GmqdDMVdCQc=
=GVI9
-----END PGP SIGNATURE-----

 
 
 

C/elf library and object formats?

Post by Michael Meissn » Fri, 22 Mar 1996 04:00:00


In article <4ikeis$...@mulgave.octacon.co.uk> Andy Kirby

<A.Ki...@cyberdev.octacon.co.uk> writes:

| Yo can anyone suggest suitable references and or sources for file
| formats for C librarys and object files. Particularly elf format
| libraries and the mechanism for dynamic linkage. I guess i'm looking
| for these details solely in connection with linux.
|
| SORRY if this is considered strictly a C news group thing.
| I did'nt think they would be linux specific enough.

Generic ELF is documented in:

        System V Application Binary Interface
        ISBN 0-13-880410-9

The processor supplement for the x86 is:

        System V Application Binary Interface, Intel386 (tm) Processor
        Supplement
        ISBN 0-13-877689-X

Now, these were originally published by AT&T back when they owned UNIX System
V.  As to whether Novell, or now SCO is publishing these, I don't know.  If you
want an elf specific object dumper, where is what I wrote in my last job, and
have enhanced somewhat since then:

/*
 * COPYRIGHT NOTICE
 *
 * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
 *
 * Permission is hereby granted to use, copy, modify and freely distribute
 * the software in this file and its documentation for any purpose without
 * fee, provided that the above copyright notice appears in all copies and
 * that both the copyright notice and this permission notice appear in
 * supporting documentation.  Further, provided that the name of Open
 * Software Foundation, Inc. ("OSF") not be used in advertising or
 * publicity pertaining to distribution of the software without prior
 * written permission from OSF.  OSF makes no representations about the
 * suitability of this software for any purpose.  It is provided "as is"
 * without express or implied warranty.
 */
/*
 * ELF object file dumper.
 */
/*
 * HISTORY
 * $Log: elfdump.c,v $
 * Revision 1.39  1996/03/15 15:07:22  meissner
 * Add support for filename being -, and buffering it.
 *
 * Revision 1.38  1996/03/15 13:39:16  meissner
 * Document -h.
 *
 * Revision 1.37  1996/02/05 00:27:34  meissner
 * Shorten section summary by a few chars.
 *
 * Revision 1.36  1996/01/16  19:22:54  meissner
 * Correctly spell _SDA2_BASE_.
 *
 * Revision 1.35  1996/01/12 19:27:28  meissner
 * Make exclude flag lower case.
 *
 * Revision 1.34  1996/01/12 18:30:43  meissner
 * Add more linker symbols.
 *
 * Revision 1.33  1996/01/12 14:56:01  meissner
 * Add more linker generated symbols used in PowerPC.
 *
 * Revision 1.32  1996/01/11 21:50:16  meissner
 * Fix last change.
 *
 * Revision 1.31  1996/01/11 21:48:41  meissner
 * Add extra ().
 *
 * Revision 1.30  1996/01/11 21:48:00  meissner
 * Add SHT_ORDERED & SHF_EXCLUDE support.
 *
 * Revision 1.29  1996/01/03 22:31:27  meissner
 * Fix typo.
 * Add ppc reloc type 255 as R_PPC_TOC16 (cygnus local).
 *
 * Revision 1.28  1995/11/13  18:36:51  meissner
 * if -d and machine is PowerPC, try canonical cross compiler name for objdump.
 *
 * Revision 1.27  1995/09/26  14:19:43  meissner
 * Add -D to print a text section in raw format as well as disassemble.
 *
 * Revision 1.26  1995/09/21  17:50:54  meissner
 * Add -mrelocatable-lib support.
 *
 * Revision 1.25  1995/03/13  15:10:42  meissner
 * For processor and user specific types, remove high bits before printing number.
 *
 * Revision 1.24  1995/03/08  23:19:54  meissner
 * Add -mrelocatable support.
 *
 * Revision 1.23  1995/03/01  19:49:33  meissner
 * Correctly deal with bi-endian data in print_section_hash.
 *
 * Revision 1.22  1995/02/24  16:43:36  meissner
 * Don't compare unsigneds with signeds.
 * Eliminate STT_STABS hack from OSF/1.
 *
 * Revision 1.21  1995/02/24  14:52:05  meissner
 * Fall back to use V.4's dis if objdump isn't available.
 *
 * Revision 1.20  1995/02/14  21:10:42  meissner
 * Do endian transformation on stab string offsets.
 * Before writing to stderr, fflush stdout.
 *
 * Revision 1.19  1995/02/14  18:56:01  meissner
 * EM_PPC is now 20, not 17.  Reconize both old and new values.
 *
 * Revision 1.18  1995/01/28  02:35:01  meissner
 * Fix spacing if raw section size is not a multiple of 4.
 * For -d, also look for ../../binutils/objdump.
 *
 * Revision 1.17  1995/01/27  17:14:15  meissner
 * Add new PowerPC section relative relocations.
 *
 * Revision 1.16  1995/01/23  16:21:38  meissner
 * Make -e deal with mixed endian systems.
 * Add support for new linker symbols.
 *
 * Revision 1.15  1995/01/22  01:52:44  meissner
 * When writing the layout, size any holes as well.
 *
 * Revision 1.14  1995/01/20  17:19:18  meissner
 * For -d, try using ../binutils/objdump first in case we are in the build tree.
 *
 * Revision 1.13  1995/01/19  22:31:10  meissner
 * Add PowerPC relocations.
 *
 * Revision 1.12  1995/01/19  18:02:32  meissner
 * Replace uchar with Uchar.
 *
 * Revision 1.11  1995/01/19  17:50:22  meissner
 * Allow ELF file to be unaligned.
 * Deal with converting numbers from host format to target format.
 * Remove OSF/1 profile support.
 *
 * Revision 1.10  1994/12/29  17:39:07  meissner
 * Add support to print PowerPC, MIPS, and PA RISC specific flags.
 *
 * Revision 1.9  1994/12/29 16:35:43  meissner
 * Use fflush(stdout); fflush(stderr); instead of fflush(NULL).
 * Don't invoke /usr/ccs/gcc-elf/objdump.
 *
 * Revision 1.8  1994/12/27 19:24:53  meissner
 * Make version string const.
 *
 * Revision 1.7  1994/12/27 18:40:30  meissner
 * Remove support for EM_CYGNUS_POWERPC.
 * Always print value of ehdr fields, not just symbolic name.
 * Print file modification time.
 *
 * Revision 1.6  1994/12/23 18:41:57  meissner
 * Add EM_PPC (powerpc) support.
 *
 * Revision 1.5  1994/12/21 17:47:32  meissner
 * Compile cleanly with -Wall on unixware.
 *
 * Revision 1.4  1994/12/21 17:44:27  meissner
 * Make -Wall silent on Suns.
 *
 * Revision 1.3  1994/12/21 16:32:32  meissner
 * Add elf.h declarations from System V ABI.
 * Make work on SPARC.
 * If NO_MMAP is defined, don't use mmap.
 * Add cygnus local declarations.
 *
 * Revision 1.2  1994/12/20 21:14:03  meissner
 * Move OSF changelog to separate comment.
 *
 * Revision 1.1  1994/12/20 21:11:44  meissner
 * Initial version.
 */
/*
 * Changes made at Open Software Foundation.
 *
 * Revision 1.1.2.32  1994/04/08  17:10:34  meissner
 *      Correctly print out .lprofil sections when a double word count is used.
 *      [1994/04/08  17:10:25  meissner]
 *
 * Revision 1.1.2.31  1994/04/07  13:56:54  meissner
 *      Range check section section index in get_section_name.
 *      Add program header regions to vm/file map printout.
 *      [1994/04/07  13:56:44  meissner]
 *
 * Revision 1.1.2.30  1994/03/17  13:28:57  meissner
 *      Cut down on more spaces in output.
 *      Print section name instead of number in symbol.
 *      If -e, add linker generated symbols in vm layout.
 *      Indicate where there are holes in the file/vm layout.
 *      Don't print profil buckets that are 0.
 *      [1994/03/17  13:28:49  meissner]
 *
 * Revision 1.1.2.29  1994/03/16  22:27:11  meissner
 *      Print out layout information for the ELF file and virtual memory.
 *      Check layouts printed for overlaps.
 *      Print out end offsets in the program headers.
 *      Lowercase section flags.
 *      Cut down on symbol line length.
 *      [1994/03/16  22:27:02  meissner]
 *
 * Revision 1.1.2.28  1994/03/16  18:25:24  meissner
 *      Align summary fields of section headers.
 *      Print out end+1 offset in section headers.
 *      Always print all section header fields.
 *      Skip profiling sections if -p.
 *      [1994/03/16  18:25:14  meissner]
 *
 * Revision 1.1.2.27  1994/03/11  22:35:01  chasb
 *      Expand Copyrights
 *      [1994/03/09  19:43:03  chasb]
 *
 * Revision 1.1.2.26  1994/02/28  21:36:34  meissner
 *      Correctly print out profil lowpc.
 *      [1994/02/28  21:36:24  meissner]
 *
 * Revision 1.1.2.25  1994/02/25  16:55:19  meissner
 *      Add support for printing profile stats on OSF/1.
 *      Allow unsigned long in addition to int for profil sizes.
 *      [1994/02/25  16:55:11  meissner]
 *
 * Revision 1.1.2.24  1993/12/23  01:18:10  meissner
 *      On OSF/1 print the uarea for profiling ELF files.
 *      [1993/12/23  01:18:03  meissner]
 *
 * Revision 1.1.2.23  1993/11/22  21:14:23  meissner
 *      Add -v option to print the version string.
 *      [1993/11/22  21:14:16  meissner]
 *
 * Revision 1.1.2.22  1993/11/22  21:00:50  meissner
 *      Don't print section name for reloc to defined symbol, print symbol name.
 *      [1993/11/22  21:00:42  meissner]
 *
 * Revision 1.1.2.21  1993/11/11  21:40:27  meissner
 *      Correctly align gprof/prof output.
 *      Don't print profil ticks in hex.
 *      [1993/11/11  21:40:12  meissner]
 *
 * Revision 1.1.2.20  1993/11/11  21:29:19  meissner
 *      CR 77 - Add profile output support.
 *      [1993/11/11  21:29:06  meissner]
 *
 * Revision 1.1.2.19  1993/10/15  18:55:56  meissner
 *      Fix mmap call to set the MAP_PRIVATE flag.
 *      [1993/10/15  18:55:44  meissner]
 *
 * Revision 1.1.2.18  1993/09/23  21:52:22  meissner
 *      Treat .debug_sfnames as a string section.
 *      [1993/09/23  21:52:09  meissner]
 *
 * Revision 1.1.2.17  1993/09/23  21:29:12  meissner
 *      Skip printing null bytes in string sections, except for the first byte.
 *      [1993/09/23  21:28:58  meissner]
 *
 * Revision 1.1.2.16  1993/09/23  21:21:20  meissner
 *      Print .stabstr section as strings.
 *      Know about .stab section special format.
 *      [1993/09/23  21:21:07  meissner]
 *
 * Revision 1.1.2.15  1993/09/08  22:32:47  meissner
 *      CR 62: Add -t {d,o,x} to specify output formats.
 *      [1993/09/08  22:32:35  meissner]
 *
 * Revision 1.1.2.14  1993/07/27  20:37:07  meissner
 *      Print 386 relocations in symbolic format.
 *      [1993/07/27  20:36:52  meissner]
 *
 * Revision 1.1.2.13  1993/07/23  15:07:30  meissner
 *      Add definition of STT_STABS if not provided in elf.h.
 *      Remove ifdefs of STT_STABS elsewhere.
 *      If -d, invoke objdump -d -j <section> to disassemble executable sections.
 *      [1993/07/23  15:07:12  meissner]
 *
 * Revision 1.1.2.12  1993/07/21  01:33:23  meissner
 *      Print stabs type symbolically, not numerically.
 *
...

read more »

 
 
 

C/elf library and object formats?

Post by Russell Johnsto » Fri, 22 Mar 1996 04:00:00



> Yo can anyone suggest suitable references and or sources for file
> formats for C librarys and object files. Particularly elf format

You want to go to
  <ftp://tsx-11.mit.edu/pub/linux/packages/GCC/>
and get "elf.ps.gz" (the complete file format description) and/or
"ELF.doc.tar.gz" (H.J. Lu's description of what it all means to us
as programmers).

Quote:> SORRY if this is considered strictly a C news group thing.
> I did'nt think they would be linux specific enough.

Actually it seems more Linux-specific to me.  We're the ones who
chose this file format, right?

Cheers,
Russell Johnston