[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libabigail for Mach-O?



Hello Andrew,

"Andrew C. Morrow" <andrew.c.morrow@gmail.com> a écrit:

> The OS X environment use the Mach-O format for binaries, rather than
> ELF, so that is obviously a problem - libabigail doesn't understand
> how to read that format. However, OS X does use DWARF for its
> debugging information.

Right.

> That suggests that, at least in principle, it should be possible to
> make libabigail work against a Mach-O binary if you could teach it how
> to get the dwarf info out (I'm purposefully ignoring the dsymutil
> angle here).

Right.

> I do however seem to remember seeing in discussion here recently that
> libabigail relies not only on the DWARF info in an ELF binary, but
> also does make use of the ELF info. That would make Mach-O
> considerably harder. If that is true, how strong is the dependency on
> ELF?

If you want to re-use the elf/dwarf reader that already exists in
libabigail today for Mach-O, then I guess, yes, the dependency on ELF is
very strong because the reader really goes read information from ELF
sections and whatnot.

But then bear in mind that libabigail also reads symbols, types and
declarations information from ... XML.  I mean, the XML emitted by
abidw.  I call it the ".abi" format.  This is what allows you to use
e.g, abidiff to compare an ABI expressed in XML and an ABI expressed in
ELF/DWARF.

So it's very well possible to write an entirely new reader using APIs
that are specific to your platform, be it MacOS X or Windows.

So that's the theory.

> If the same sort of info could be surfaced from a Mach-O file,
> could libabigail make use of it?

Yes, in practice, if elfutils (used by libabigail's ELF/DWARF reader
today) can be made to understand Mach-O and expose it as ELF, then that
would make things super easy from the libabigail's ELF/DWARF reader side
of things.

But then, I am not sure that's desirable from an architectural point of
view.  Rather than going through the hassle of making Mach-O look like
ELF (which it is not), why not just write a different Abigail reader
that would read Mach-O and the debug info that it contains?

> In what ways exactly does libabigail use the ELF info?

>From ELF, Libabigail gets the set of function and variable *symbols*
(and their versions) that are defined in the binary and that are
exported.  It then matches those symbols with the functions and
variables they belong to.  Those functions and variables are separately
described by the debug info.

For instance, the debug info won't tell you if the visibility of the
function is local to the binary or if its global.  That information is a
property of the symbol of the function and that symbol is an ELF
artifact.

> Where on the spectrum ranging from "trivial" to "effectively
> impossible" would this fall?

I'd say "serious" :-)  It's far from being impossible, as there are
already two different readers in the code base (they can be used as
examples).

If the binary format is well documented, I think it would take me a
month (maybe two) to have a working implementation, including the
necessary regression tests.

So it's not trivial.

I am ready to help anyone who would want to undertake this and I'll
welcome the resulting patches, of course.

I hope this helps.

Cheers,

-- 
		Dodji