This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [lto] add direct-to-ELF serialization to lto1


On 2008-06-26, Ollie Wild <aaw@google.com> wrote:
> On Thu, Jun 26, 2008 at 5:48 AM, Diego Novillo <dnovillo@google.com> wrote:
>  >
>
> > I don't understand this.  Why not use langhooks instead of using another hook mechanism?  It's the same thing, but it seems to me that it'd be more natural to just use the langhooks harness that we already have.
>
>
> One reason is because we will likely end up with multiple
>  implementations for the various object file formats (think Apple).
>  Having a dynamic registration facility simplifies this.  Otherwise,
>  the langhooks will end up being replaced by switch statements which
>  call the *real* langhooks.

But in this case, we simply conditionally #define the langhooks for
each target format.   So, in langhooks-def.h we define
L_H_BEGIN_SECTION, L_H_WRITE_SECTION_DATA and L_H_END_SECTION to the
default (empty) versions.

In lto/lto-lang.c we conditionally define them based on the target
format, something like

#if defined OBJECT_FORMAT_ELF
#define LANG_HOOKS_BEGIN_SECTION elf_begin_section
...
#endif

Does this make sense?


Diego.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]