mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-01 09:49:43 +08:00
* elf.c (sym_is_global): Return a bfd_boolean.
(ignore_section_sym): New function. (elf_map_symbols): Use ignore_section_sym to discard some syms. (_bfd_elf_symbol_from_bfd_symbol): Ensure section belongs to bfd before using elf_section_syms.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2006-05-26 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* elf.c (sym_is_global): Return a bfd_boolean.
|
||||||
|
(ignore_section_sym): New function.
|
||||||
|
(elf_map_symbols): Use ignore_section_sym to discard some syms.
|
||||||
|
(_bfd_elf_symbol_from_bfd_symbol): Ensure section belongs to
|
||||||
|
bfd before using elf_section_syms.
|
||||||
|
|
||||||
2006-05-25 H.J. Lu <hongjiu.lu@intel.com>
|
2006-05-25 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* config.bfd: (sh-*-linux*): Treat as 64bit target.
|
* config.bfd: (sh-*-linux*): Treat as 64bit target.
|
||||||
|
67
bfd/elf.c
67
bfd/elf.c
@ -3280,7 +3280,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
|
|||||||
/* Map symbol from it's internal number to the external number, moving
|
/* Map symbol from it's internal number to the external number, moving
|
||||||
all local symbols to be at the head of the list. */
|
all local symbols to be at the head of the list. */
|
||||||
|
|
||||||
static int
|
static bfd_boolean
|
||||||
sym_is_global (bfd *abfd, asymbol *sym)
|
sym_is_global (bfd *abfd, asymbol *sym)
|
||||||
{
|
{
|
||||||
/* If the backend has a special mapping, use it. */
|
/* If the backend has a special mapping, use it. */
|
||||||
@ -3293,6 +3293,20 @@ sym_is_global (bfd *abfd, asymbol *sym)
|
|||||||
|| bfd_is_com_section (bfd_get_section (sym)));
|
|| bfd_is_com_section (bfd_get_section (sym)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Don't output section symbols for sections that are not going to be
|
||||||
|
output. Also, don't output section symbols for reloc and other
|
||||||
|
special sections. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
ignore_section_sym (bfd *abfd, asymbol *sym)
|
||||||
|
{
|
||||||
|
return ((sym->flags & BSF_SECTION_SYM) != 0
|
||||||
|
&& (sym->value != 0
|
||||||
|
|| (sym->section->owner != abfd
|
||||||
|
&& (sym->section->output_section->owner != abfd
|
||||||
|
|| sym->section->output_offset != 0))));
|
||||||
|
}
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
elf_map_symbols (bfd *abfd)
|
elf_map_symbols (bfd *abfd)
|
||||||
{
|
{
|
||||||
@ -3333,51 +3347,29 @@ elf_map_symbols (bfd *abfd)
|
|||||||
asymbol *sym = syms[idx];
|
asymbol *sym = syms[idx];
|
||||||
|
|
||||||
if ((sym->flags & BSF_SECTION_SYM) != 0
|
if ((sym->flags & BSF_SECTION_SYM) != 0
|
||||||
&& sym->value == 0)
|
&& !ignore_section_sym (abfd, sym))
|
||||||
{
|
{
|
||||||
asection *sec;
|
asection *sec = sym->section;
|
||||||
|
|
||||||
sec = sym->section;
|
if (sec->owner != abfd)
|
||||||
|
sec = sec->output_section;
|
||||||
|
|
||||||
if (sec->owner != NULL)
|
sect_syms[sec->index] = syms[idx];
|
||||||
{
|
|
||||||
if (sec->owner != abfd)
|
|
||||||
{
|
|
||||||
if (sec->output_offset != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sec = sec->output_section;
|
|
||||||
|
|
||||||
/* Empty sections in the input files may have had a
|
|
||||||
section symbol created for them. (See the comment
|
|
||||||
near the end of _bfd_generic_link_output_symbols in
|
|
||||||
linker.c). If the linker script discards such
|
|
||||||
sections then we will reach this point. Since we know
|
|
||||||
that we cannot avoid this case, we detect it and skip
|
|
||||||
the abort and the assignment to the sect_syms array.
|
|
||||||
To reproduce this particular case try running the
|
|
||||||
linker testsuite test ld-scripts/weak.exp for an ELF
|
|
||||||
port that uses the generic linker. */
|
|
||||||
if (sec->owner == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BFD_ASSERT (sec->owner == abfd);
|
|
||||||
}
|
|
||||||
sect_syms[sec->index] = syms[idx];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Classify all of the symbols. */
|
/* Classify all of the symbols. */
|
||||||
for (idx = 0; idx < symcount; idx++)
|
for (idx = 0; idx < symcount; idx++)
|
||||||
{
|
{
|
||||||
|
if (ignore_section_sym (abfd, syms[idx]))
|
||||||
|
continue;
|
||||||
if (!sym_is_global (abfd, syms[idx]))
|
if (!sym_is_global (abfd, syms[idx]))
|
||||||
num_locals++;
|
num_locals++;
|
||||||
else
|
else
|
||||||
num_globals++;
|
num_globals++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We will be adding a section symbol for each BFD section. Most normal
|
/* We will be adding a section symbol for each normal BFD section. Most
|
||||||
sections will already have a section symbol in outsymbols, but
|
sections will already have a section symbol in outsymbols, but
|
||||||
eg. SHT_GROUP sections will not, and we need the section symbol mapped
|
eg. SHT_GROUP sections will not, and we need the section symbol mapped
|
||||||
at least in that case. */
|
at least in that case. */
|
||||||
@ -3403,6 +3395,8 @@ elf_map_symbols (bfd *abfd)
|
|||||||
asymbol *sym = syms[idx];
|
asymbol *sym = syms[idx];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (ignore_section_sym (abfd, sym))
|
||||||
|
continue;
|
||||||
if (!sym_is_global (abfd, sym))
|
if (!sym_is_global (abfd, sym))
|
||||||
i = num_locals2++;
|
i = num_locals2++;
|
||||||
else
|
else
|
||||||
@ -5130,13 +5124,14 @@ _bfd_elf_symbol_from_bfd_symbol (bfd *abfd, asymbol **asym_ptr_ptr)
|
|||||||
&& (flags & BSF_SECTION_SYM)
|
&& (flags & BSF_SECTION_SYM)
|
||||||
&& asym_ptr->section)
|
&& asym_ptr->section)
|
||||||
{
|
{
|
||||||
|
asection *sec;
|
||||||
int indx;
|
int indx;
|
||||||
|
|
||||||
if (asym_ptr->section->output_section != NULL)
|
sec = asym_ptr->section;
|
||||||
indx = asym_ptr->section->output_section->index;
|
if (sec->owner != abfd && sec->output_section != NULL)
|
||||||
else
|
sec = sec->output_section;
|
||||||
indx = asym_ptr->section->index;
|
if (sec->owner == abfd
|
||||||
if (indx < elf_num_section_syms (abfd)
|
&& (indx = sec->index) < elf_num_section_syms (abfd)
|
||||||
&& elf_section_syms (abfd)[indx] != NULL)
|
&& elf_section_syms (abfd)[indx] != NULL)
|
||||||
asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
|
asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user