From: Nathan Sidwell <nathan@codesourcery.com>
To: binutils@sourceware.org
Subject: [vxworks] PLT to weak symbol
Date: Wed, 11 Apr 2007 09:56:00 -0000 [thread overview]
Message-ID: <461CB161.8070701@codesourcery.com> (raw)
[-- 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
next reply other threads:[~2007-04-11 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 9:56 Nathan Sidwell [this message]
2007-04-11 11:08 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=461CB161.8070701@codesourcery.com \
--to=nathan@codesourcery.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).