mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 12:03:41 +08:00
Pass GOT_RELOC to UNDEFINED_WEAK_RESOLVED_TO_ZERO
When UNDEFINED_WEAK_RESOLVED_TO_ZERO is checked to convert load via GOT, has_got_reloc is always TRUE. This patch adds GOT_RELOC, which is TRUE in x86 convert_load, to UNDEFINED_WEAK_RESOLVED_TO_ZERO. * elf32-i386.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Take GOT_RELOC and replace (EH)->has_got_reloc with GOT_RELOC. (elf_i386_fixup_symbol): Pass has_got_reloc to UNDEFINED_WEAK_RESOLVED_TO_ZERO. (elf_i386_allocate_dynrelocs): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (elf_i386_convert_load): Pass TRUE to UNDEFINED_WEAK_RESOLVED_TO_ZERO. * elf64-x86-64.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Take GOT_RELOC and replace (EH)->has_got_reloc with GOT_RELOC. (elf_x86_64_fixup_symbol): Pass has_got_reloc to UNDEFINED_WEAK_RESOLVED_TO_ZERO. (elf_x86_64_allocate_dynrelocs): Likewise. (elf_x86_64_relocate_section): Likewise. (elf_x86_64_finish_dynamic_symbol): Likewise. (elf_x86_64_convert_load): Pass TRUE to UNDEFINED_WEAK_RESOLVED_TO_ZERO.
This commit is contained in:
parent
010f98a585
commit
e62b9723fd
@ -1,3 +1,24 @@
|
||||
2016-04-29 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* elf32-i386.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Take GOT_RELOC
|
||||
and replace (EH)->has_got_reloc with GOT_RELOC.
|
||||
(elf_i386_fixup_symbol): Pass has_got_reloc to
|
||||
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
|
||||
(elf_i386_allocate_dynrelocs): Likewise.
|
||||
(elf_i386_relocate_section): Likewise.
|
||||
(elf_i386_finish_dynamic_symbol): Likewise.
|
||||
(elf_i386_convert_load): Pass TRUE to
|
||||
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
|
||||
* elf64-x86-64.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Take
|
||||
GOT_RELOC and replace (EH)->has_got_reloc with GOT_RELOC.
|
||||
(elf_x86_64_fixup_symbol): Pass has_got_reloc to
|
||||
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
|
||||
(elf_x86_64_allocate_dynrelocs): Likewise.
|
||||
(elf_x86_64_relocate_section): Likewise.
|
||||
(elf_x86_64_finish_dynamic_symbol): Likewise.
|
||||
(elf_x86_64_convert_load): Pass TRUE to
|
||||
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
|
||||
|
||||
2016-04-29 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* elf32-i386.c (check_relocs_failed): New.
|
||||
|
@ -743,11 +743,11 @@ static const struct elf_i386_backend_data elf_i386_arch_bed =
|
||||
1. Has non-GOT/non-PLT relocations in text section. Or
|
||||
2. Has no GOT/PLT relocation.
|
||||
*/
|
||||
#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
|
||||
#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, GOT_RELOC, EH) \
|
||||
((EH)->elf.root.type == bfd_link_hash_undefweak \
|
||||
&& bfd_link_executable (INFO) \
|
||||
&& (elf_i386_hash_table (INFO)->interp == NULL \
|
||||
|| !(EH)->has_got_reloc \
|
||||
|| !(GOT_RELOC) \
|
||||
|| (EH)->has_non_got_reloc \
|
||||
|| !(INFO)->dynamic_undefined_weak))
|
||||
|
||||
@ -2055,6 +2055,7 @@ elf_i386_fixup_symbol (struct bfd_link_info *info,
|
||||
{
|
||||
if (h->dynindx != -1
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
elf_i386_hash_entry (h)->has_got_reloc,
|
||||
elf_i386_hash_entry (h)))
|
||||
{
|
||||
h->dynindx = -1;
|
||||
@ -2266,7 +2267,9 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
||||
|
||||
plt_entry_size = GET_PLT_ENTRY_SIZE (info->output_bfd);
|
||||
|
||||
resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
|
||||
resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
eh->has_got_reloc,
|
||||
eh);
|
||||
|
||||
/* Clear the reference count of function pointer relocations if
|
||||
symbol isn't a normal function. */
|
||||
@ -2876,7 +2879,7 @@ elf_i386_convert_load (bfd *abfd, asection *sec,
|
||||
|
||||
/* Undefined weak symbol is only bound locally in executable
|
||||
and its reference is resolved as 0. */
|
||||
if (UNDEFINED_WEAK_RESOLVED_TO_ZERO (link_info,
|
||||
if (UNDEFINED_WEAK_RESOLVED_TO_ZERO (link_info, TRUE,
|
||||
elf_i386_hash_entry (h)))
|
||||
{
|
||||
if (opcode == 0xff)
|
||||
@ -3973,7 +3976,9 @@ elf_i386_relocate_section (bfd *output_bfd,
|
||||
|
||||
eh = (struct elf_i386_link_hash_entry *) h;
|
||||
resolved_to_zero = (eh != NULL
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
eh->has_got_reloc,
|
||||
eh));
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
@ -5026,7 +5031,9 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
|
||||
/* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
|
||||
resolved undefined weak symbols in executable so that their
|
||||
references have value 0 at run-time. */
|
||||
local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
|
||||
local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
eh->has_got_reloc,
|
||||
eh);
|
||||
|
||||
if (h->plt.offset != (bfd_vma) -1)
|
||||
{
|
||||
|
@ -748,11 +748,11 @@ static const struct elf_x86_64_backend_data elf_x86_64_bnd_arch_bed =
|
||||
1. Has non-GOT/non-PLT relocations in text section. Or
|
||||
2. Has no GOT/PLT relocation.
|
||||
*/
|
||||
#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
|
||||
#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, GOT_RELOC, EH) \
|
||||
((EH)->elf.root.type == bfd_link_hash_undefweak \
|
||||
&& bfd_link_executable (INFO) \
|
||||
&& (elf_x86_64_hash_table (INFO)->interp == NULL \
|
||||
|| !(EH)->has_got_reloc \
|
||||
|| !(GOT_RELOC) \
|
||||
|| (EH)->has_non_got_reloc \
|
||||
|| !(INFO)->dynamic_undefined_weak))
|
||||
|
||||
@ -2290,6 +2290,7 @@ elf_x86_64_fixup_symbol (struct bfd_link_info *info,
|
||||
{
|
||||
if (h->dynindx != -1
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
elf_x86_64_hash_entry (h)->has_got_reloc,
|
||||
elf_x86_64_hash_entry (h)))
|
||||
{
|
||||
h->dynindx = -1;
|
||||
@ -2502,7 +2503,9 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
|
||||
bed = get_elf_backend_data (info->output_bfd);
|
||||
plt_entry_size = GET_PLT_ENTRY_SIZE (info->output_bfd);
|
||||
|
||||
resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
|
||||
resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
eh->has_got_reloc,
|
||||
eh);
|
||||
|
||||
/* We can't use the GOT PLT if pointer equality is needed since
|
||||
finish_dynamic_symbol won't clear symbol value and the dynamic
|
||||
@ -3105,6 +3108,7 @@ elf_x86_64_convert_load (bfd *abfd, asection *sec,
|
||||
R_X86_64_PC32. */
|
||||
if ((relocx || opcode == 0x8b)
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (link_info,
|
||||
TRUE,
|
||||
elf_x86_64_hash_entry (h)))
|
||||
{
|
||||
if (opcode == 0xff)
|
||||
@ -4283,7 +4287,9 @@ elf_x86_64_relocate_section (bfd *output_bfd,
|
||||
}
|
||||
|
||||
resolved_to_zero = (eh != NULL
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
|
||||
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
eh->has_got_reloc,
|
||||
eh));
|
||||
|
||||
/* When generating a shared object, the relocations handled here are
|
||||
copied into the output file to be resolved at run time. */
|
||||
@ -5403,7 +5409,9 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
|
||||
/* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
|
||||
resolved undefined weak symbols in executable so that their
|
||||
references have value 0 at run-time. */
|
||||
local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
|
||||
local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
|
||||
eh->has_got_reloc,
|
||||
eh);
|
||||
|
||||
if (h->plt.offset != (bfd_vma) -1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user