mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 02:50:08 +08:00
x86: Add GENERATE_DYNAMIC_RELOCATION_P
Add GENERATE_DYNAMIC_RELOCATION_P which returns TRUE if dynamic relocation should be generated. * elf32-i386.c (X86_SIZE_TYPE_P): New. (elf_i386_relocate_section): Use GENERATE_DYNAMIC_RELOCATION_P. * elf64-x86-64.c (X86_SIZE_TYPE_P): New. (elf_x86_64_relocate_section): Use GENERATE_DYNAMIC_RELOCATION_P. * elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): New.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2017-10-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
* elf32-i386.c (X86_SIZE_TYPE_P): New.
|
||||||
|
(elf_i386_relocate_section): Use GENERATE_DYNAMIC_RELOCATION_P.
|
||||||
|
* elf64-x86-64.c (X86_SIZE_TYPE_P): New.
|
||||||
|
(elf_x86_64_relocate_section): Use GENERATE_DYNAMIC_RELOCATION_P.
|
||||||
|
* elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): New.
|
||||||
|
|
||||||
2017-10-06 H.J. Lu <hongjiu.lu@intel.com>
|
2017-10-06 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* elfxx-x86.h (POINTER_LOCAL_IFUNC_P): New.
|
* elfxx-x86.h (POINTER_LOCAL_IFUNC_P): New.
|
||||||
|
@ -184,6 +184,8 @@ static reloc_howto_type elf_howto_table[]=
|
|||||||
|
|
||||||
#define X86_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
|
#define X86_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
|
||||||
|
|
||||||
|
#define X86_SIZE_TYPE_P(TYPE) ((TYPE) == R_386_SIZE32)
|
||||||
|
|
||||||
#ifdef DEBUG_GEN_RELOC
|
#ifdef DEBUG_GEN_RELOC
|
||||||
#define TRACE(str) \
|
#define TRACE(str) \
|
||||||
fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
|
fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
|
||||||
@ -2749,29 +2751,9 @@ disallow_got32:
|
|||||||
|| is_vxworks_tls)
|
|| is_vxworks_tls)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Copy dynamic function pointer relocations. Don't generate
|
if (GENERATE_DYNAMIC_RELOCATION_P (info, eh, r_type,
|
||||||
dynamic relocations against resolved undefined weak symbols
|
FALSE, resolved_to_zero,
|
||||||
in PIE, except for R_386_PC32. */
|
(r_type == R_386_PC32)))
|
||||||
if ((bfd_link_pic (info)
|
|
||||||
&& (h == NULL
|
|
||||||
|| ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
|
||||||
&& (!resolved_to_zero
|
|
||||||
|| r_type == R_386_PC32))
|
|
||||||
|| h->root.type != bfd_link_hash_undefweak))
|
|
||||||
&& ((r_type != R_386_PC32 && r_type != R_386_SIZE32)
|
|
||||||
|| !SYMBOL_CALLS_LOCAL (info, h)))
|
|
||||||
|| (ELIMINATE_COPY_RELOCS
|
|
||||||
&& !bfd_link_pic (info)
|
|
||||||
&& h != NULL
|
|
||||||
&& h->dynindx != -1
|
|
||||||
&& (!h->non_got_ref
|
|
||||||
|| eh->func_pointer_refcount > 0
|
|
||||||
|| (h->root.type == bfd_link_hash_undefweak
|
|
||||||
&& !resolved_to_zero))
|
|
||||||
&& ((h->def_dynamic && !h->def_regular)
|
|
||||||
/* Undefined weak symbol is bound locally when
|
|
||||||
PIC is false. */
|
|
||||||
|| h->root.type == bfd_link_hash_undefweak)))
|
|
||||||
{
|
{
|
||||||
Elf_Internal_Rela outrel;
|
Elf_Internal_Rela outrel;
|
||||||
bfd_boolean skip, relocate;
|
bfd_boolean skip, relocate;
|
||||||
|
@ -206,6 +206,9 @@ static reloc_howto_type x86_64_elf_howto_table[] =
|
|||||||
|| ((TYPE) == R_X86_64_PC32_BND) \
|
|| ((TYPE) == R_X86_64_PC32_BND) \
|
||||||
|| ((TYPE) == R_X86_64_PC64))
|
|| ((TYPE) == R_X86_64_PC64))
|
||||||
|
|
||||||
|
#define X86_SIZE_TYPE_P(TYPE) \
|
||||||
|
((TYPE) == R_X86_64_SIZE32 || (TYPE) == R_X86_64_SIZE64)
|
||||||
|
|
||||||
/* Map BFD relocs to the x86_64 elf relocs. */
|
/* Map BFD relocs to the x86_64 elf relocs. */
|
||||||
struct elf_reloc_map
|
struct elf_reloc_map
|
||||||
{
|
{
|
||||||
@ -2393,6 +2396,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
|
|||||||
bfd_boolean resolved_to_zero;
|
bfd_boolean resolved_to_zero;
|
||||||
bfd_boolean relative_reloc;
|
bfd_boolean relative_reloc;
|
||||||
bfd_boolean converted_reloc;
|
bfd_boolean converted_reloc;
|
||||||
|
bfd_boolean need_copy_reloc_in_pie;
|
||||||
|
|
||||||
r_type = ELF32_R_TYPE (rel->r_info);
|
r_type = ELF32_R_TYPE (rel->r_info);
|
||||||
if (r_type == (int) R_X86_64_GNU_VTINHERIT
|
if (r_type == (int) R_X86_64_GNU_VTINHERIT
|
||||||
@ -3085,40 +3089,18 @@ direct:
|
|||||||
if ((input_section->flags & SEC_ALLOC) == 0)
|
if ((input_section->flags & SEC_ALLOC) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Don't copy a pc-relative relocation into the output file
|
need_copy_reloc_in_pie = (bfd_link_pie (info)
|
||||||
if the symbol needs copy reloc or the symbol is undefined
|
|
||||||
when building executable. Copy dynamic function pointer
|
|
||||||
relocations. Don't generate dynamic relocations against
|
|
||||||
resolved undefined weak symbols in PIE. */
|
|
||||||
if ((bfd_link_pic (info)
|
|
||||||
&& !(bfd_link_pie (info)
|
|
||||||
&& h != NULL
|
&& h != NULL
|
||||||
&& (h->needs_copy
|
&& (h->needs_copy
|
||||||
|| eh->needs_copy
|
|| eh->needs_copy
|
||||||
|| h->root.type == bfd_link_hash_undefined)
|
|| (h->root.type
|
||||||
|
== bfd_link_hash_undefined))
|
||||||
&& (X86_PCREL_TYPE_P (r_type)
|
&& (X86_PCREL_TYPE_P (r_type)
|
||||||
|| r_type == R_X86_64_SIZE32
|
|| X86_SIZE_TYPE_P (r_type)));
|
||||||
|| r_type == R_X86_64_SIZE64))
|
|
||||||
&& (h == NULL
|
if (GENERATE_DYNAMIC_RELOCATION_P (info, eh, r_type,
|
||||||
|| ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
need_copy_reloc_in_pie,
|
||||||
&& !resolved_to_zero)
|
resolved_to_zero, FALSE))
|
||||||
|| h->root.type != bfd_link_hash_undefweak))
|
|
||||||
&& ((! X86_PCREL_TYPE_P (r_type)
|
|
||||||
&& r_type != R_X86_64_SIZE32
|
|
||||||
&& r_type != R_X86_64_SIZE64)
|
|
||||||
|| ! SYMBOL_CALLS_LOCAL (info, h)))
|
|
||||||
|| (ELIMINATE_COPY_RELOCS
|
|
||||||
&& !bfd_link_pic (info)
|
|
||||||
&& h != NULL
|
|
||||||
&& h->dynindx != -1
|
|
||||||
&& (!h->non_got_ref
|
|
||||||
|| eh->func_pointer_refcount > 0
|
|
||||||
|| (h->root.type == bfd_link_hash_undefweak
|
|
||||||
&& !resolved_to_zero))
|
|
||||||
&& ((h->def_dynamic && !h->def_regular)
|
|
||||||
/* Undefined weak symbol is bound locally when
|
|
||||||
PIC is false. */
|
|
||||||
|| h->root.type == bfd_link_hash_undefined)))
|
|
||||||
{
|
{
|
||||||
Elf_Internal_Rela outrel;
|
Elf_Internal_Rela outrel;
|
||||||
bfd_boolean skip, relocate;
|
bfd_boolean skip, relocate;
|
||||||
|
@ -113,6 +113,36 @@
|
|||||||
&& ((H)->root.type == bfd_link_hash_defweak \
|
&& ((H)->root.type == bfd_link_hash_defweak \
|
||||||
|| !(H)->def_regular)))
|
|| !(H)->def_regular)))
|
||||||
|
|
||||||
|
/* TRUE if dynamic relocation should be generated. Don't copy a
|
||||||
|
pc-relative relocation into the output file if the symbol needs
|
||||||
|
copy reloc or the symbol is undefined when building executable.
|
||||||
|
Copy dynamic function pointer relocations. Don't generate dynamic
|
||||||
|
relocations against resolved undefined weak symbols in PIE, except
|
||||||
|
when PC32_RELOC is TRUE. Undefined weak symbol is bound locally
|
||||||
|
when PIC is false. */
|
||||||
|
#define GENERATE_DYNAMIC_RELOCATION_P(INFO, EH, R_TYPE, \
|
||||||
|
NEED_COPY_RELOC_IN_PIE, \
|
||||||
|
RESOLVED_TO_ZERO, PC32_RELOC) \
|
||||||
|
((bfd_link_pic (INFO) \
|
||||||
|
&& !(NEED_COPY_RELOC_IN_PIE) \
|
||||||
|
&& ((EH) == NULL \
|
||||||
|
|| ((ELF_ST_VISIBILITY ((EH)->elf.other) == STV_DEFAULT \
|
||||||
|
&& (!(RESOLVED_TO_ZERO) || PC32_RELOC)) \
|
||||||
|
|| (EH)->elf.root.type != bfd_link_hash_undefweak)) \
|
||||||
|
&& ((!X86_PCREL_TYPE_P (R_TYPE) \
|
||||||
|
&& !X86_SIZE_TYPE_P (R_TYPE)) \
|
||||||
|
|| ! SYMBOL_CALLS_LOCAL ((INFO), &(EH)->elf))) \
|
||||||
|
|| (ELIMINATE_COPY_RELOCS \
|
||||||
|
&& !bfd_link_pic (INFO) \
|
||||||
|
&& (EH) != NULL \
|
||||||
|
&& (EH)->elf.dynindx != -1 \
|
||||||
|
&& (!(EH)->elf.non_got_ref \
|
||||||
|
|| (EH)->func_pointer_refcount > 0 \
|
||||||
|
|| ((EH)->elf.root.type == bfd_link_hash_undefweak \
|
||||||
|
&& !(RESOLVED_TO_ZERO))) \
|
||||||
|
&& (((EH)->elf.def_dynamic && !(EH)->elf.def_regular) \
|
||||||
|
|| (EH)->elf.root.type == bfd_link_hash_undefined)))
|
||||||
|
|
||||||
/* TRUE if this is actually a static link, or it is a -Bsymbolic link
|
/* TRUE if this is actually a static link, or it is a -Bsymbolic link
|
||||||
and the symbol is defined locally, or the symbol was forced to be
|
and the symbol is defined locally, or the symbol was forced to be
|
||||||
local because of a version file. */
|
local because of a version file. */
|
||||||
|
Reference in New Issue
Block a user