From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661776020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bk7HbAgmKycF6zU1hOjI4A2RDpzLsC2va4/xIube/rU=; b=CD3J1ukWEOFMZIp5IU08bkUcbKpJFdDUmkaF5mhPiEgcZJo482jo01SdG7R8KPUjAbYldI RbPUJ2QMBgmarAoOnDzduapCEFwTAz+mckRJxV6a3XJG/N5JZiTuBsnGqoLAbQYWiTUKZX wU1UOzlptwUUmuWqCC9N+h/1xlBoKug= 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) From: Florian Weimer 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 Content-Type: text/plain; charset=UTF-8; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 List-Id: 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-h= f.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: =E2=80=A6/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. --- 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. =20 -BEGIN { result =3D 0 } +BEGIN { + result =3D 0; + pltrelsize =3D -1; +} =20 FILENAME !=3D lastfile { if (lastfile && jmprel_offset =3D=3D 0 && rela_offset =3D=3D 0 && rel_of= fset =3D=3D 0) { print FILENAME ": *** failed to find expected output (readelf -WSdr)"; result =3D 2; } + if (pltrelsz > 0 && jmprel_offset =3D=3D -1) { + print FILENAME ": Could not find section for DT_JMPREL"; + result =3D 2; + } lastfile =3D FILENAME; jmprel_offset =3D 0; rela_offset =3D 0; rel_offset =3D 0; + pltrelsz =3D -1; delete section_offset_by_address; } =20 @@ -82,12 +90,16 @@ $2 =3D=3D "(JMPREL)" { if (jmprel_addr in section_offset_by_address) { jmprel_offset =3D section_offset_by_address[jmprel_addr]; } else { - print FILENAME ": *** DT_JMPREL does not match any section's address"; - result =3D 2; + jmprel_offset =3D -1 } next } =20 +$2 =3D=3D "(PLTRELSZ)" { + pltrelsz =3D strtonum($3); + next +} + $2 =3D=3D "(RELA)" { rela_addr =3D strtonum($3); if (rela_addr in section_offset_by_address) { --=20 2.37.2