From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27394 invoked by alias); 11 Apr 2007 09:56:44 -0000 Received: (qmail 27381 invoked by uid 22791); 11 Apr 2007 09:56:44 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Apr 2007 10:56:41 +0100 Received: (qmail 30665 invoked from network); 11 Apr 2007 09:56:39 -0000 Received: from unknown (HELO ?192.168.189.100?) (nathan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Apr 2007 09:56:39 -0000 Message-ID: <461CB161.8070701@codesourcery.com> Date: Wed, 11 Apr 2007 09:56:00 -0000 From: Nathan Sidwell User-Agent: Thunderbird 1.5.0.10 (X11/20070306) MIME-Version: 1.0 To: binutils@sourceware.org Subject: [vxworks] PLT to weak symbol Content-Type: multipart/mixed; boundary="------------060300070407030009030308" 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/msg00111.txt.bz2 This is a multi-part message in MIME format. --------------060300070407030009030308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1052 this patch fixes a problem that vxworks rtp has with weak symbols. Consider: app.c void Weak (void); void (*const ptr) (void) = &Weak; lib.c void __attribute__((weak)) Weak (void) {} This is what you get with a C++ class that has no key virtual function. Weak is an inline virtual function. The problem vxworks has is that .rodata (where 'ptr' resides) is relocated by the kernel loader, and that doesn't know anything about 'Weak'. It blithely *ignores* the relocation we emit, and we end up with a broken image. The rtp dynamic loader is responsible for filling in relocs to Weak, but it doesn't relocate .rodata and the like. We already have special code to deal with the non-weak case here, and change the reloc for ptr's initializer to refer to .plt, which the kernel loader does know about. This patch makes it do the same thing for weak definitions too. ok? nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk --------------060300070407030009030308 Content-Type: text/plain; name="all.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="all.diff" Content-length: 1126 2007-04-11 Nathan Sidwell * elf-vxworks.c (elf_vxworks_emit_relocs): Remap weakdef PLT slot relocs too. Index: elf-vxworks.c =================================================================== RCS file: /cvs/src/src/bfd/elf-vxworks.c,v retrieving revision 1.5 diff -c -3 -p -r1.5 elf-vxworks.c *** elf-vxworks.c 4 Aug 2006 13:13:55 -0000 1.5 --- elf-vxworks.c 11 Apr 2007 09:46:46 -0000 *************** elf_vxworks_emit_relocs (bfd *output_bfd *** 170,176 **** && *rel_hash && (*rel_hash)->def_dynamic && !(*rel_hash)->def_regular ! && (*rel_hash)->root.type == bfd_link_hash_defined && (*rel_hash)->root.u.def.section->output_section != NULL) { /* This is a relocation from an executable or shared library --- 170,177 ---- && *rel_hash && (*rel_hash)->def_dynamic && !(*rel_hash)->def_regular ! && ((*rel_hash)->root.type == bfd_link_hash_defined ! || (*rel_hash)->root.type == bfd_link_hash_weakdef) && (*rel_hash)->root.u.def.section->output_section != NULL) { /* This is a relocation from an executable or shared library --------------060300070407030009030308--