From: David Daney <david.daney@cavium.com>
To: binutils <binutils@sourceware.org>
Cc: linux-mips <linux-mips@linux-mips.org>,
Manuel Lauss <manuel.lauss@googlemail.com>,
Debian MIPS <debian-mips@lists.debian.org>
Subject: [Patch]: Fix ld pr11138 FAILures on mips*.
Date: Mon, 05 Dec 2011 16:49:35 -0800 [thread overview]
Message-ID: <4EDD669F.30207@cavium.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]
The pr11138 testcase links an executable with a version script. On
mips64-linux the presence of a version script was causing the
MIPS_RLD_MAP dynamic tag to be populated with a NULL value. When such
an executable was run ld.so would try to dereference this and receive
SIGSEGV, thus killing the process.
The root cause of this is that the mips linker synthesizes a special
symbol "__RLD_MAP", and then sets MIPS_RLD_MAP to point to it. When a
version script is present, this symbol gets versioned along with all the
rest, and when it is time to take its address, the symbol can no longer
be found as it has had version information appended to its name.
Since "__RLD_MAP" is really part of the ABI, we want to exclude it from
symbol versioning. To this end, I introduced a new symbol flag
'no_sym_version' to tag this type of symbol. When the "__RLD_MAP"
symbol is created, we set this flag.
In _bfd_elf_link_assign_sym_version, we then skip all symbols that have
'no_sym_version' set, and everything now works.
This problem has also been reported in the wild when linking the firefox
executable.
Tested on mips64-linux-gnu and x86_64-linux-gnu
Ok to commit?
2011-12-05 David Daney <david.daney@cavium.com>
* elf-bfd.h (elf_link_hash_entry): Add no_sym_version field.
* elflink.c (_bfd_elf_link_assign_sym_version): Don't assign a
version if no_sym_version is set.
* elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Set
no_sym_version for "__RLD_MAP".
[-- Attachment #2: dd-2.patch --]
[-- Type: text/plain, Size: 1784 bytes --]
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.329
diff -u -p -r1.329 elf-bfd.h
--- bfd/elf-bfd.h 17 Aug 2011 00:39:38 -0000 1.329
+++ bfd/elf-bfd.h 5 Dec 2011 20:15:49 -0000
@@ -198,6 +198,8 @@ struct elf_link_hash_entry
unsigned int pointer_equality_needed : 1;
/* Symbol is a unique global symbol. */
unsigned int unique_global : 1;
+ /* Symbol should not be versioned. It is part of the ABI */
+ unsigned int no_sym_version : 1;
/* String table index in .dynstr if this is a dynamic symbol. */
unsigned long dynstr_index;
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.430
diff -u -p -r1.430 elflink.c
--- bfd/elflink.c 15 Nov 2011 11:33:57 -0000 1.430
+++ bfd/elflink.c 5 Dec 2011 20:15:50 -0000
@@ -1946,6 +1946,9 @@ _bfd_elf_link_assign_sym_version (struct
if (!h->def_regular)
return TRUE;
+ if (h->no_sym_version)
+ return TRUE;
+
bed = get_elf_backend_data (info->output_bfd);
p = strchr (h->root.root.string, ELF_VER_CHR);
if (p != NULL && h->verinfo.vertree == NULL)
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.296
diff -u -p -r1.296 elfxx-mips.c
--- bfd/elfxx-mips.c 29 Nov 2011 20:28:54 -0000 1.296
+++ bfd/elfxx-mips.c 5 Dec 2011 20:15:50 -0000
@@ -7260,6 +7260,7 @@ _bfd_mips_elf_create_dynamic_sections (b
h = (struct elf_link_hash_entry *) bh;
h->non_elf = 0;
h->def_regular = 1;
+ h->no_sym_version = 1;
h->type = STT_OBJECT;
if (! bfd_elf_link_record_dynamic_symbol (info, h))
next reply other threads:[~2011-12-06 0:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 0:49 David Daney [this message]
2011-12-06 5:40 ` [Patch]: Fix ld pr11138 FAILures on mips* Alan Modra
2011-12-06 20:20 ` David Daney
2011-12-06 23:43 ` Alan Modra
2011-12-06 21:16 ` Richard Sandiford
2011-12-06 22:13 ` David Daney
2011-12-08 20:34 ` Richard Sandiford
2011-12-08 20:53 ` David Daney
2011-12-07 0:07 ` Alan Modra
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=4EDD669F.30207@cavium.com \
--to=david.daney@cavium.com \
--cc=binutils@sourceware.org \
--cc=debian-mips@lists.debian.org \
--cc=linux-mips@linux-mips.org \
--cc=manuel.lauss@googlemail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.