From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id C5C233858417; Sun, 9 Jan 2022 17:45:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C5C233858417 Received: by mail-pj1-x1035.google.com with SMTP id g11-20020a17090a7d0b00b001b2c12c7273so8500566pjl.0; Sun, 09 Jan 2022 09:45:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gbeQ+1+ZVXKEiZrUylJBf3iQaeA0H+ohYRc/ttdSZLY=; b=VjD82lNMgPDpGSeLOH2k9JrkFbDjNB4pcPn3hYYjIWKFGK1v63snhV2VvwyDGIWlGx CIOivFoaXU6wBQMTt1VWh6/RRzINU14/EjZNI8aDpSwEMGXbUH3HHlC5xUj2rBP27J6E xhUtz10LrPdzBOIjTSBvyypfYv/l1CPGIQLdn1IjIjpkef0hPJUmrWrnOkmHgx7csIF0 uTR5jR6GgFvta3CG1TxkpgyjL3A+uGsFMP8YlRTo0vGMuhyuiH8PQ41x1SGQQlbJ1VLi JqirHlwmKm4x6rB3fyshm9DHTmAJagk6rMxLSLczzoS4JEHEBHvoAfmxYiWWNdMthdUg /cyA== X-Gm-Message-State: AOAM530HNNBq4JFeEuu+mqoPYo3RSA//E8ybTU2z9VrOrxbpfTwJlfyP 0P00irT+EI3oPthGrFVpvzc= X-Google-Smtp-Source: ABdhPJwFRUAkZ+oFgGfbIEsBtqZ7P4MaxN0NElvdUqGV+tCw0rUQeB8zEqzJz+yF7swq6+dNka/Fkw== X-Received: by 2002:a17:90a:4b45:: with SMTP id o5mr15949299pjl.121.1641750305669; Sun, 09 Jan 2022 09:45:05 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id g19sm4378286pfv.19.2022.01.09.09.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 09:45:05 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 30135C0730; Sun, 9 Jan 2022 09:45:04 -0800 (PST) From: "H.J. Lu" To: binutils@sourceware.org Cc: gdb-patches@sourceware.org, Fangrui Song Subject: [gdb-11-branch: Patch 2/3] readelf: Support SHT_RELR/DT_RELR for -r Date: Sun, 9 Jan 2022 09:45:03 -0800 Message-Id: <20220109174504.1120244-3-hjl.tools@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220109174504.1120244-1-hjl.tools@gmail.com> References: <20220109174504.1120244-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3028.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jan 2022 17:45:10 -0000 From: Fangrui Song 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