diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-08-26 19:22:26 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-08-26 19:26:21 -0700 |
commit | a5b4ee9451dc9ffb6aa29376fc03943c53c6da0d (patch) | |
tree | 74028cae4c8a9f47eab5faa25aff8a47b0c04e77 /bfd/elf-bfd.h | |
parent | aecbb010f9d74b574ba89a64f45cde2407e53dab (diff) | |
download | gdb-a5b4ee9451dc9ffb6aa29376fc03943c53c6da0d.zip gdb-a5b4ee9451dc9ffb6aa29376fc03943c53c6da0d.tar.gz gdb-a5b4ee9451dc9ffb6aa29376fc03943c53c6da0d.tar.bz2 |
Disallow copy relocation against protected data symbol
We shpouldn't generate copy relocation to resolve reference to protected
data symbol defined in shared object with the NO_COPY_ON_PROTECTED
property. This patch adds a bit to elf_obj_tdata as well as
elf_i386_link_hash_entry and elf_x86_64_link_hash_entry to track the bfd
with the NO_COPY_ON_PROTECTED property as well as protected symbol
defined in shared object. extern_protected_data is set to FALSE if any
input relocatable file contains the NO_COPY_ON_PROTECTED property.
bfd/
PR ld/21997
* elf-bfd.h (elf_obj_tdata): Use ENUM_BITFIELD on object_id,
dyn_lib_class and has_gnu_symbols. Change bad_symtab to bitfield.
Add a has_no_copy_on_protected bitfield.
(elf_has_no_copy_on_protected): New.
* elf-properties.c (_bfd_elf_parse_gnu_properties): Set
elf_has_no_copy_on_protected for GNU_PROPERTY_NO_COPY_ON_PROTECTED.
(elf_merge_gnu_property_list): Likewise.
(_bfd_elf_link_setup_gnu_properties): Set extern_protected_data
to FALSE for elf_has_no_copy_on_protected.
* elf32-i386.c (SYMBOL_NO_COPYRELOC): New.
(elf_i386_link_hash_entry): Add def_protected.
(elf_i386_adjust_dynamic_symbol): Also check SYMBOL_NO_COPYRELOC
when checking info->nocopyreloc.
(elf_i386_link_setup_gnu_properties): Don't set
extern_protected_data here.
(elf_i386_merge_symbol_attribute): New function.
(elf_backend_merge_symbol_attribute): New.
* elf64-x86-64.c (SYMBOL_NO_COPYRELOC): New.
(elf_x86_64_link_hash_entry): Add def_protected.
(elf_x86_64_need_pic): Report protected symbol for def_protected.
(elf_x86_64_adjust_dynamic_symbol): Also check SYMBOL_NO_COPYRELOC
when checking info->nocopyreloc.
(elf_x86_64_relocate_section): Also check for R_X86_64_PC32
relocation run-time overflow and unresolvable R_X86_64_32S
relocation against protected data symbol defined in shared object
with GNU_PROPERTY_NO_COPY_ON_PROTECTED.
(elf_x86_64_link_setup_gnu_properties): Don't set
extern_protected_data here.
(elf_x86_64_merge_symbol_attribute): New function.
(elf_backend_merge_symbol_attribute): New.
ld/
PR ld/21997
* testsuite/ld-i386/i386.exp: Run PR ld/21997 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr21997-1a.S: New file.
* testsuite/ld-i386/pr21997-1b.c: Likewise.
* testsuite/ld-i386/pr21997-1c.S: Likewise.
* testsuite/ld-x86-64/pr21997-1a.S: Likewise.
* testsuite/ld-x86-64/pr21997-1a.err: Likewise.
* testsuite/ld-x86-64/pr21997-1b.c: Likewise.
* testsuite/ld-x86-64/pr21997-1b.err: Likewise.
* testsuite/ld-x86-64/pr21997-1c.c: Likewise.
Diffstat (limited to 'bfd/elf-bfd.h')
-rw-r--r-- | bfd/elf-bfd.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 83958e4..79b9dbc 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1887,21 +1887,27 @@ struct elf_obj_tdata /* An identifier used to distinguish different target specific extensions to this structure. */ - enum elf_target_id object_id; + ENUM_BITFIELD (elf_target_id) object_id : 6; /* Whether a dyanmic object was specified normally on the linker command line, or was specified when --as-needed was in effect, or was found via a DT_NEEDED entry. */ - enum dynamic_lib_link_class dyn_lib_class; + ENUM_BITFIELD (dynamic_lib_link_class) dyn_lib_class : 4; + + /* Whether if the bfd contains symbols that have the STT_GNU_IFUNC + symbol type or STB_GNU_UNIQUE binding. */ + ENUM_BITFIELD (elf_gnu_symbols) has_gnu_symbols : 3; + + /* Whether if the bfd contains the GNU_PROPERTY_NO_COPY_ON_PROTECTED + property. */ + unsigned int has_no_copy_on_protected : 1; /* Irix 5 often screws up the symbol table, sorting local symbols after global symbols. This flag is set if the symbol table in this BFD appears to be screwed up. If it is, we ignore the sh_info field in the symbol table header, and always read all the symbols. */ - bfd_boolean bad_symtab; - - enum elf_gnu_symbols has_gnu_symbols; + unsigned int bad_symtab : 1; /* Information grabbed from an elf core file. */ struct core_elf_obj_tdata *core; @@ -1956,6 +1962,8 @@ struct elf_obj_tdata #define elf_other_obj_attributes_proc(bfd) \ (elf_other_obj_attributes (bfd) [OBJ_ATTR_PROC]) #define elf_properties(bfd) (elf_tdata (bfd) -> properties) +#define elf_has_no_copy_on_protected(bfd) \ + (elf_tdata(bfd) -> has_no_copy_on_protected) extern void _bfd_elf_swap_verdef_in (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *); |