From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from arjuna.pair.com (arjuna.pair.com [209.68.5.131]) by sourceware.org (Postfix) with ESMTPS id 83DC13858D1E for ; Thu, 22 Feb 2024 03:13:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83DC13858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bitrange.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bitrange.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 83DC13858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.68.5.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708571634; cv=none; b=eyhpcHdR3c/96At9U22y87yHUiO5nWW6Pc0hRWa2qBPc3kekVKNOCZrEugmyt46H7eEIBtQuTTXLRKPk+lr7yVXirUsNNHFen36vTK1cgq34yxBhWRUMO1BdpyyE9FddNotiPjwpyWGVf4cnxEXBFsO4Q5MUlxchYGrImwhMbvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708571634; c=relaxed/simple; bh=e0Db2OxEg6GNb4g8I0K8rMK13BJNiendw+WJ9pY8he8=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=kfdSvQF+hf1LPA/8Df4u2WaO1SZlREwbN4dDNUz3gxDQUZEqSosyJDgI2i/UbybHED6MjGFIQSCyV7elEy4pnEkh/wCa0B2oOzp20668pGdew2HKmAsH0Dq1PtLDcbLntUyMKu8Ii/jYjveb1MUM4HTrNFFVOQcrj1mcLvm4Mr0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by arjuna.pair.com (Postfix, from userid 3006) id E53AB8A639; Wed, 21 Feb 2024 22:13:51 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by arjuna.pair.com (Postfix) with ESMTP id E4B5E8A521; Wed, 21 Feb 2024 22:13:51 -0500 (EST) Date: Wed, 21 Feb 2024 22:13:51 -0500 (EST) From: Hans-Peter Nilsson X-X-Sender: hp@arjuna.pair.com To: YunQiang Su cc: Nick Clifton , binutils@sourceware.org, macro@orcam.me.uk, xry111@xry111.site Subject: Re: [PATCH v6] MIPS: Reject branch absolute relocs for PIC for linking In-Reply-To: <20240221145256.3118097-1-syq@gcc.gnu.org> Message-ID: References: <20240221145256.3118097-1-syq@gcc.gnu.org> User-Agent: Alpine 2.20.16 (BSF 172 2016-09-29) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: mailmunge 3.11 on 209.68.5.131 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,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: A random comment: On Wed, 21 Feb 2024, YunQiang Su wrote: > The asm code like: > b 8 > will emit absolute relocs like: > R_MIPS_PC16 *ABS* > > If they are included into PIC shared objects or PIE executables, > the branch target will be like 0x12340000, which will make the > programs crash. > --- > bfd/elfxx-mips.c | 9 +++++++++ > ld/testsuite/ld-mips-elf/mips-elf.exp | 1 + > ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.d | 5 +++++ > ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.s | 2 ++ > 4 files changed, 17 insertions(+) > create mode 100644 ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.d > create mode 100644 ld/testsuite/ld-mips-elf/pic-reject-abs-reloc.s > > diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c > index 69dd71419ff..9542250dec4 100644 > --- a/bfd/elfxx-mips.c > +++ b/bfd/elfxx-mips.c > @@ -9258,6 +9258,15 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, > (h) ? h->root.root.string : "a local symbol"); > break; > default: > + if (branch_reloc_p (r_type) && r_symndx == STN_UNDEF) > + { > + howto = MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, NEWABI_P (abfd)); > + info->callbacks->einfo > + /* xgettext:c-format */ > + (_("%X%H: relocation %s against `*ABS*' cannot be used" There's no "*ABS*" in the source and IMHO that'd look confusing to innocent users. How about "...against an absolute value"? Or "...against an absolute value or absolute symbol"? Perhaps the latter is a bit too wordy, but also more complete. > + " when making a PIC/PIE object\n"), > + abfd, sec, rel->r_offset, howto->name); > + } > break; brgds, H-P