From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EAGVBOFZXGe2dRUAWB0awg (envelope-from ) for ; Fri, 13 Dec 2024 10:59:29 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Y6jAESO8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0FE1E1E097; Fri, 13 Dec 2024 10:59:29 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DB8071E091 for ; Fri, 13 Dec 2024 10:59:26 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77872385780D for ; Fri, 13 Dec 2024 15:59:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77872385780D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Y6jAESO8 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 49B583858C51 for ; Fri, 13 Dec 2024 15:57:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49B583858C51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 49B583858C51 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734105455; cv=none; b=rwMJw9J4N8wqo8tVWNDC7zP/ZTW7+v3SG6AvFU7IXdSo4CYy5fiL/pE7PhtKPbN0WPh0Eibsp5qxcKO3ceoG8BT59Fxlk7Ux0Ay+r9CqM2XaKhKvn32zRvKpF0XWHI2kxlVtDULA9TCKIgRu6W7MbR9BmWVD4vhnb6vkd72Q7gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734105455; c=relaxed/simple; bh=GNjrWZaR2u8QPV7jSvvsp3NvK1SgGTxaoyrXha79Q10=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=P1CWVFPXCQBDd5j8zKT62wM/UvEtAL/2IrN5qqnmsuZUL4YgcOpLdhh5r2HyS5KrWVhvwM0dk0A7xocADP1QrAoZat9Xue883EEI3IASk9bC0m0TDv98KI5JAVsMCI508SCkjdxJIQeNdSv7Wkxvtn1fz1TNkiVektBw7dYmv8A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49B583858C51 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5d34030ebb2so3279495a12.1 for ; Fri, 13 Dec 2024 07:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734105453; x=1734710253; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8DAqjgAKRKty4p7iz2B47/0ZdwFOlU9PnPzNBn+NVyA=; b=Y6jAESO8iioPOTeuwKK1NLfJQgbDr3Qwlc8V9W83MKLC1/NWBkczVxIH0P4KZefTK7 1IouNbVQ8WYcOhQe9VDKRrlBEVCFI4Ltt41n1tmsaKXRjLeHMhi+slYYEhku6EN8y4nq a55Hnl5trKdfNEy8SUglMkB9UkwZTSaQbEdW0Aga5kC9U2tyxJmDx+Mm3x8JVxFWnHJS XqqLE3GG/3++/plSVWqIejVG0z6KWozEZY0v3zFN4OnIZNrKtRKitfUMb7lpoSKuVg4k euKlJzyGUMSwOzkR+D33c2e2BiCitAs06CPNtPZBd6PqwM0vFdr6S74xmLGx2hBV1rC0 YnyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105453; x=1734710253; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8DAqjgAKRKty4p7iz2B47/0ZdwFOlU9PnPzNBn+NVyA=; b=MqGsrXQkpffFWt/KwMe3WxIStWqvnI/+BaAFhYeRT84kTcl+ZSCCR75LYRLmD/fGNS fa3EJjLUe608PzpjCqVCXJ9WMFSW70QBrvISzOLeBSTv2aXbOfWssh/IKT2Rw7JQ9VVm WbOmWs34xAZLwOXdKZLPA2OVesBP09a21szGvjy8eqQgKdZxn5OVVLNDQVR+TumrSwgN +noxauxKiTgbIzlFE9unxizlbF2Ssb85OO9J38oq85s+r3puXd5FT2g3EH7rf7KW3Q8b BmefvlMb2vJwI8xU/jzmzhUkUp6pCM70mLdH7blSP49E+z57Wrr3SPObFTKX37zRz160 s4sw== X-Gm-Message-State: AOJu0YzaFR7dfvjCricEfr94xMkfBhNFWGGfuUlsKPg00K9R/PfnHzaR AOWPDQlANH45MAttuwUxw1XS2kd4M2N+057iSTXEwenaciRDGsKp3pgoxfuD X-Gm-Gg: ASbGncvdvi5fTNudYIFQCSMtUPhB9bDSMixsJq6empuDb2H9k6wenbrc/ctwUPkuJar KbL3qrabHMaDTDzO6f0GSJUvp8IBf5PQ81PfgnjOFFGNVcNeXgs/hU5qdeeNflMvfynFxETKwQS PQoeVKq8QjIZqjuyJUhRZgP9pGHeLCGYzImjl08nhUTcw9aUmJSuw7WFCG6BKuwbtxDmICksSOv MCHNBXOyrLieWUJ7Us/BY1M1L77/F0D2+G6pt12RgOSsVIR46lG4jrw1k6dEiOrxlJAv4uF X-Google-Smtp-Source: AGHT+IEG6G6yNe5y7XiCnM1NuNKLuzfQUtgDrJ3qMduMvz2SncBqiczmrjs9QNR3Q91mVZYyYumi9w== X-Received: by 2002:a05:6402:4310:b0:5d3:bc1d:e56a with SMTP id 4fb4d7f45d1cf-5d63c313603mr2337159a12.8.1734105453269; Fri, 13 Dec 2024 07:57:33 -0800 (PST) Received: from SYRN16-0224-L.. ([109.245.202.111]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d6501d5863sm95355a12.76.2024.12.13.07.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:57:32 -0800 (PST) From: Milica Matic X-Google-Original-From: Milica Matic To: gdb-patches@sourceware.org Cc: milica.matic@htecgroup.com, simark@simark.ca, cfu@wavecomp.com, aburgess@redhat.com, kevinb@redhat.com, macro@orcam.me.uk, djordje.todorovic@htecgroup.com, Matthew Fortune , Matthew Fortune , Faraz Shahbazker Subject: [PATCH 02/21] Add new relocations for microMIPSR6 Date: Fri, 13 Dec 2024 16:53:09 +0100 Message-Id: <20241213155328.406003-4-milica.matic@htecgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213155328.406003-1-milica.matic@htecgroup.com> References: <20241213155328.406003-1-milica.matic@htecgroup.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Matthew Fortune Enabling support for advanced instructions and optimizations in the microMIPS R6 architecture. New relocation types, such as PC21_S1 and PC26_S1, enhance memory management and branch efficiency for PC-relative operations. These additions ensure proper functionality of tools like linkers and assemblers with microMIPS R6 binaries. Cherry-picked fe62e35 from https://github.com/MIPS/binutils-gdb Signed-off-by: Matthew Fortune Signed-off-by: Faraz Shahbazker Signed-off-by: Milica Matic bfd/ * bfd-in2.h (enum bfd_reloc_code_real): Add BFD_RELOC_MICROMIPS_21_PCREL_S1, BFD_RELOC_MICROMIPS_26_PCREL_S1, BFD_RELOC_MICROMIPS_18_PCREL_S3, BFD_RELOC_MICROMIPS_19_PCREL_S2, BFD_RELOC_MICROMIPS_HI16_S_PCREL, BFD_RELOC_MICROMIPS_LO16_PCREL. * libbfd.h (bfd_reloc_code_real_names): Add strings for the above. * reloc.c (DOCDD): Document the above. * elf32-mips.c (elf_micromips_howto_table_rel): Define HOWTO entries for the above. (micromips_reloc_map): Create mappings for the above. * elf64-mips.c (micromips_elf64_howto_table_rel): Define HOWTO entries for the above. (micromips_elf64_howto_table_rela): Likewise. (micromips_reloc_map): Create mappings for the above. * elfn32-mips.c (elf_micromips_howto_table_rel): Define HOWTO entries for the above. (elf_micromips_howto_table_rela): Likewise. (micromips_reloc_map): Create mappings for the above. elfcpp/ * mips.h (enum): Add R_MICROMIPS_PCHI16, R_MICROMIPS_PCLO16, R_MICROMIPS_PC21_S1, R_MICROMIPS_PC26_S1, R_MICROMIPS_PC18_S3, R_MICROMIPS_PC19_S2. include/ * elf/mips.h (elf_mips_reloc_type): Add R_MICROMIPS_PCHI16, R_MICROMIPS_PCLO16, R_MICROMIPS_PC21_S1, R_MICROMIPS_PC26_S1, R_MICROMIPS_PC18_S3, R_MICROMIPS_PC19_S2. --- bfd/bfd-in2.h | 6 ++ bfd/elf32-mips.c | 93 ++++++++++++++++++++++- bfd/elf64-mips.c | 181 +++++++++++++++++++++++++++++++++++++++++++- bfd/elfn32-mips.c | 185 +++++++++++++++++++++++++++++++++++++++++++-- bfd/libbfd.h | 6 ++ bfd/reloc.c | 12 +++ elfcpp/mips.h | 6 ++ include/elf/mips.h | 8 +- 8 files changed, 484 insertions(+), 13 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 8cc255b8354..b403b005a17 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -3664,6 +3664,10 @@ enum bfd_reloc_code_real BFD_RELOC_MICROMIPS_7_PCREL_S1, BFD_RELOC_MICROMIPS_10_PCREL_S1, BFD_RELOC_MICROMIPS_16_PCREL_S1, + BFD_RELOC_MICROMIPS_21_PCREL_S1, + BFD_RELOC_MICROMIPS_26_PCREL_S1, + BFD_RELOC_MICROMIPS_18_PCREL_S3, + BFD_RELOC_MICROMIPS_19_PCREL_S2, /* MIPS16 PC-relative relocation. */ BFD_RELOC_MIPS16_16_PCREL_S1, @@ -3679,6 +3683,8 @@ enum bfd_reloc_code_real BFD_RELOC_MICROMIPS_HI16, BFD_RELOC_MICROMIPS_HI16_S, BFD_RELOC_MICROMIPS_LO16, + BFD_RELOC_MICROMIPS_HI16_S_PCREL, + BFD_RELOC_MICROMIPS_LO16_PCREL, /* MIPS ELF relocations. */ BFD_RELOC_MIPS_GOT16, diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index bec7a207aa8..c62428c2857 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -1401,8 +1401,34 @@ static reloc_howto_type elf_micromips_howto_table_rel[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - EMPTY_HOWTO (158), - EMPTY_HOWTO (159), + HOWTO (R_MICROMIPS_PCHI16, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCHI16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PCLO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCLO16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + EMPTY_HOWTO (160), EMPTY_HOWTO (161), @@ -1544,6 +1570,63 @@ static reloc_howto_type elf_micromips_howto_table_rel[] = 0x007fffff, /* src_mask */ 0x007fffff, /* dst_mask */ true), /* pcrel_offset */ + + + HOWTO (R_MICROMIPS_PC21_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 21, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC21_S1", /* name */ + true, /* partial_inplace */ + 0x001fffff, /* src_mask */ + 0x001fffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC26_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 26, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC26_S1", /* name */ + true, /* partial_inplace */ + 0x03ffffff, /* src_mask */ + 0x03ffffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC18_S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC18_S3", /* name */ + true, /* partial_inplace */ + 0x0003ffff, /* src_mask */ + 0x0003ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC19_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC19_S2", /* name */ + true, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + true), /* pcrel_offset */ }; /* 16 bit offset for pc-relative branches. */ @@ -2058,12 +2141,18 @@ static const struct elf_reloc_map micromips_reloc_map[] = { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_HI16_S_PCREL, R_MICROMIPS_PCHI16 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_LO16_PCREL, R_MICROMIPS_PCLO16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_21_PCREL_S1, R_MICROMIPS_PC21_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_26_PCREL_S1, R_MICROMIPS_PC26_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_18_PCREL_S3, R_MICROMIPS_PC18_S3 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_19_PCREL_S2, R_MICROMIPS_PC19_S2 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min }, diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index afd7b30f134..7d72aeedf62 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -2438,8 +2438,36 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - EMPTY_HOWTO (158), - EMPTY_HOWTO (159), + + HOWTO (R_MICROMIPS_PCHI16, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCHI16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PCLO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCLO16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + + EMPTY_HOWTO (160), EMPTY_HOWTO (161), @@ -2581,6 +2609,63 @@ static reloc_howto_type micromips_elf64_howto_table_rel[] = 0x007fffff, /* src_mask */ 0x007fffff, /* dst_mask */ true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC21_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 21, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC21_S1", /* name */ + true, /* partial_inplace */ + 0x001fffff, /* src_mask */ + 0x001fffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC26_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 26, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC26_S1", /* name */ + true, /* partial_inplace */ + 0x03ffffff, /* src_mask */ + 0x03ffffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC18_S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC18_S3", /* name */ + true, /* partial_inplace */ + 0x0003ffff, /* src_mask */ + 0x0003ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC19_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC19_S2", /* name */ + true, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + true) /* pcrel_offset */ + }; static reloc_howto_type micromips_elf64_howto_table_rela[] = @@ -2940,8 +3025,34 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - EMPTY_HOWTO (158), - EMPTY_HOWTO (159), + HOWTO (R_MICROMIPS_PCHI16, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "_MICROMIPS_PCHI16", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PCLO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCLO16", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + EMPTY_HOWTO (160), EMPTY_HOWTO (161), @@ -3083,6 +3194,62 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] = 0, /* src_mask */ 0x007fffff, /* dst_mask */ true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC21_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 21, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC21_S1", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x001fffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC26_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 26, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC26_S1", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x03ffffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC18_S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC18_S3", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0003ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC19_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC19_S2", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0007ffff, /* dst_mask */ + true), /* pcrel_offset */ }; /* GNU extension to record C++ vtable hierarchy */ @@ -3771,12 +3938,18 @@ static const struct elf_reloc_map micromips_reloc_map[] = { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_HI16_S_PCREL, R_MICROMIPS_PCHI16 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_LO16_PCREL, R_MICROMIPS_PCLO16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_21_PCREL_S1, R_MICROMIPS_PC21_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_26_PCREL_S1, R_MICROMIPS_PC26_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_18_PCREL_S3, R_MICROMIPS_PC18_S3 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_19_PCREL_S2, R_MICROMIPS_PC19_S2 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min }, diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c index e137204aff7..4f55be8ff78 100644 --- a/bfd/elfn32-mips.c +++ b/bfd/elfn32-mips.c @@ -2418,8 +2418,35 @@ static reloc_howto_type elf_micromips_howto_table_rel[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - EMPTY_HOWTO (158), - EMPTY_HOWTO (159), + + HOWTO (R_MICROMIPS_PCHI16, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCHI16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PCLO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCLO16", /* name */ + true, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + EMPTY_HOWTO (160), EMPTY_HOWTO (161), @@ -2561,6 +2588,62 @@ static reloc_howto_type elf_micromips_howto_table_rel[] = 0x007fffff, /* src_mask */ 0x007fffff, /* dst_mask */ true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC21_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 21, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC21_S1", /* name */ + true, /* partial_inplace */ + 0x001fffff, /* src_mask */ + 0x001fffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC26_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 26, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC26_S1", /* name */ + true, /* partial_inplace */ + 0x03ffffff, /* src_mask */ + 0x03ffffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC18_S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC18_S3", /* name */ + true, /* partial_inplace */ + 0x0003ffff, /* src_mask */ + 0x0003ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC19_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC19_S2", /* name */ + true, /* partial_inplace */ + 0x0007ffff, /* src_mask */ + 0x0007ffff, /* dst_mask */ + true) /* pcrel_offset */ }; static reloc_howto_type elf_micromips_howto_table_rela[] = @@ -2920,8 +3003,35 @@ static reloc_howto_type elf_micromips_howto_table_rela[] = 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ - EMPTY_HOWTO (158), - EMPTY_HOWTO (159), + + HOWTO (R_MICROMIPS_PCHI16, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCHI16", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PCLO16, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PCLO16", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0000ffff, /* dst_mask */ + true), /* pcrel_offset */ + EMPTY_HOWTO (160), EMPTY_HOWTO (161), @@ -3063,6 +3173,63 @@ static reloc_howto_type elf_micromips_howto_table_rela[] = 0, /* src_mask */ 0x007fffff, /* dst_mask */ true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC21_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 21, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC21_S1", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x001fffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC26_S1, /* type */ + 1, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 26, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC26_S1", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x03ffffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC18_S3, /* type */ + 3, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 18, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC18_S3", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0003ffff, /* dst_mask */ + true), /* pcrel_offset */ + + HOWTO (R_MICROMIPS_PC19_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 19, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MICROMIPS_PC19_S2", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0x0007ffff, /* dst_mask */ + true), /* pcrel_offset */ + }; /* GNU extension to record C++ vtable hierarchy */ @@ -3195,7 +3362,7 @@ static reloc_howto_type elf_mips_eh_howto = false); /* pcrel_offset */ -/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a +/* Set the GP value for OUTPUT_BFD. Returns false if this is a dangerous relocation. */ static bool @@ -3605,12 +3772,18 @@ static const struct elf_reloc_map micromips_reloc_map[] = { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_HI16_S_PCREL, R_MICROMIPS_PCHI16 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_LO16_PCREL, R_MICROMIPS_PCLO16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_21_PCREL_S1, R_MICROMIPS_PC21_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_26_PCREL_S1, R_MICROMIPS_PC26_S1 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_18_PCREL_S3, R_MICROMIPS_PC18_S3 - R_MICROMIPS_min }, + { BFD_RELOC_MICROMIPS_19_PCREL_S2, R_MICROMIPS_PC19_S2 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min }, { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min }, @@ -3858,7 +4031,7 @@ mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym) || bfd_is_com_section (bfd_asymbol_section (sym))); } -/* Likewise, return TRUE if the symbol table split overall must be +/* Likewise, return true if the symbol table split overall must be between section symbols and all other symbols. */ static bool mips_elf_n32_elfsym_local_is_section (bfd *abfd) diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 7d7ae1eaec9..a2d4ce2602c 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1314,6 +1314,10 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MICROMIPS_7_PCREL_S1", "BFD_RELOC_MICROMIPS_10_PCREL_S1", "BFD_RELOC_MICROMIPS_16_PCREL_S1", + "BFD_RELOC_MICROMIPS_21_PCREL_S1", + "BFD_RELOC_MICROMIPS_26_PCREL_S1", + "BFD_RELOC_MICROMIPS_18_PCREL_S3", + "BFD_RELOC_MICROMIPS_19_PCREL_S2", "BFD_RELOC_MIPS16_16_PCREL_S1", "BFD_RELOC_MIPS_21_PCREL_S2", "BFD_RELOC_MIPS_26_PCREL_S2", @@ -1323,6 +1327,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MICROMIPS_HI16", "BFD_RELOC_MICROMIPS_HI16_S", "BFD_RELOC_MICROMIPS_LO16", + "BFD_RELOC_MICROMIPS_HI16_S_PCREL", + "BFD_RELOC_MICROMIPS_LO16_PCREL", "BFD_RELOC_MIPS_GOT16", "BFD_RELOC_MICROMIPS_GOT16", "BFD_RELOC_MIPS_CALL16", diff --git a/bfd/reloc.c b/bfd/reloc.c index f60776299c8..437a77882c0 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -2024,6 +2024,14 @@ ENUMX BFD_RELOC_MICROMIPS_10_PCREL_S1 ENUMX BFD_RELOC_MICROMIPS_16_PCREL_S1 +ENUMX + BFD_RELOC_MICROMIPS_21_PCREL_S1 +ENUMX + BFD_RELOC_MICROMIPS_26_PCREL_S1 +ENUMX + BFD_RELOC_MICROMIPS_18_PCREL_S3 +ENUMX + BFD_RELOC_MICROMIPS_19_PCREL_S2 ENUMDOC microMIPS PC-relative relocations. @@ -2051,6 +2059,10 @@ ENUMX BFD_RELOC_MICROMIPS_HI16_S ENUMX BFD_RELOC_MICROMIPS_LO16 +ENUMX + BFD_RELOC_MICROMIPS_HI16_S_PCREL +ENUMX + BFD_RELOC_MICROMIPS_LO16_PCREL ENUMDOC microMIPS versions of generic BFD relocs. diff --git a/elfcpp/mips.h b/elfcpp/mips.h index e8a8e2458e9..3539d1781b6 100644 --- a/elfcpp/mips.h +++ b/elfcpp/mips.h @@ -146,6 +146,8 @@ enum R_MICROMIPS_SCN_DISP = 155, R_MICROMIPS_JALR = 156, R_MICROMIPS_HI0_LO16 = 157, + R_MICROMIPS_PCHI16 = 158, + R_MICROMIPS_PCLO16 = 159, // TLS relocations. R_MICROMIPS_TLS_GD = 162, R_MICROMIPS_TLS_LDM = 163, @@ -157,6 +159,10 @@ enum // microMIPS GP- and PC-relative relocations. R_MICROMIPS_GPREL7_S2 = 172, R_MICROMIPS_PC23_S2 = 173, + R_MICROMIPS_PC21_S1 = 174, + R_MICROMIPS_PC26_S1 = 175, + R_MICROMIPS_PC18_S3 = 176, + R_MICROMIPS_PC19_S2 = 177, // This was a GNU extension used by embedded-PIC. It was co-opted by // mips-linux for exception-handling data. GCC stopped using it in diff --git a/include/elf/mips.h b/include/elf/mips.h index fb3357666ec..2d390056374 100644 --- a/include/elf/mips.h +++ b/include/elf/mips.h @@ -148,6 +148,8 @@ START_RELOC_NUMBERS (elf_mips_reloc_type) RELOC_NUMBER (R_MICROMIPS_SCN_DISP, 155) RELOC_NUMBER (R_MICROMIPS_JALR, 156) RELOC_NUMBER (R_MICROMIPS_HI0_LO16, 157) + RELOC_NUMBER (R_MICROMIPS_PCHI16, 158) + RELOC_NUMBER (R_MICROMIPS_PCLO16, 159) /* TLS relocations. */ RELOC_NUMBER (R_MICROMIPS_TLS_GD, 162) RELOC_NUMBER (R_MICROMIPS_TLS_LDM, 163) @@ -159,7 +161,11 @@ START_RELOC_NUMBERS (elf_mips_reloc_type) /* microMIPS GP- and PC-relative relocations. */ RELOC_NUMBER (R_MICROMIPS_GPREL7_S2, 172) RELOC_NUMBER (R_MICROMIPS_PC23_S2, 173) - FAKE_RELOC (R_MICROMIPS_max, 174) + RELOC_NUMBER (R_MICROMIPS_PC21_S1, 174) + RELOC_NUMBER (R_MICROMIPS_PC26_S1, 175) + RELOC_NUMBER (R_MICROMIPS_PC18_S3, 176) + RELOC_NUMBER (R_MICROMIPS_PC19_S2, 177) + FAKE_RELOC (R_MICROMIPS_max, 178) /* This was a GNU extension used by embedded-PIC. It was co-opted by mips-linux for exception-handling data. GCC stopped using it in -- 2.34.1