Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jan 2000 12:19:02 -0800
From:      "Ronald F. Guilmette" <rfg@monkeys.com>
To:        James Howard <howardjp@wam.umd.edu>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: libelf and Elf Interface Routines 
Message-ID:  <54934.947881142@monkeys.com>
In-Reply-To: Your message of Fri, 14 Jan 2000 08:34:15 -0500. <Pine.GSO.4.21.0001140830170.5488-100000@rac3.wam.umd.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help

In message <Pine.GSO.4.21.0001140830170.5488-100000@rac3.wam.umd.edu>, 
James Howard <howardjp@wam.umd.edu> wrote:

>I was playing with a program written for Solaris to see if I could port it
>to FreeBSD (another learning experience thing;).  The program uses
>Solaris's libelf to talk to Elf files.  It does this quite extensively in
>fact.  Does FreeBSD provide a similar interface?  Poking around the man
>pages has revealed nothing but I wanted to ask before I gave up.  If no
>interface is currently provided, is there one currently being planned?
>
>Thank you, Jamie

The original libelf code was/is owned by, and developed by AT&T's Unix
Systems Group (USG) which AT&T sold to (I think) Novell and which Novell
then sold to SCO.

Bottom line is that the _real_ libelf is proprietary code.

FreeBSD (and Linux, and ...) all use GNU software development tools, and
some of theese tools that need to diddle around with low-level object
file bits and pieces (e.g. the GNU linker and also gdb) were converted
some time ago to use a marvelous <*snicker*> format-independent object file
access/diddling library that was created by Cygnus Support (now Cygnus
Solutions) called "libbfd".  (I never asked what the letters B-F-D stood
for.  I always figured that they had the obvious meaning. :-)

Anyway, you could probably use libbfd to do what you want.  It's coplefted,
and available (I believe) at ftp.gnu.org/pub/gnu but you'll probably find
a fresher version somewhere on Cygus's ftp site.  (Start at www.cygnus.com
and then scrounge around till you find it.)

Hummm... I just tried doing a "locate" to see if this library was already
installed on my FreeBSD 3.3 system, and it _did_ find it, but it looks
like it is mixed in with the Linux compatability stuff:

    /usr/compat/linux/usr/lib/libbfd.a

I dunno how well that will work if you are not running in Linux compatability
mode, so you probably want to fetch a fresh set of sources for libbfd and
build it yourself on/for FreeBSD.

So the good news is that there _is_ an object file access library that you
may be able to use to fish out (or create) bits and pieces of ELF object
files.

The bad news is that because libbfd was designed to be independent of any
single object file format, the API for it is (in my opinion) really rather
ugly and complicated, and certainly a lot less simple than the API for
libelf, which only had to deal with ELF format files.

Anyway, pragmatically speaking, ELF format object files are really fairly
simple anyway, and depending upon the complexity of what you want to do,
you may not need an access library at all.  You could perhaps just hand
code the operations that you need yourself from scratch.  ELF files are
really quite simple to pick apart... *if* you have the ELF spec.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54934.947881142>