From patchwork Fri Dec 4 12:51:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 41301 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 707FB397304B; Fri, 4 Dec 2020 12:51:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 707FB397304B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607086268; bh=jVrwLuStCIXPjoHkhLN+yS26ChrJbH5YTQKopbR+ZpM=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Pxw8j9Rx67cE+nAoYN7sBtYgvniPULwIUx7dlDR2drPXVBSBmCpGRi9NltnJmFtNl o1uADvqx21pRL0ZXb0By1vS4+rB1oYXESL+wbPFF3XHUFkjSFyEQVPY4w9yLbS2Qqg mGBEouwgSJ3dk5YYPvRN5z3U5FrEQF5AYFSMuplU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 0F3773973028 for ; Fri, 4 Dec 2020 12:51:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0F3773973028 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-CaqMR12yO_WwVSrkQeEqdA-1; Fri, 04 Dec 2020 07:51:04 -0500 X-MC-Unique: CaqMR12yO_WwVSrkQeEqdA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 595FF9CC03 for ; Fri, 4 Dec 2020 12:51:03 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE71D620D7 for ; Fri, 4 Dec 2020 12:51:02 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v3 2/3] scripts/localplt.awk: Handle DT_JMPREL with empty PLT (for C-SKY) In-Reply-To: <5472b914e28766d11f2622f34b328088792cf550.1607085588.git.fweimer@redhat.com> References: <5472b914e28766d11f2622f34b328088792cf550.1607085588.git.fweimer@redhat.com> Message-Id: <409d1db377e15aa4c8e7c60752afe94b4be1ad23.1607085588.git.fweimer@redhat.com> Date: Fri, 04 Dec 2020 13:51:01 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On csky-linux-gnuabiv2, binutils 2.33 produces a DT_JMPREL entry for the dynamic loader if it does not contain any PLT relocations: Dynamic section at offset 0x1df48 contains 19 entries: Tag Type Name/Value 0x0000000e (SONAME) Library soname: [ld-linux-cskyv2-hf.so.1] 0x00000004 (HASH) 0xd4 0x6ffffef5 (GNU_HASH) 0x1a8 0x00000005 (STRTAB) 0x4ac 0x00000006 (SYMTAB) 0x28c 0x0000000a (STRSZ) 527 (bytes) 0x0000000b (SYMENT) 16 (bytes) 0x00000003 (PLTGOT) 0x1f000 0x00000002 (PLTRELSZ) 0 (bytes) 0x00000014 (PLTREL) RELA 0x00000017 (JMPREL) 0xaa4 0x00000007 (RELA) 0x75c 0x00000008 (RELASZ) 840 (bytes) 0x00000009 (RELAENT) 12 (bytes) 0x6ffffffc (VERDEF) 0x700 0x6ffffffd (VERDEFNUM) 3 0x6ffffff0 (VERSYM) 0x6bc 0x6ffffff9 (RELACOUNT) 68 0x00000000 (NULL) 0x0 This confuses the script: Unexpected output from check-localplt: …/elf/ld.so.jmprel: *** DT_JMPREL does not match any section's address This commit changes the script to record the DT_PLTRELSZ value and reject DT_JMPREL values not a section boundary only if DT_PLTRELSZ is present with a non-zero value. --- v3: Trivial rebase to current master. scripts/localplt.awk | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/localplt.awk b/scripts/localplt.awk index beaa342922..fe79ca01ab 100644 --- a/scripts/localplt.awk +++ b/scripts/localplt.awk @@ -4,17 +4,25 @@ # It writes "NAME: SYMBOL" for each PLT entry in NAME that refers to a # symbol defined in the same object. -BEGIN { result = 0 } +BEGIN { + result = 0; + pltrelsize = -1; +} FILENAME != lastfile { if (lastfile && jmprel_offset == 0 && rela_offset == 0 && rel_offset == 0) { print FILENAME ": *** failed to find expected output (readelf -WSdr)"; result = 2; } + if (pltrelsz > 0 && jmprel_offset == -1) { + print FILENAME ": Could not find section for DT_JMPREL"; + result = 2; + } lastfile = FILENAME; jmprel_offset = 0; rela_offset = 0; rel_offset = 0; + pltrelsz = -1; delete section_offset_by_address; } @@ -82,12 +90,16 @@ $2 == "(JMPREL)" { if (jmprel_addr in section_offset_by_address) { jmprel_offset = section_offset_by_address[jmprel_addr]; } else { - print FILENAME ": *** DT_JMPREL does not match any section's address"; - result = 2; + jmprel_offset = -1 } next } +$2 == "(PLTRELSZ)" { + pltrelsz = strtonum($3); + next +} + $2 == "(RELA)" { rela_addr = strtonum($3); if (rela_addr in section_offset_by_address) {