public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Cc: gdb-patches@sourceware.org, Fangrui Song <maskray@google.com>
Subject: [gdb-11-branch: Patch 2/3] readelf: Support SHT_RELR/DT_RELR for -r
Date: Sun,  9 Jan 2022 09:45:03 -0800	[thread overview]
Message-ID: <20220109174504.1120244-3-hjl.tools@gmail.com> (raw)
In-Reply-To: <20220109174504.1120244-1-hjl.tools@gmail.com>

From: Fangrui Song <maskray@google.com>

The -r output for SHT_RELR looks like:

Relocation section '.relr.dyn' at offset 0x530 contains 4 entries:
  7 offsets
00000000000028c0
00000000000028c8
0000000000003ad0
0000000000003ad8
0000000000003ae0
0000000000003ae8
0000000000003af0

For --use-dynamic, the header looks like

    'RELR' relocation section at offset 0x530 contains 32 bytes:

include/
    * elf/common.h (DT_ENCODING): Bump to 38.
    * elf/external.h (Elf32_External_Relr): New.
    (Elf64_External_Relr): New.

(cherry picked from commit a7fd11862703e45d2774981a4888bc127d473b06)
---
 include/elf/common.h   | 2 +-
 include/elf/external.h | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/elf/common.h b/include/elf/common.h
index 8c6a595fea4..dff90c4d9e1 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -1053,13 +1053,13 @@
 #define DT_FINI_ARRAYSZ 28
 #define DT_RUNPATH	29
 #define DT_FLAGS	30
-#define DT_ENCODING	32
 #define DT_PREINIT_ARRAY   32
 #define DT_PREINIT_ARRAYSZ 33
 #define DT_SYMTAB_SHNDX    34
 #define DT_RELRSZ	35
 #define DT_RELR		36
 #define DT_RELRENT	37
+#define DT_ENCODING	38
 
 /* Note, the Oct 4, 1999 draft of the ELF ABI changed the values
    for DT_LOOS and DT_HIOS.  Some implementations however, use
diff --git a/include/elf/external.h b/include/elf/external.h
index b24985687e6..815e39c2837 100644
--- a/include/elf/external.h
+++ b/include/elf/external.h
@@ -211,6 +211,10 @@ typedef struct {
   unsigned char	r_addend[4];	/* Constant addend used to compute value */
 } Elf32_External_Rela;
 
+typedef struct {
+  unsigned char r_data[4];	/* RELR entry */
+} Elf32_External_Relr;
+
 typedef struct {
   unsigned char r_offset[8];	/* Location at which to apply the action */
   unsigned char	r_info[8];	/* index and type of relocation */
@@ -222,6 +226,10 @@ typedef struct {
   unsigned char	r_addend[8];	/* Constant addend used to compute value */
 } Elf64_External_Rela;
 
+typedef struct {
+  unsigned char r_data[8];	/* RELR entry */
+} Elf64_External_Relr;
+
 /* dynamic section structure */
 
 typedef struct {
-- 
2.34.1


  parent reply	other threads:[~2022-01-09 17:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 17:45 [gdb-11-branch: Patch 0/3] Support SHT_RELR (.relr.dyn) section H.J. Lu
2022-01-09 17:45 ` [gdb-11-branch: Patch 1/3] readelf: Support RELR in -S and -d and output H.J. Lu
2022-01-09 17:45 ` H.J. Lu [this message]
2022-01-09 17:45 ` [gdb-11-branch: Patch 3/3] bfd_section_from_shdr: Support SHT_RELR sections H.J. Lu
2022-01-10  2:44 ` [gdb-11-branch: Patch 0/3] Support SHT_RELR (.relr.dyn) section Simon Marchi
2022-01-10 13:03   ` H.J. Lu
2022-01-16  9:44     ` Joel Brobecker
2022-01-16 10:21       ` Joel Brobecker
2022-01-16 13:30         ` H.J. Lu

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=20220109174504.1120244-3-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=maskray@google.com \
    /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).