From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87076 invoked by alias); 10 Aug 2016 21:34:10 -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 87038 invoked by uid 89); 10 Aug 2016 21:34:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=stricter, inferred X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Aug 2016 21:34:08 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 67F1BB5D37C01 for ; Wed, 10 Aug 2016 22:33:51 +0100 (IST) Received: from [10.20.78.240] (10.20.78.240) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server id 14.3.294.0; Wed, 10 Aug 2016 22:33:54 +0100 Date: Wed, 10 Aug 2016 21:34:00 -0000 From: "Maciej W. Rozycki" To: CC: Faraz Shahbazker Subject: [committed 1/4] MIPS/BFD: Set the ISA bit in microMIPS LA25 stub references In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2016-08/txt/msg00066.txt.bz2 Fix a linker regression introduced with commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment of branch and jump targets") causing a build failure in microMIPS glibc where the `zdump' tool fails to link: .../timezone/zdump.o: In function `yeartot': .../timezone/zdump.c:758:(.text+0x62): Jump to a non-instruction-aligned address .../timezone/zdump.c:758:(.text+0x76): Jump to a non-instruction-aligned address .../timezone/zdump.c:768:(.text+0x112): Jump to a non-instruction-aligned address .../timezone/zdump.c:774:(.text+0x1b8): Jump to a non-instruction-aligned address .../timezone/zdump.c:774:(.text+0x1cc): Jump to a non-instruction-aligned address collect2: error: ld returned 1 exit status make[2]: *** [.../timezone/zdump] Error 1 The cause of the failure is the stricter check introduced with the said change for jump and branch targets tripping on the address of microMIPS LA25 stubs. Despite being microMIPS code these stubs do not have the ISA bit set throughout the relocation calculation process, because they have their address set to the memory offset into the stub section they are placed in. The `mips_elf_la25_stub' structure does not carry ISA mode information, but there is no need to extend it, because the ISA mode can be inferred from the original symbol, which will have STO_MICROMIPS annotation, so use that instead to set the ISA bit appropriately. Also only LA25 stubs associated with microMIPS symbols need to have the ISA bit set, because other LA25 stubs are made with regular MIPS code, even if associated with a MIPS16 symbol (in which case they are needed by a call thunk only rather than the MIPS16 function proper). bfd/ * elfxx-mips.c (mips_elf_calculate_relocation): Set the ISA bit in microMIPS LA25 stub references. --- binutils-umips-bfd-la25-isa-bit.diff Index: binutils/bfd/elfxx-mips.c =================================================================== --- binutils.orig/bfd/elfxx-mips.c 2016-08-08 16:50:32.668787260 +0100 +++ binutils/bfd/elfxx-mips.c 2016-08-08 17:31:58.912513411 +0100 @@ -5577,9 +5580,13 @@ mips_elf_calculate_relocation (bfd *abfd else if (h != NULL && h->la25_stub && mips_elf_relocation_needs_la25_stub (input_bfd, r_type, target_is_16_bit_code_p)) - symbol = (h->la25_stub->stub_section->output_section->vma - + h->la25_stub->stub_section->output_offset - + h->la25_stub->offset); + { + symbol = (h->la25_stub->stub_section->output_section->vma + + h->la25_stub->stub_section->output_offset + + h->la25_stub->offset); + if (ELF_ST_IS_MICROMIPS (h->root.other)) + symbol |= 1; + } /* For direct MIPS16 and microMIPS calls make sure the compressed PLT entry is used if a standard PLT entry has also been made. In this case the symbol will have been set by mips_elf_set_plt_sym_value