public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [vxworks]  PLT to weak symbol
@ 2007-04-11  9:56 Nathan Sidwell
  2007-04-11 11:08 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Sidwell @ 2007-04-11  9:56 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

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


[-- Attachment #2: all.diff --]
[-- Type: text/plain, Size: 1126 bytes --]

2007-04-11  Nathan Sidwell  <nathan@codesourcery.com>

	* 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [vxworks]  PLT to weak symbol
  2007-04-11  9:56 [vxworks] PLT to weak symbol Nathan Sidwell
@ 2007-04-11 11:08 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2007-04-11 11:08 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: binutils

On Wed, Apr 11, 2007 at 10:58:57AM +0100, Nathan Sidwell wrote:
> ok?
> 
> nathan

> 2007-04-11  Nathan Sidwell  <nathan@codesourcery.com>
> 
> 	* elf-vxworks.c (elf_vxworks_emit_relocs): Remap weakdef PLT slot
> 	relocs too.

This is OK.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-11 11:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-11  9:56 [vxworks] PLT to weak symbol Nathan Sidwell
2007-04-11 11:08 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).