From patchwork Mon Aug 29 12:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1671426 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=xO8ApHgI; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MGV7j14KCz1yg7 for ; Mon, 29 Aug 2022 22:27:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C8F93856DEC for ; Mon, 29 Aug 2022 12:27:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C8F93856DEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661776041; bh=bk7HbAgmKycF6zU1hOjI4A2RDpzLsC2va4/xIube/rU=; 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=xO8ApHgIuLUmGCkU4yybnFbhRwDK7zoomyPb0q0pzri1mwSYduYt0K3f1aCYm9LtS G05h7nP9LUPBU2QKYMN7Du+WcVFMJJxOIt3OraojZ4PfgxneBGSyDuVCDZ3YU2egbu 9iJQxDRriNS3sSf/cE+WYIgyHsPqHqYCXekoPo1w= 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D02453858D3C for ; Mon, 29 Aug 2022 12:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D02453858D3C Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470-f_DfcrrEPce-O02vcfqzHg-1; Mon, 29 Aug 2022 08:26:59 -0400 X-MC-Unique: f_DfcrrEPce-O02vcfqzHg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37AEC3C10221 for ; Mon, 29 Aug 2022 12:26:59 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.190]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB930C15BB3 for ; Mon, 29 Aug 2022 12:26:58 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v4 2/3] scripts/localplt.awk: Handle DT_JMPREL with empty PLT (for C-SKY) In-Reply-To: References: X-From-Line: b9db8689f75c8225800e006655764134e4185663 Mon Sep 17 00:00:00 2001 Message-Id: Date: Mon, 29 Aug 2022 14:26:57 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+incoming=patchwork.ozlabs.org@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. Reviewed-by: Siddhesh Poyarekar --- 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) {