public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: YunQiang Su <wzssyqa@gmail.com>
To: binutils <binutils@sourceware.org>,
	Libc-alpha <libc-alpha@sourceware.org>
Subject: The definition of ELF64_MIPS_R_TYPE is ambiguous
Date: Sun, 23 Jul 2023 12:52:18 +0800	[thread overview]
Message-ID: <CAKcpw6UjNkw8Z6m0=_w1NhWpap1WhjrVUzyRKc+J4bynB3zhcA@mail.gmail.com> (raw)

With some search of the definition of ELF64_MIPS_R_TYPE macro, we find
that they are defined differently between projects.
http://codesearch.debian.net/search?q=ELF64_MIPS_R_TYPE

1. In binutils-gdb/include/elf/mips.h, it is defined as:
    #define ELF64_MIPS_R_TYPE(i) ((i) & 0xff)

    newlib/include/elf/elf.h, linux/scripts/mod/modpost.h, libiberty,
are using a similar definition.

2. In glibc/sysdeps/mips/ldsodefs.h, it is defined as:
    #define ELF64_MIPS_R_TYPE(i) \
  (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \
   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
                   ).r_info_fields.r_type2 << 8) \
   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
                   ).r_info_fields.r_type3 << 16) \
   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
                  ).r_info_fields.r_ssym << 24))

   uclibc/ldso/ldso/mips/dl-sysdep.h is using a similar definition.


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.
Any suggestions?

For myself, I prefer the way of glibc/uclibc:
1. Define ELF64_MIPS_R_TYPE1 for the lowest byte of r_info.
2. Define ELF64_MIPS_R_TYPE for full r_info.

             reply	other threads:[~2023-07-23  4:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-23  4:52 YunQiang Su [this message]
2023-07-23  6:51 ` Andreas Schwab
2023-07-23  7:11   ` YunQiang Su
2023-07-23  7:18     ` Andreas Schwab
2023-08-07 11:09       ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKcpw6UjNkw8Z6m0=_w1NhWpap1WhjrVUzyRKc+J4bynB3zhcA@mail.gmail.com' \
    --to=wzssyqa@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).