From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8126 invoked by alias); 12 Apr 2007 16:51:10 -0000 Received: (qmail 7840 invoked by uid 22791); 12 Apr 2007 16:51:09 -0000 X-Spam-Check-By: sourceware.org Received: from gateway.codesourcery.com (HELO gateway.codesourcery.com) (65.74.133.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 12 Apr 2007 17:51:01 +0100 Received: (qmail 26355 invoked by uid 1010); 12 Apr 2007 16:50:58 -0000 From: Richard Sandiford To: binutils@sourceware.org Mail-Followup-To: binutils@sourceware.org, richard@codesourcery.com Subject: Fix DT_TEXTREL handling for MIPS VxWorks Date: Thu, 12 Apr 2007 16:56:00 -0000 Message-ID: <87r6qptu32.fsf@firetop.home> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 X-SW-Source: 2007-04/txt/msg00154.txt.bz2 Last year's MIPS DT_TEXTREL fix means that VxWorks executables with text relocations against __GOTT_BASE__ or __GOTT_INDEX__ (and nothing else) no longer get a DT_TEXTREL tag. This patch adds the same sort of DT_TEXTREL checks to the code that handles these relocations. Tested on mips-wrs-vxworks. OK to install? Richard bfd/ * elfxx-mips.c (mips_elf_calculate_relocation): Set DT_TEXTREL when creating a __GOTT_BASE__ or __GOTT_INDEX__ relocation in a read-only section. (_bfd_mips_elf_check_relocs): Likewise. ld/testsuite/ * ld-mips-elf/vxworks1-lib.td: New test. * ld-mips-elf/mips-elf.exp: Run it. Index: bfd/elfxx-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elfxx-mips.c,v retrieving revision 1.198 diff -u -p -r1.198 elfxx-mips.c --- bfd/elfxx-mips.c 26 Mar 2007 10:29:35 -0000 1.198 +++ bfd/elfxx-mips.c 12 Apr 2007 16:43:10 -0000 @@ -4275,6 +4275,13 @@ mips_elf_calculate_relocation (bfd *abfd outrel.r_info = ELF32_R_INFO (h->root.dynindx, r_type); outrel.r_addend = addend; bfd_elf32_swap_reloca_out (abfd, &outrel, loc); + + /* If we've written this relocation for a readonly section, + we need to set DF_TEXTREL again, so that we do not delete the + DT_TEXTREL tag. */ + if (MIPS_ELF_READONLY_SECTION (input_section)) + info->flags |= DF_TEXTREL; + *valuep = 0; return bfd_reloc_ok; } @@ -6493,6 +6500,10 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s return FALSE; } mips_elf_allocate_dynamic_relocations (dynobj, info, 1); + if (MIPS_ELF_READONLY_SECTION (sec)) + /* We tell the dynamic linker that there are + relocations against the text segment. */ + info->flags |= DF_TEXTREL; } } else if (r_type == R_MIPS_CALL_LO16 Index: ld/testsuite/ld-mips-elf/mips-elf.exp =================================================================== RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/mips-elf.exp,v retrieving revision 1.41 diff -u -p -r1.41 mips-elf.exp --- ld/testsuite/ld-mips-elf/mips-elf.exp 2 Nov 2006 15:20:31 -0000 1.41 +++ ld/testsuite/ld-mips-elf/mips-elf.exp 12 Apr 2007 16:43:10 -0000 @@ -21,7 +21,7 @@ if {[istarget "mips*-*-vxworks"]} { {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" "-mips2" {vxworks1-lib.s} {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd} - {readelf --symbols vxworks1-lib.nd}} + {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}} "libvxworks1.so"} {"VxWorks executable test 1 (dynamic)" \ "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" Index: ld/testsuite/ld-mips-elf/vxworks1-lib.td =================================================================== RCS file: ld/testsuite/ld-mips-elf/vxworks1-lib.td diff -N ld/testsuite/ld-mips-elf/vxworks1-lib.td --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-mips-elf/vxworks1-lib.td 12 Apr 2007 16:43:10 -0000 @@ -0,0 +1,3 @@ +#... + 0x0+16 \(TEXTREL\) +0x0 +#pass