From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85054 invoked by alias); 18 May 2019 08:19:08 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 85046 invoked by uid 89); 18 May 2019 08:19:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: NAM02-SN1-obe.outbound.protection.outlook.com Received: from mail-eopbgr770099.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) (40.107.77.99) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 May 2019 08:19:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZ0S+KAKePYhLvRGAuhoObvxVgbfoRFZhzZ2xg2t3Ec=; b=B7Xp0+gMwaDEXfurRL7nQcJpi9Ti41ZwujZc9a6QBJ2h2QAfzFIrCrrcCbiuU07f8CnGMjwYe637mhrTUxkXPIPNs8zMSAwbMQD6mymTg93uDWqOCaNKJKwX9v4k1wAChKYHY5ZON7XrdahvZHV7b3U1a5Sf8W5NxhjxsOijjIw= Received: from DM5PR22MB0683.namprd22.prod.outlook.com (10.172.190.23) by DM5PR22MB0651.namprd22.prod.outlook.com (10.172.189.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.25; Sat, 18 May 2019 08:19:03 +0000 Received: from DM5PR22MB0683.namprd22.prod.outlook.com ([fe80::9160:9545:a33d:233d]) by DM5PR22MB0683.namprd22.prod.outlook.com ([fe80::9160:9545:a33d:233d%7]) with mapi id 15.20.1900.010; Sat, 18 May 2019 08:19:03 +0000 From: Faraz Shahbazker To: "binutils@sourceware.org" CC: Faraz Shahbazker , "paul.hua.gm@gmail.com" Subject: [PATCH 0/2] MIPS/LD: Improve error checking for relocations in shared libraries Date: Sat, 18 May 2019 08:19:00 -0000 Message-ID: <20190518081905.223364-1-fshahbazker@wavecomp.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=fshahbazker@wavecomp.com; x-ms-oob-tlc-oobclassifiers: OLM:3044; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-Type: text/plain; charset="us-ascii" Content-ID: <6005A36CDE9EE04993C0A00211CEC7B7@namprd22.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-SW-Source: 2019-05/txt/msg00229.txt.bz2 This patch series improves error checking for unacceptable non-PIC relocations when linking shared libraries. Patch 1/2 fixes problems with existing checks. There are 2 possible sites of memory faults: 1. Applying bfd_is_abs_symbol predicate on a symbol link hash entry that is NULL, as is the case for statically scoped variables. 2. Trying to dereference a relocation howto pointer for an unsupported relocation when printing the error message. Further, the search for relocations should be performed on RELA table for n64 (%higher and %highest) relocations because these are declared empty in the REL table for the n64 MIPS backend. The new tests cover all of the above issues. Patch 2/2 extends the checks to tprel_hi and tprel_lo relocations. These relocations represent the Local Exec TLS mode that may be valid for PIEs but not for shared libraries, regardless of STATIC_TLS. Notably, GCC will generate such relocations for statically scoped TLS variables in n64 mode without an explicit -fpic option and linking them without error creates a shared library which will fail at run-time. Faraz Shahbazker (2): MIPS/LD: Fix memory fault linking non-PIC object in to shared library MIPS/LD: Reject tprel_hi and tprel_lo relocations in shared library bfd/elfxx-mips.c | 31 +++++++++++++++++++++++----= ---- ld/testsuite/ld-mips-elf/mips-elf.exp | 7 +++++++ ld/testsuite/ld-mips-elf/pic-reloc-5.d | 10 ++++++++++ ld/testsuite/ld-mips-elf/pic-reloc-5.s | 22 ++++++++++++++++++++++ ld/testsuite/ld-mips-elf/pic-reloc-6.d | 11 +++++++++++ ld/testsuite/ld-mips-elf/pic-reloc-6.s | 22 ++++++++++++++++++++++ ld/testsuite/ld-mips-elf/pic-reloc-7.d | 8 ++++++++ ld/testsuite/ld-mips-elf/pic-reloc-7.s | 10 ++++++++++ ld/testsuite/ld-mips-elf/pic-reloc-tls.ld | 7 +++++++ 9 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-5.d create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-5.s create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-6.d create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-6.s create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-7.d create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-7.s create mode 100644 ld/testsuite/ld-mips-elf/pic-reloc-tls.ld --=20 2.9.5