aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-bfd.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-03-27 15:41:05 +1030
committerAlan Modra <amodra@gmail.com>2015-03-27 16:20:32 +1030
commitb84171287ffe60dd1e7c02262a0493862fa21a97 (patch)
tree158858087a8b26b4da5a56cbce18fad8ac814970 /bfd/elf-bfd.h
parentf3308340aba43e99aa448641a5d3db1c7fae60cf (diff)
downloadgdb-b84171287ffe60dd1e7c02262a0493862fa21a97.zip
gdb-b84171287ffe60dd1e7c02262a0493862fa21a97.tar.gz
gdb-b84171287ffe60dd1e7c02262a0493862fa21a97.tar.bz2
Relax PR 15228 protected visibility restriction
Allows .dynbss copy of shared library protected visibility variables if they are read-only. To recap: Copying a variable from a shared library into an executable's .dynbss is an old hack invented for non-PIC executables, to avoid the text relocations you'd otherwise need to access a shared library variable. This works with ELF shared libraries because global symbols can be overridden. The trouble is that protected visibility symbols can't be overridden. A shared library will continue to access it's own protected visibility variable while the executable accesses a copy. If either the shared library or the executable updates the value then the copy diverges from the original. This is wrong since there is only one definition of the variable in the application. So I made the linker report an error on attempting to copy protected visibility variables into .dynbss. However, you'll notice the above paragraph contains an "If". An application that does not modify the variable value remains correct even though two copies of the variable exist. The linker can detect this situation if the variable was defined in a read-only section. PR ld/15228 PR ld/18167 * elflink.c (elf_merge_st_other): Add "sec" parameter. Don't set protected_def when symbol section is read-only. Adjust all calls. * elf-bfd.h (struct elf_link_hash_entry): Update protected_def comment.
Diffstat (limited to 'bfd/elf-bfd.h')
-rw-r--r--bfd/elf-bfd.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 13c32e0..53ef9d8 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -200,7 +200,8 @@ struct elf_link_hash_entry
unsigned int pointer_equality_needed : 1;
/* Symbol is a unique global symbol. */
unsigned int unique_global : 1;
- /* Symbol is defined with non-default visibility. */
+ /* Symbol is defined by a shared library with non-default visibility
+ in a read/write section. */
unsigned int protected_def : 1;
/* String table index in .dynstr if this is a dynamic symbol. */