mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
* linker.c (_bfd_generic_final_link): Set "linker_mark" for
all sections that will be included in the output file. (_bfd_generic_link_output_symbols): Discard symbols in sections which are being discarded. Fixes 4 failures in the g++ testsuite on the v850.
This commit is contained in:
@ -1,6 +1,11 @@
|
|||||||
start-sanitize-v850
|
|
||||||
Wed Oct 16 11:24:35 1996 Jeffrey A Law (law@cygnus.com)
|
Wed Oct 16 11:24:35 1996 Jeffrey A Law (law@cygnus.com)
|
||||||
|
|
||||||
|
* linker.c (_bfd_generic_final_link): Set "linker_mark" for
|
||||||
|
all sections that will be included in the output file.
|
||||||
|
(_bfd_generic_link_output_symbols): Discard symbols in sections
|
||||||
|
which are being discarded.
|
||||||
|
|
||||||
|
start-sanitize-v850
|
||||||
* elf32-v850.c (bfd_elf32_v850_reloc): Mask out bits we
|
* elf32-v850.c (bfd_elf32_v850_reloc): Mask out bits we
|
||||||
no longer want in pc-relative relocs.
|
no longer want in pc-relative relocs.
|
||||||
|
|
||||||
|
47
bfd/linker.c
47
bfd/linker.c
@ -1521,11 +1521,13 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->notice_hash != (struct bfd_hash_table *) NULL
|
if (info->notice_all
|
||||||
|
|| (info->notice_hash != (struct bfd_hash_table *) NULL
|
||||||
&& (bfd_hash_lookup (info->notice_hash, name, false, false)
|
&& (bfd_hash_lookup (info->notice_hash, name, false, false)
|
||||||
!= (struct bfd_hash_entry *) NULL))
|
!= (struct bfd_hash_entry *) NULL)))
|
||||||
{
|
{
|
||||||
if (! (*info->callbacks->notice) (info, name, abfd, section, value))
|
if (! (*info->callbacks->notice) (info, h->root.string, abfd, section,
|
||||||
|
value))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,7 +1567,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
previously common. */
|
previously common. */
|
||||||
BFD_ASSERT (h->type == bfd_link_hash_common);
|
BFD_ASSERT (h->type == bfd_link_hash_common);
|
||||||
if (! ((*info->callbacks->multiple_common)
|
if (! ((*info->callbacks->multiple_common)
|
||||||
(info, name,
|
(info, h->root.string,
|
||||||
h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
|
h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
|
||||||
abfd, bfd_link_hash_defined, (bfd_vma) 0)))
|
abfd, bfd_link_hash_defined, (bfd_vma) 0)))
|
||||||
return false;
|
return false;
|
||||||
@ -1628,7 +1630,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
if (! ((*info->callbacks->constructor)
|
if (! ((*info->callbacks->constructor)
|
||||||
(info,
|
(info,
|
||||||
c == 'I' ? true : false,
|
c == 'I' ? true : false,
|
||||||
name, abfd, section, value)))
|
h->root.string, abfd, section, value)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1699,7 +1701,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
two sizes. */
|
two sizes. */
|
||||||
BFD_ASSERT (h->type == bfd_link_hash_common);
|
BFD_ASSERT (h->type == bfd_link_hash_common);
|
||||||
if (! ((*info->callbacks->multiple_common)
|
if (! ((*info->callbacks->multiple_common)
|
||||||
(info, name,
|
(info, h->root.string,
|
||||||
h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
|
h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
|
||||||
abfd, bfd_link_hash_common, value)))
|
abfd, bfd_link_hash_common, value)))
|
||||||
return false;
|
return false;
|
||||||
@ -1732,7 +1734,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
else
|
else
|
||||||
obfd = NULL;
|
obfd = NULL;
|
||||||
if (! ((*info->callbacks->multiple_common)
|
if (! ((*info->callbacks->multiple_common)
|
||||||
(info, name, obfd, h->type, (bfd_vma) 0,
|
(info, h->root.string, obfd, h->type, (bfd_vma) 0,
|
||||||
abfd, bfd_link_hash_common, value)))
|
abfd, bfd_link_hash_common, value)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1773,8 +1775,8 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (! ((*info->callbacks->multiple_definition)
|
if (! ((*info->callbacks->multiple_definition)
|
||||||
(info, name, msec->owner, msec, mval, abfd, section,
|
(info, h->root.string, msec->owner, msec, mval, abfd,
|
||||||
value)))
|
section, value)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1783,7 +1785,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
/* Create an indirect symbol from an existing common symbol. */
|
/* Create an indirect symbol from an existing common symbol. */
|
||||||
BFD_ASSERT (h->type == bfd_link_hash_common);
|
BFD_ASSERT (h->type == bfd_link_hash_common);
|
||||||
if (! ((*info->callbacks->multiple_common)
|
if (! ((*info->callbacks->multiple_common)
|
||||||
(info, name,
|
(info, h->root.string,
|
||||||
h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
|
h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size,
|
||||||
abfd, bfd_link_hash_indirect, (bfd_vma) 0)))
|
abfd, bfd_link_hash_indirect, (bfd_vma) 0)))
|
||||||
return false;
|
return false;
|
||||||
@ -1831,8 +1833,9 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
/* Issue a warning and cycle. */
|
/* Issue a warning and cycle. */
|
||||||
if (h->u.i.warning != NULL)
|
if (h->u.i.warning != NULL)
|
||||||
{
|
{
|
||||||
if (! (*info->callbacks->warning) (info, h->u.i.warning, name,
|
if (! (*info->callbacks->warning) (info, h->u.i.warning,
|
||||||
abfd, (asection *) NULL,
|
h->root.string, abfd,
|
||||||
|
(asection *) NULL,
|
||||||
(bfd_vma) 0))
|
(bfd_vma) 0))
|
||||||
return false;
|
return false;
|
||||||
/* Only issue a warning once. */
|
/* Only issue a warning once. */
|
||||||
@ -1855,7 +1858,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
|
|
||||||
case WARN:
|
case WARN:
|
||||||
/* Issue a warning. */
|
/* Issue a warning. */
|
||||||
if (! (*info->callbacks->warning) (info, string, name,
|
if (! (*info->callbacks->warning) (info, string, h->root.string,
|
||||||
hash_entry_bfd (h),
|
hash_entry_bfd (h),
|
||||||
(asection *) NULL, (bfd_vma) 0))
|
(asection *) NULL, (bfd_vma) 0))
|
||||||
return false;
|
return false;
|
||||||
@ -1869,7 +1872,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
|||||||
ensure this. */
|
ensure this. */
|
||||||
if (h->next != NULL || info->hash->undefs_tail == h)
|
if (h->next != NULL || info->hash->undefs_tail == h)
|
||||||
{
|
{
|
||||||
if (! (*info->callbacks->warning) (info, string, name,
|
if (! (*info->callbacks->warning) (info, string, h->root.string,
|
||||||
hash_entry_bfd (h),
|
hash_entry_bfd (h),
|
||||||
(asection *) NULL,
|
(asection *) NULL,
|
||||||
(bfd_vma) 0))
|
(bfd_vma) 0))
|
||||||
@ -1937,6 +1940,12 @@ _bfd_generic_final_link (abfd, info)
|
|||||||
abfd->symcount = 0;
|
abfd->symcount = 0;
|
||||||
outsymalloc = 0;
|
outsymalloc = 0;
|
||||||
|
|
||||||
|
/* Mark all sections which will be included in the output file. */
|
||||||
|
for (o = abfd->sections; o != NULL; o = o->next)
|
||||||
|
for (p = o->link_order_head; p != NULL; p = p->next)
|
||||||
|
if (p->type == bfd_indirect_link_order)
|
||||||
|
p->u.indirect.section->linker_mark = true;
|
||||||
|
|
||||||
/* Build the output symbol table. */
|
/* Build the output symbol table. */
|
||||||
for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
|
for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
|
||||||
if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc))
|
if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc))
|
||||||
@ -2221,10 +2230,11 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
|||||||
|
|
||||||
/* This switch is straight from the old code in
|
/* This switch is straight from the old code in
|
||||||
write_file_locals in ldsym.c. */
|
write_file_locals in ldsym.c. */
|
||||||
if (info->strip == strip_some
|
if (info->strip == strip_all
|
||||||
|
|| (info->strip == strip_some
|
||||||
&& (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
|
&& (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
|
||||||
false, false)
|
false, false)
|
||||||
== (struct bfd_hash_entry *) NULL))
|
== (struct bfd_hash_entry *) NULL)))
|
||||||
output = false;
|
output = false;
|
||||||
else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
|
else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
|
||||||
{
|
{
|
||||||
@ -2287,6 +2297,11 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
|||||||
else
|
else
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
|
/* If this symbol is in a section which is not being included
|
||||||
|
in the output file, then we don't want to output the symbol. */
|
||||||
|
if (sym->section->linker_mark == false)
|
||||||
|
output = false;
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
if (! generic_add_output_symbol (output_bfd, psymalloc, sym))
|
if (! generic_add_output_symbol (output_bfd, psymalloc, sym))
|
||||||
|
Reference in New Issue
Block a user