mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
* elf32-i386.c (elf_i386_check_relocs): Don't make syms dynamic
here.. (elf_i386_adjust_dynamic_symbol): ..nor here.. (allocate_plt_and_got_and_discard_relocs): .. instead do so here after gc has run. (elf_i386_size_dynamic_sections): Fix a comment. (elf_i386_relocate_section <R_386_32, R_386_PC32>): Rearrange code involved in writing reloc out.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
2001-06-27 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* elf32-i386.c (elf_i386_check_relocs): Don't make syms dynamic
|
||||||
|
here..
|
||||||
|
(elf_i386_adjust_dynamic_symbol): ..nor here..
|
||||||
|
(allocate_plt_and_got_and_discard_relocs): .. instead do so here
|
||||||
|
after gc has run.
|
||||||
|
(elf_i386_size_dynamic_sections): Fix a comment.
|
||||||
|
(elf_i386_relocate_section <R_386_32, R_386_PC32>): Rearrange code
|
||||||
|
involved in writing reloc out.
|
||||||
|
|
||||||
2001-06-25 Alan Modra <amodra@bigpond.net.au>
|
2001-06-25 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
* elf32-i386.c (elf_i386_check_relocs <R_386_32, R_386_PC32>):
|
* elf32-i386.c (elf_i386_check_relocs <R_386_32, R_386_PC32>):
|
||||||
|
118
bfd/elf32-i386.c
118
bfd/elf32-i386.c
@ -611,15 +611,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
|
|||||||
if (h != NULL)
|
if (h != NULL)
|
||||||
{
|
{
|
||||||
if (h->got.refcount == -1)
|
if (h->got.refcount == -1)
|
||||||
{
|
|
||||||
/* Make sure this symbol is output as a dynamic symbol. */
|
|
||||||
if (h->dynindx == -1)
|
|
||||||
{
|
|
||||||
if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
h->got.refcount = 1;
|
h->got.refcount = 1;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
h->got.refcount += 1;
|
h->got.refcount += 1;
|
||||||
}
|
}
|
||||||
@ -726,12 +718,6 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
|
|||||||
if (dynobj == NULL)
|
if (dynobj == NULL)
|
||||||
htab->root.dynobj = dynobj = abfd;
|
htab->root.dynobj = dynobj = abfd;
|
||||||
|
|
||||||
if (h != NULL && h->dynindx == -1)
|
|
||||||
{
|
|
||||||
if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sreloc == NULL)
|
if (sreloc == NULL)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -990,14 +976,6 @@ elf_i386_adjust_dynamic_symbol (info, h)
|
|||||||
linkage table, and we can just do a PC32 reloc instead. */
|
linkage table, and we can just do a PC32 reloc instead. */
|
||||||
h->plt.refcount = (bfd_vma) -1;
|
h->plt.refcount = (bfd_vma) -1;
|
||||||
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
|
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure this symbol is output as a dynamic symbol. */
|
|
||||||
if (h->dynindx == -1)
|
|
||||||
{
|
|
||||||
if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1115,6 +1093,7 @@ allocate_plt_and_got_and_discard_relocs (h, inf)
|
|||||||
struct bfd_link_info *info;
|
struct bfd_link_info *info;
|
||||||
struct elf_i386_link_hash_table *htab;
|
struct elf_i386_link_hash_table *htab;
|
||||||
asection *s;
|
asection *s;
|
||||||
|
struct elf_i386_link_hash_entry *eh;
|
||||||
|
|
||||||
if (h->root.type == bfd_link_hash_indirect
|
if (h->root.type == bfd_link_hash_indirect
|
||||||
|| h->root.type == bfd_link_hash_warning)
|
|| h->root.type == bfd_link_hash_warning)
|
||||||
@ -1126,6 +1105,15 @@ allocate_plt_and_got_and_discard_relocs (h, inf)
|
|||||||
if (htab->root.dynamic_sections_created
|
if (htab->root.dynamic_sections_created
|
||||||
&& h->plt.refcount > 0)
|
&& h->plt.refcount > 0)
|
||||||
{
|
{
|
||||||
|
/* Make sure this symbol is output as a dynamic symbol.
|
||||||
|
Undefined weak syms won't yet be marked as dynamic. */
|
||||||
|
if (h->dynindx == -1
|
||||||
|
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
||||||
|
{
|
||||||
|
if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
s = htab->splt;
|
s = htab->splt;
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
abort ();
|
abort ();
|
||||||
@ -1178,6 +1166,15 @@ allocate_plt_and_got_and_discard_relocs (h, inf)
|
|||||||
{
|
{
|
||||||
boolean dyn;
|
boolean dyn;
|
||||||
|
|
||||||
|
/* Make sure this symbol is output as a dynamic symbol.
|
||||||
|
Undefined weak syms won't yet be marked as dynamic. */
|
||||||
|
if (h->dynindx == -1
|
||||||
|
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
||||||
|
{
|
||||||
|
if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
s = htab->sgot;
|
s = htab->sgot;
|
||||||
h->got.offset = s->_raw_size;
|
h->got.offset = s->_raw_size;
|
||||||
s->_raw_size += 4;
|
s->_raw_size += 4;
|
||||||
@ -1188,28 +1185,44 @@ allocate_plt_and_got_and_discard_relocs (h, inf)
|
|||||||
else
|
else
|
||||||
h->got.offset = (bfd_vma) -1;
|
h->got.offset = (bfd_vma) -1;
|
||||||
|
|
||||||
/* In the shared -Bsymbolic case, discard space allocated to copy
|
/* In the shared -Bsymbolic case, discard space allocated for
|
||||||
PC relative relocs against symbols which turn out to be defined
|
dynamic relocs against symbols which turn out to be defined
|
||||||
in regular objects. For the normal shared case, discard space
|
in regular objects. For the normal shared case, discard space
|
||||||
for relocs that have become local due to symbol visibility
|
for relocs that have become local due to symbol visibility
|
||||||
changes. For the non-shared case, discard space for symbols
|
changes. For the non-shared case, discard space for symbols
|
||||||
which turn out to need copy relocs or are not dynamic. */
|
which turn out to need copy relocs or are not dynamic. */
|
||||||
|
|
||||||
if ((info->shared
|
eh = (struct elf_i386_link_hash_entry *) h;
|
||||||
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
|
if (eh->dyn_relocs == NULL)
|
||||||
&& ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
|
return true;
|
||||||
|| info->symbolic))
|
|
||||||
|| (!info->shared
|
if (!info->shared
|
||||||
&& (h->dynindx == -1
|
&& (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
|
||||||
|| (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) != 0
|
&& ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
||||||
|| ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|
|| h->root.type == bfd_link_hash_undefweak
|
||||||
&& h->root.type != bfd_link_hash_undefweak
|
|| h->root.type == bfd_link_hash_undefined))
|
||||||
&& h->root.type != bfd_link_hash_undefined))))
|
{
|
||||||
|
/* Make sure this symbol is output as a dynamic symbol.
|
||||||
|
Undefined weak syms won't yet be marked as dynamic. */
|
||||||
|
if (h->dynindx == -1
|
||||||
|
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
||||||
|
{
|
||||||
|
if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If that succeeded, we know we'll be keeping all the relocs. */
|
||||||
|
if (h->dynindx != -1)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!info->shared
|
||||||
|
|| ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
|
||||||
|
&& ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
|
||||||
|
|| info->symbolic)))
|
||||||
{
|
{
|
||||||
struct elf_i386_link_hash_entry *eh;
|
|
||||||
struct elf_i386_dyn_relocs *c;
|
struct elf_i386_dyn_relocs *c;
|
||||||
|
|
||||||
eh = (struct elf_i386_link_hash_entry *) h;
|
|
||||||
for (c = eh->dyn_relocs; c != NULL; c = c->next)
|
for (c = eh->dyn_relocs; c != NULL; c = c->next)
|
||||||
c->section->_raw_size -= c->count * sizeof (Elf32_External_Rel);
|
c->section->_raw_size -= c->count * sizeof (Elf32_External_Rel);
|
||||||
}
|
}
|
||||||
@ -1290,9 +1303,8 @@ elf_i386_size_dynamic_sections (output_bfd, info)
|
|||||||
allocate_plt_and_got_and_discard_relocs,
|
allocate_plt_and_got_and_discard_relocs,
|
||||||
(PTR) info);
|
(PTR) info);
|
||||||
|
|
||||||
/* The check_relocs and adjust_dynamic_symbol entry points have
|
/* We now have determined the sizes of the various dynamic sections.
|
||||||
determined the sizes of the various dynamic sections. Allocate
|
Allocate memory for them. */
|
||||||
memory for them. */
|
|
||||||
relocs = false;
|
relocs = false;
|
||||||
reltext = false;
|
reltext = false;
|
||||||
for (s = dynobj->sections; s != NULL; s = s->next)
|
for (s = dynobj->sections; s != NULL; s = s->next)
|
||||||
@ -1775,32 +1787,24 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
|
|||||||
memset (&outrel, 0, sizeof outrel);
|
memset (&outrel, 0, sizeof outrel);
|
||||||
relocate = false;
|
relocate = false;
|
||||||
}
|
}
|
||||||
else if (r_type == R_386_PC32)
|
else if (h != NULL
|
||||||
|
&& h->dynindx != -1
|
||||||
|
&& (r_type == R_386_PC32
|
||||||
|
|| !info->shared
|
||||||
|
|| !info->symbolic
|
||||||
|
|| (h->elf_link_hash_flags
|
||||||
|
& ELF_LINK_HASH_DEF_REGULAR) == 0))
|
||||||
|
|
||||||
{
|
{
|
||||||
BFD_ASSERT (h != NULL && h->dynindx != -1);
|
|
||||||
relocate = false;
|
relocate = false;
|
||||||
outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_PC32);
|
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* h->dynindx may be -1 if this symbol was marked to
|
/* This symbol is local, or marked to become local. */
|
||||||
become local. */
|
|
||||||
if (h == NULL
|
|
||||||
|| (info->shared
|
|
||||||
&& (info->symbolic || h->dynindx == -1)
|
|
||||||
&& (h->elf_link_hash_flags
|
|
||||||
& ELF_LINK_HASH_DEF_REGULAR) != 0))
|
|
||||||
{
|
|
||||||
relocate = true;
|
relocate = true;
|
||||||
outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
|
outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
BFD_ASSERT (h->dynindx != -1);
|
|
||||||
relocate = false;
|
|
||||||
outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bfd_elf32_swap_reloc_out (output_bfd, &outrel,
|
bfd_elf32_swap_reloc_out (output_bfd, &outrel,
|
||||||
(((Elf32_External_Rel *)
|
(((Elf32_External_Rel *)
|
||||||
|
Reference in New Issue
Block a user