[llvm] r179051 - Template the MachO types over the word size.

Rafael Espíndola rafael.espindola at gmail.com
Tue Apr 16 13:12:18 PDT 2013


On 16 April 2013 15:53, Jim Grosbach <grosbach at apple.com> wrote:
> Ping.
>
> I reiterate that I have serious problems with this patch. Having not heard
> any explanation for why it’s an improvement, I want it reverted. Sooner
> rather than later, please.

Sorry, I completely missed the original reply and only now noticed this thread.

The objective of templating first on 32/64 bits and then on endianness
is to allow generic access to macho objects in the same way we have
access to elf objects. I do realize the in between states are a bit
messy, so let me explain the overall design.

>From an user perspective (say llvm-readobj), they can just template
code that needs macho specific type. Inside the template the different
data structures are easily available.

For code that is not templated, typedefs are now provided for an
easier access. For example, you can say MachOObjectFileLE64::Section
to access the section of a 64 bit little endian object.

The main win of having the templates is the ability to access little
and big endian objects without having to put an if at every memory
access.

The code is structured with a base class that is common to all 4
variants, a middle class that is common to 64 and 32 bits and the 4
base classes.

We are now able to correctly process all 4 types of objects (with
tests!), so I am now more comfortable refactoring this a bit. On the
list are

* Any missing features.
* Sharing code when possible. The relocation name logic is big on the list.
* Making more methods private.
* Moving the individual templates to a detail namespace to make it
clear that they should not be used directly.

I hope this explains what is going on.

> -Jim
>

Cheers,
Rafael




More information about the llvm-commits mailing list