* elf32-cris.c (cris_elf_relocate_section): Drop nonsensical
dynamic reference test in assertion when initializing GOT with static contents. Just assert that there are either no dynamic sections, the symbol is defined in the regular objects or that the symbol is undef weak. Tweak comment. (elf_cris_finish_dynamic_symbol): Emit .got reloc for a program only if the symbol isn't defined in the program and isn't undef weak. (elf_cris_adjust_dynamic_symbol): Simplify condition for getting rid of PLT entry: only do it if the symbol isn't defined in a DSO. When doing so, clear ELF_LINK_HASH_NEEDS_PLT. Tweak comments. (elf_cris_discard_excess_program_dynamics): Don't consider ELF_LINK_HASH_REF_DYNAMIC when omitting .got runtime relocs.
This commit is contained in:
parent
f1cf2c2e58
commit
6849c52f0a
|
@ -1,3 +1,19 @@
|
||||||
|
2002-07-12 Hans-Peter Nilsson <hp@axis.com>
|
||||||
|
|
||||||
|
* elf32-cris.c (cris_elf_relocate_section): Drop nonsensical
|
||||||
|
dynamic reference test in assertion when initializing GOT with
|
||||||
|
static contents. Just assert that there are either no dynamic
|
||||||
|
sections, the symbol is defined in the regular objects or that the
|
||||||
|
symbol is undef weak. Tweak comment.
|
||||||
|
(elf_cris_finish_dynamic_symbol): Emit .got reloc for a program
|
||||||
|
only if the symbol isn't defined in the program and isn't undef
|
||||||
|
weak.
|
||||||
|
(elf_cris_adjust_dynamic_symbol): Simplify condition for getting
|
||||||
|
rid of PLT entry: only do it if the symbol isn't defined in a DSO.
|
||||||
|
When doing so, clear ELF_LINK_HASH_NEEDS_PLT. Tweak comments.
|
||||||
|
(elf_cris_discard_excess_program_dynamics): Don't consider
|
||||||
|
ELF_LINK_HASH_REF_DYNAMIC when omitting .got runtime relocs.
|
||||||
|
|
||||||
2002-07-11 Alan Modra <amodra@bigpond.net.au>
|
2002-07-11 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
* elf32-i386.c (elf_i386_relocate_section): Don't complain about
|
* elf32-i386.c (elf_i386_relocate_section): Don't complain about
|
||||||
|
|
|
@ -1046,29 +1046,28 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||||
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
|
||||||
{
|
{
|
||||||
/* This wasn't checked above for ! info->shared, but
|
/* This wasn't checked above for ! info->shared, but
|
||||||
must hold there if we get here; the symbol must not
|
must hold there if we get here; the symbol must be
|
||||||
be used in, or defined by a DSO. (Note that
|
defined in the regular program, or be undefweak. */
|
||||||
checking for ELF_LINK_HASH_DEF_REGULAR doesn't
|
BFD_ASSERT (!elf_hash_table (info)->dynamic_sections_created
|
||||||
catch all cases.) */
|
|| info->shared
|
||||||
BFD_ASSERT (info->shared
|
|
||||||
|| (h->elf_link_hash_flags
|
|| (h->elf_link_hash_flags
|
||||||
& (ELF_LINK_HASH_REF_DYNAMIC
|
& ELF_LINK_HASH_DEF_REGULAR) != 0
|
||||||
| ELF_LINK_HASH_DEF_DYNAMIC)) == 0);
|
|| h->root.type == bfd_link_hash_undefweak);
|
||||||
|
|
||||||
/* This is actually a static link, or it is a
|
/* This is actually a static link, or it is a
|
||||||
-Bsymbolic link and the symbol is defined
|
-Bsymbolic link and the symbol is defined locally,
|
||||||
locally, or the symbol was forced to be local
|
or is undefweak, or the symbol was forced to be
|
||||||
because of a version file, or we're not creating a
|
local because of a version file, or we're not
|
||||||
dynamic object and the symbol isn't referred to by
|
creating a dynamic object. We must initialize this
|
||||||
a dynamic object. We must initialize
|
entry in the global offset table. Since the offset
|
||||||
this entry in the global offset table. Since
|
must always be a multiple of 4, we use the least
|
||||||
the offset must always be a multiple of 4, we
|
significant bit to record whether we have
|
||||||
use the least significant bit to record whether
|
initialized it already.
|
||||||
we have initialized it already.
|
|
||||||
|
|
||||||
When doing a dynamic link, we create a .rela.got
|
If this GOT entry should be runtime-initialized, we
|
||||||
relocation entry to initialize the value. This
|
will create a .rela.got relocation entry to
|
||||||
is done in the finish_dynamic_symbol routine. */
|
initialize the value. This is done in the
|
||||||
|
finish_dynamic_symbol routine. */
|
||||||
if ((off & 1) != 0)
|
if ((off & 1) != 0)
|
||||||
off &= ~1;
|
off &= ~1;
|
||||||
else
|
else
|
||||||
|
@ -1561,9 +1560,13 @@ elf_cris_finish_dynamic_symbol (output_bfd, info, h, sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't emit .got relocs for symbols that aren't in the
|
/* We don't emit .got relocs for symbols that aren't in the
|
||||||
dynamic-symbols table for an ordinary program. */
|
dynamic-symbols table for an ordinary program and are either defined
|
||||||
|
by the program or are undefined weak symbols. */
|
||||||
if (h->got.offset != (bfd_vma) -1
|
if (h->got.offset != (bfd_vma) -1
|
||||||
&& (info->shared || h->dynindx != -1))
|
&& (info->shared
|
||||||
|
|| (h->dynindx != -1
|
||||||
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
|
||||||
|
&& h->root.type != bfd_link_hash_undefweak)))
|
||||||
{
|
{
|
||||||
asection *sgot;
|
asection *sgot;
|
||||||
asection *srela;
|
asection *srela;
|
||||||
|
@ -2067,23 +2070,23 @@ elf_cris_adjust_dynamic_symbol (info, h)
|
||||||
if (h->type == STT_FUNC
|
if (h->type == STT_FUNC
|
||||||
|| (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
|
|| (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
|
||||||
{
|
{
|
||||||
|
/* If we link a program (not a DSO), we'll get rid of unnecessary
|
||||||
|
PLT entries; we point to the actual symbols -- even for pic
|
||||||
|
relocs, because a program built with -fpic should have the same
|
||||||
|
result as one built without -fpic, specifically considering weak
|
||||||
|
symbols.
|
||||||
|
FIXME: m68k and i386 differ here, for unclear reasons. */
|
||||||
if (! info->shared
|
if (! info->shared
|
||||||
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0)
|
||||||
&& (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
|
|
||||||
/* We must always create the plt entry if it was referenced by a
|
|
||||||
PLT relocation. In this case we already recorded it as a
|
|
||||||
dynamic symbol. */
|
|
||||||
/* FIXME: m68k and i386 differ here, for unclear reasons. */
|
|
||||||
&& h->dynindx == -1)
|
|
||||||
{
|
{
|
||||||
/* This case can occur if we saw a PLT reloc in an input file,
|
/* This case can occur if we saw a PLT reloc in an input file,
|
||||||
but the symbol was never referred to by a dynamic object. In
|
but the symbol was not defined by a dynamic object. In such
|
||||||
such a case, we don't actually need to build a procedure
|
a case, we don't actually need to build a procedure linkage
|
||||||
linkage table, and we can just do a PC reloc instead, or
|
table, and we can just do an absolute or PC reloc instead, or
|
||||||
change a .got.plt index to a .got index for GOTPLT relocs. */
|
change a .got.plt index to a .got index for GOTPLT relocs. */
|
||||||
BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
|
BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
|
||||||
|
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
|
||||||
h->plt.offset = (bfd_vma) -1;
|
h->plt.offset = (bfd_vma) -1;
|
||||||
|
|
||||||
return
|
return
|
||||||
elf_cris_adjust_gotplt_to_got ((struct
|
elf_cris_adjust_gotplt_to_got ((struct
|
||||||
elf_cris_link_hash_entry *) h,
|
elf_cris_link_hash_entry *) h,
|
||||||
|
@ -2121,9 +2124,7 @@ elf_cris_adjust_dynamic_symbol (info, h)
|
||||||
|
|
||||||
/* If this symbol is not defined in a regular file, and we are
|
/* If this symbol is not defined in a regular file, and we are
|
||||||
not generating a shared library, then set the symbol to this
|
not generating a shared library, then set the symbol to this
|
||||||
location in the .plt. This is required to make function
|
location in the .plt. */
|
||||||
pointers compare as equal between the normal executable and
|
|
||||||
the shared library. */
|
|
||||||
if (!info->shared
|
if (!info->shared
|
||||||
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
||||||
{
|
{
|
||||||
|
@ -2907,10 +2908,9 @@ elf_cris_discard_excess_program_dynamics (h, inf)
|
||||||
|
|
||||||
/* If we're not creating a shared library and have a symbol which is
|
/* If we're not creating a shared library and have a symbol which is
|
||||||
referred to by .got references, but the symbol is defined locally,
|
referred to by .got references, but the symbol is defined locally,
|
||||||
(or rather, not referred to by a DSO and not defined by a DSO) then
|
(or rather, not not defined by a DSO) then lose the reloc for the
|
||||||
lose the reloc for the .got (don't allocate room for it). */
|
.got (don't allocate room for it). */
|
||||||
if ((h->root.elf_link_hash_flags
|
if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0)
|
||||||
& (ELF_LINK_HASH_REF_DYNAMIC | ELF_LINK_HASH_DEF_DYNAMIC)) == 0)
|
|
||||||
{
|
{
|
||||||
if (h->root.got.refcount > 0
|
if (h->root.got.refcount > 0
|
||||||
/* The size of this section is only valid and in sync with the
|
/* The size of this section is only valid and in sync with the
|
||||||
|
|
Loading…
Reference in New Issue