From patchwork Fri Jan 7 19:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 49728 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF5E53857C6D for ; Fri, 7 Jan 2022 19:15:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF5E53857C6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1641582934; bh=AXjjkasH7faV5aH60uMlhgSb57580VT8sl60JwcF/h4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=L9J1PKxa5ZJQwOLIMKIEBRzPF7R9j18CxNJsfM41gLixe2kjj9U3xuTicLsO2rVQr u6rCuIU+1CRXUcEwI8bXbDyGQP9XwXjxe3SiSTGe5GVM9OR2nwshoFz1J/rjlmy6Ge z7NK7K5FXXHUx0s22j5oblB/uKx5CApGJFOg4YAQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 518243858412; Fri, 7 Jan 2022 19:06:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 518243858412 Received: by mail-pj1-x1035.google.com with SMTP id lr15-20020a17090b4b8f00b001b19671cbebso7260310pjb.1; Fri, 07 Jan 2022 11:06:36 -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=AXjjkasH7faV5aH60uMlhgSb57580VT8sl60JwcF/h4=; b=ijHPBHDVbk/t9HcdUhQWH85poJcOsdk++XWLdZjhzZzqmCKe2g+Gdenf6q5awFdzA3 ezEz/fgs7e75A9Eoy0k63nUIYCnJsMbH2HQryupIhl4KDgJDsLaeZRwGeYy7JumcmceT zv6qWb/XCbHCaF07rDE9rZ/8kUQ2K9W3C1hOdBrxmJfr0R2hs9rAfvr/MKgS25+nuC+o HFdXOcNQPqKQ3kofO8OJXxXW10B2ICYyMXs9v67ADXysuoqtA1B49/m/AC0zi9cSb3Ov QIqemWyoduWH3xF462NuCGndzsW8hLRKbOmWIOzMDqrWG4KGvQHs2UBaKh+MUHYHbkg7 Yd3g== X-Gm-Message-State: AOAM5327oM+62R1M98L0nEGHZPyuwFmSncC8JPVv5lrcMKeY8OjnpNHP ly9QWTFYZ5yhdmwb0ueYt9U= X-Google-Smtp-Source: ABdhPJxBD7t2ojKhPxOz74izPqqLhlEIIU1WF0TgyEk8qzxYYAUp/DDrTHxxUgEEuQqcd/EE7EpQ2g== X-Received: by 2002:a17:902:e549:b0:149:22b4:530c with SMTP id n9-20020a170902e54900b0014922b4530cmr62658560plf.17.1641582395291; Fri, 07 Jan 2022 11:06:35 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id s25sm6312754pfg.208.2022.01.07.11.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 11:06:34 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 55BC9C0EE2; Fri, 7 Jan 2022 11:06:32 -0800 (PST) To: binutils@sourceware.org Subject: [PATCH 09/10] ld: Add simple DT_RELR tests Date: Fri, 7 Jan 2022 11:06:30 -0800 Message-Id: <20220107190631.309790-10-hjl.tools@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220107190631.309790-1-hjl.tools@gmail.com> References: <20220107190631.309790-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3028.9 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: libc-alpha@sourceware.org, Nick Clifton , Alan Modra Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" * 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 .* +#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 .* +#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