From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by sourceware.org (Postfix) with ESMTPS id 82E113857C7F; Sat, 8 Jan 2022 02:39:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 82E113857C7F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f50.google.com with SMTP id oa15so5911704pjb.4; Fri, 07 Jan 2022 18:39:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Kjr3ERxWIywrWCWKbRuI+hn29yPCEe2Ot1W92BH/Shk=; b=P/scNn7FyIGfH6jdM6pZCJTlwhnFjVNGudQ0A+r68b7yEwvESdDSGufwRtos4N7GHi 3hI/8Uwp6Oalt4iE2fN84ZDhL07cYOHzjRsWy93yT46C5mLovpv30BgWB2v+1mSW3tx0 CEI7RyJq8s7mXnb/fE03ZIJzcoMY2gahg9fcXxmHTdn3Ic+im8a60PUm2EUClp4zPbcT UjP3zW/+CrhZ60claWBewewIQOMnPT31/qHPD3/XclI+3CGTe50kmGY3LGxKDX+UXR/S M+VPqM+Wrwe/baCgtuezrz8YwQctI6OQcM1WY0lDdRJaN2wPBR+iYwgKZp2A9WfLiaXk EesQ== X-Gm-Message-State: AOAM531rublX316h8Xo/9A6eUdAXTQiWohDJ/v65pbB8fsQOL9BKiDjf BiLwQMGpti6eOLO7LFgKmaFrfqU07XM= X-Google-Smtp-Source: ABdhPJyf3hpsRrepMPwIGHGnHy3L9u8GbK/HJ7wAiXwmGfXQgSE+A+JSoS294fY2r0pcbTuEbTUk0A== X-Received: by 2002:a17:902:a409:b0:149:28e8:8e80 with SMTP id p9-20020a170902a40900b0014928e88e80mr65872852plq.56.1641609598654; Fri, 07 Jan 2022 18:39:58 -0800 (PST) Received: from localhost ([2601:647:6300:b760:954:a2bf:9e0e:b531]) by smtp.gmail.com with ESMTPSA id h22sm232822pfv.1.2022.01.07.18.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 18:39:58 -0800 (PST) Date: Fri, 7 Jan 2022 18:39:57 -0800 From: Fangrui Song To: "H.J. Lu" Cc: binutils@sourceware.org, libc-alpha@sourceware.org Subject: Re: [PATCH 09/10] ld: Add simple DT_RELR tests Message-ID: <20220108023957.7s6km6bmkummlv2z@gmail.com> References: <20220107190631.309790-1-hjl.tools@gmail.com> <20220107190631.309790-10-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220107190631.309790-10-hjl.tools@gmail.com> X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jan 2022 02:40:01 -0000 On 2022-01-07, H.J. Lu via Binutils wrote: > * testsuite/ld-elf/dt-relr-1.s: New file. > * testsuite/ld-elf/dt-relr-1a.d: Likewise. > * testsuite/ld-elf/dt-relr-1b.d: Likewise. > * testsuite/ld-elf/dt-relr-1c.d: Likewise. > * testsuite/ld-elf/dt-relr-2.s: Likewise. > * testsuite/ld-elf/dt-relr-2a.d: Likewise. > * testsuite/ld-elf/dt-relr-2b.d: Likewise. > * testsuite/ld-elf/dt-relr-2c.d: Likewise. > * testsuite/ld-elf/dt-relr-2d.d: Likewise. > * testsuite/ld-elf/dt-relr-2e.d: Likewise. > * testsuite/ld-elf/dt-relr-2f.d: Likewise. > * testsuite/ld-elf/dt-relr-2g.d: Likewise. > * testsuite/ld-elf/dt-relr-2h.d: Likewise. >--- > ld/testsuite/ld-elf/dt-relr-1.s | 13 +++++++++++++ > ld/testsuite/ld-elf/dt-relr-1a.d | 10 ++++++++++ > ld/testsuite/ld-elf/dt-relr-1b.d | 9 +++++++++ > ld/testsuite/ld-elf/dt-relr-1c.d | 9 +++++++++ > ld/testsuite/ld-elf/dt-relr-2.s | 20 ++++++++++++++++++++ > ld/testsuite/ld-elf/dt-relr-2a.d | 10 ++++++++++ > ld/testsuite/ld-elf/dt-relr-2b.d | 17 +++++++++++++++++ > ld/testsuite/ld-elf/dt-relr-2c.d | 17 +++++++++++++++++ > ld/testsuite/ld-elf/dt-relr-2d.d | 9 +++++++++ > ld/testsuite/ld-elf/dt-relr-2e.d | 9 +++++++++ > ld/testsuite/ld-elf/dt-relr-2f.d | 8 ++++++++ > ld/testsuite/ld-elf/dt-relr-2g.d | 9 +++++++++ > ld/testsuite/ld-elf/dt-relr-2h.d | 9 +++++++++ > 13 files changed, 149 insertions(+) > create mode 100644 ld/testsuite/ld-elf/dt-relr-1.s > create mode 100644 ld/testsuite/ld-elf/dt-relr-1a.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-1b.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-1c.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2.s > create mode 100644 ld/testsuite/ld-elf/dt-relr-2a.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2b.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2c.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2d.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2e.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2f.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2g.d > create mode 100644 ld/testsuite/ld-elf/dt-relr-2h.d > >diff --git a/ld/testsuite/ld-elf/dt-relr-1.s b/ld/testsuite/ld-elf/dt-relr-1.s >new file mode 100644 >index 00000000000..18486d3acb2 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-1.s >@@ -0,0 +1,13 @@ >+ .text >+ .p2align 3 >+ .globl _start >+_start: >+ .byte 0 >+ >+ .data >+ .p2align 3 >+ .globl data >+data: >+ .byte 0 >+ // Offset is not a multiple of 2. Don't use DT_RELR. >+ .dc.a __ehdr_start + 10 >diff --git a/ld/testsuite/ld-elf/dt-relr-1a.d b/ld/testsuite/ld-elf/dt-relr-1a.d >new file mode 100644 >index 00000000000..55c93cefb59 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-1a.d >@@ -0,0 +1,10 @@ >+#source: dt-relr-1.s >+#ld: -e _start $DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#... >+There is no dynamic section in this file. >+#... >+There are no relocations in this file. >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-1b.d b/ld/testsuite/ld-elf/dt-relr-1b.d >new file mode 100644 >index 00000000000..2b78f75d378 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-1b.d >@@ -0,0 +1,9 @@ >+#source: dt-relr-1.s >+#ld: -e _start -pie $DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#failif >+#... >+Relocation section '\.relr\.dyn' at offset .* Worth testing "contains XX entries" and "YY offsets". >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-1c.d b/ld/testsuite/ld-elf/dt-relr-1c.d >new file mode 100644 >index 00000000000..14f6cda6832 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-1c.d >@@ -0,0 +1,9 @@ >+#source: dt-relr-1.s >+#ld: -shared $DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#failif >+#... >+Relocation section '\.relr\.dyn' at offset .* Worth testing "contains XX entries" and "YY offsets". >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2.s b/ld/testsuite/ld-elf/dt-relr-2.s >new file mode 100644 >index 00000000000..c3917ee8c3a >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2.s >@@ -0,0 +1,20 @@ >+ .text >+ .p2align 3 >+ .globl _start >+_start: >+ .byte 0 >+ >+ .data >+ .p2align 3 >+ .globl data >+data: >+ >+ .dc.a .data >+ .dc.a 0 >+ .dc.a data + 2 >+ .dc.a __ehdr_start + 4 >+ .dc.a __ehdr_start + 9 >+ >+ .byte 0 >+ // Offset is not a multiple of 2. Don't use DT_RELR. >+ .dc.a __ehdr_start + 10 >diff --git a/ld/testsuite/ld-elf/dt-relr-2a.d b/ld/testsuite/ld-elf/dt-relr-2a.d >new file mode 100644 >index 00000000000..31ef9e8e80e >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2a.d >@@ -0,0 +1,10 @@ >+#source: dt-relr-2.s >+#ld: -e _start $DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#... >+There is no dynamic section in this file. >+#... >+There are no relocations in this file. >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2b.d b/ld/testsuite/ld-elf/dt-relr-2b.d >new file mode 100644 >index 00000000000..7c401732a56 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2b.d >@@ -0,0 +1,17 @@ >+#source: dt-relr-2.s >+#ld: -e _start -pie $DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#... >+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+ >+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\) >+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\) >+#... >+Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains 1 entry: >+#... >+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .* >+#... >+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: >+ 4 offsets >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2c.d b/ld/testsuite/ld-elf/dt-relr-2c.d >new file mode 100644 >index 00000000000..63877b2f90f >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2c.d >@@ -0,0 +1,17 @@ >+#source: dt-relr-2.s >+#ld: -shared $DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#... >+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+ >+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\) >+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\) >+#... >+Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: >+#... >+[0-9a-f]+ +[0-9a-f]+ +R_.*_RELATIVE .* >+#... >+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: >+ 3 offsets >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2d.d b/ld/testsuite/ld-elf/dt-relr-2d.d >new file mode 100644 >index 00000000000..270a901f1a6 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2d.d >@@ -0,0 +1,9 @@ >+#source: dt-relr-2.s >+#ld: -e _start -pie $DT_RELR_LDFLAGS --no-relax >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#failif >+#... >+Relocation section '\.relr\.dyn' at offset .* >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2e.d b/ld/testsuite/ld-elf/dt-relr-2e.d >new file mode 100644 >index 00000000000..79ea62b096a >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2e.d >@@ -0,0 +1,9 @@ >+#source: dt-relr-2.s >+#ld: -e _start -pie $DT_RELR_LDFLAGS -z nocombreloc >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#failif >+#... >+Relocation section '\.relr\.dyn' at offset .* >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2f.d b/ld/testsuite/ld-elf/dt-relr-2f.d >new file mode 100644 >index 00000000000..4ad592f71fb >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2f.d >@@ -0,0 +1,8 @@ >+#source: dt-relr-2.s >+#ld: -r $DT_RELR_LDFLAGS >+#readelf: -rW >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#... >+Relocation section '\.rel(a|)\.data' at offset 0x[0-9a-f]+ contains 5 entries: >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2g.d b/ld/testsuite/ld-elf/dt-relr-2g.d >new file mode 100644 >index 00000000000..78e370068af >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2g.d >@@ -0,0 +1,9 @@ >+#source: dt-relr-2.s >+#ld: -e _start -pie $NO_DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#failif >+#... >+Relocation section '\.relr\.dyn' at offset .* >+#pass >diff --git a/ld/testsuite/ld-elf/dt-relr-2h.d b/ld/testsuite/ld-elf/dt-relr-2h.d >new file mode 100644 >index 00000000000..312373fb179 >--- /dev/null >+++ b/ld/testsuite/ld-elf/dt-relr-2h.d >@@ -0,0 +1,9 @@ >+#source: dt-relr-2.s >+#ld: -e _start -shared $NO_DT_RELR_LDFLAGS >+#readelf: -rW -d >+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* >+ >+#failif >+#... >+Relocation section '\.relr\.dyn' at offset .* >+#pass >-- >2.33.1 >