[GSoC] libelf license

Landon J Fuller landonf at macports.org
Fri Jun 24 21:39:17 PDT 2011


On Jun 24, 2011, at 9:02 PM, Clemens Lang wrote:

> On Fri, Jun 24, 2011 at 08:56:13PM -0400, Landon J Fuller wrote:
>> What is required from libelf? Since basic parsing of the Mach-O header
>> is a pretty straight-forward task, it may be possible to avoid an
>> external library entirely here. I'd also be happy to help with any
>> GSoC implementation questions; dylib load/id LC_CMDs, etc.
> 
> I'm not sure what Felipe needs from libelf, so I can't answer that
> question.
> 
> I personally will need a list of libraries a binary links against with
> they versions and compatibility version; I guess that counts as basic
> parsing, but reusing what otool already has still seems easier and
> especially is better tested and maintained than writing something on our
> own here. That being said, I'm still waiting for reply from Apple legal
> on that topic.

Well, for what it's worth, I dashed together a quick example of extracting the dyld information from Mach-O files (including handling universal binaries):
	https://gist.github.com/1046134

You can build it as follows:
	gcc -std=gnu99 -Wall -Werror macho.c -o macho

It accepts a single path argument:
	./macho /bin/ls
	./macho /usr/lib/libSystem.dylib

The code extracts (and prints to stdout):
	- The dyld identifier, if any.
	- Any dyld references (including weak and re-exported references).
	- The binary's run path entries (@rpath). These are required to resolve @rpath-relative dyld library references.

It's straight C with no dependencies; minus the printf()s, it should hopefully be adaptable for use in base.

Cheers,
-landonf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: macho.c
Type: application/octet-stream
Size: 8954 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20110625/618505e6/attachment.obj>


More information about the macports-dev mailing list