What size-dependent parts of bfd/elfcode.h are undesirable?
H.J. Lu
hjl.tools@gmail.com
Thu Apr 9 18:56:56 GMT 2020
On Thu, Apr 9, 2020 at 11:28 AM Jozef Lawrynowicz
<jozef.l@mittosystems.com> wrote:
>
> There is a comment at the top of bfd/elfcode.h:
>
> > (2) The code in this file is compiled twice, once in 32-bit mode and
> > once in 64-bit mode. More of it should be made size-independent
> > and moved into elf.c.
> >
>
> If I am adding a new ELF type which has 32 and 64-bit versions and has similar
> requirements to relocation entries, is it ok to copy much of the implementation
> required to support Elf_External_Rel for my new type? i.e. swap_{in,out}
> functions, size-independent mappings of external types
> (Elf_External_Rel -> Elf{32,64_External_Rel}) and field accessors
> (ELF_R_INFO -> Elf{32,64}_R_INFO).
>
> Is there a new recommended way to do something like this, or is the comment
> referring to some other parts of the size-dependent implementation?
>
> Thanks,
> Jozef
Please take a look at elf_append_rel and elf_append_rela. The same
function is used for both 32bit and 64bit ELF.
--
H.J.
More information about the Binutils
mailing list