The definition of ELF64_MIPS_R_TYPE is ambiguous

Maciej W. Rozycki macro@orcam.me.uk
Mon Aug 7 11:09:36 GMT 2023


On Sun, 23 Jul 2023, Andreas Schwab wrote:

> >> > I think that we should sync all of them to protect people from confusion.
> >> > We are lucky enough that ELF64_MIPS_R_TYPE is not used widely by normal APPs.
> >> > So it gives us the chance to make it sync between projects.
> >>
> >> Is the macro defined by the ELF psABI?
> >>
> >
> > As best as I know, the answer is no. (Correct me if anybody know about it.)
> 
> Then it should not be defined in any shared header related to ELF ABI
> definitions, especially not in glibc's elf.h.  It should remain private
> to each project.

 FWIW the 64-bit MIPS psABI[1] has instead redefined Elf64_Rela and 
Elf64_Rel structures (previously supplied by SPARC International with 
their 64-bit extensions to the original 32-bit ELF gABI):

typedef struct
{
  Elf64_Addr	r_offset;
  Elf64_Word	r_sym;
  Elf64_Byte	r_ssym;
  Elf64_Byte	r_type3;
  Elf64_Byte	r_type2;
  Elf64_Byte	r_type;
} Elf64_Rel;

typedef struct
{
  Elf64_Addr	r_offset;
  Elf64_Word	r_sym;
  Elf64_Byte	r_ssym;
  Elf64_Byte	r_type3;
  Elf64_Byte	r_type2;
  Elf64_Byte	r_type;
  Elf64_Sxword	r_addend;
} Elf64_Rela;

(transcribed from a language-agnostic representation).  I'm not sure if it 
can be factored in anyhow in <elf.h>.

 Observe the endianness-independent layout of the five fields following 
`r_offset', which makes macros such as ELF64_MIPS_R_TYPE unsuitable for 
use in the little-endian case with unprocessed `r_info' field as defined 
by 64-bit ELF gABI.

[1] "64-bit ELF Object File Specification", Draft Version 2.5, MIPS 
    Technologies / Silicon Graphics Computer Systems, Document Number 
    007-4658-001, Table 29 "Relocation Operation (Elf64_Rel, Elf64_Rela)", 
    p. 40

  Maciej


More information about the Libc-alpha mailing list