mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 20:28:28 +08:00
* elf.c (elf_map_symbols): Don't create new section symbols; Use
existing section syms. Update comments. (copy_private_bfd_data): Formatting fixes. (elfcore_grok_win32pstatus): Likewise. (swap_out_syms): Likewise. Remove unnecessary level of braces.
This commit is contained in:
@ -1,3 +1,11 @@
|
||||
2001-10-10 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf.c (elf_map_symbols): Don't create new section symbols; Use
|
||||
existing section syms. Update comments.
|
||||
(copy_private_bfd_data): Formatting fixes.
|
||||
(elfcore_grok_win32pstatus): Likewise.
|
||||
(swap_out_syms): Likewise. Remove unnecessary level of braces.
|
||||
|
||||
2001-10-09 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf-bfd.h (struct bfd_elf_section_data): Rename "group" to
|
||||
|
106
bfd/elf.c
106
bfd/elf.c
@ -2387,7 +2387,6 @@ elf_map_symbols (abfd)
|
||||
unsigned int num_locals2 = 0;
|
||||
unsigned int num_globals2 = 0;
|
||||
int max_index = 0;
|
||||
unsigned int num_sections = 0;
|
||||
unsigned int idx;
|
||||
asection *asect;
|
||||
asymbol **new_syms;
|
||||
@ -2398,8 +2397,6 @@ elf_map_symbols (abfd)
|
||||
fflush (stderr);
|
||||
#endif
|
||||
|
||||
/* Add a section symbol for each BFD section. FIXME: Is this really
|
||||
necessary? */
|
||||
for (asect = abfd->sections; asect; asect = asect->next)
|
||||
{
|
||||
if (max_index < asect->index)
|
||||
@ -2414,6 +2411,8 @@ elf_map_symbols (abfd)
|
||||
elf_section_syms (abfd) = sect_syms;
|
||||
elf_num_section_syms (abfd) = max_index;
|
||||
|
||||
/* Init sect_syms entries for any section symbols we have already
|
||||
decided to output. */
|
||||
for (idx = 0; idx < symcount; idx++)
|
||||
{
|
||||
asymbol *sym = syms[idx];
|
||||
@ -2434,15 +2433,16 @@ elf_map_symbols (abfd)
|
||||
|
||||
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. */
|
||||
/* 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;
|
||||
|
||||
@ -2453,31 +2453,6 @@ elf_map_symbols (abfd)
|
||||
}
|
||||
}
|
||||
|
||||
for (asect = abfd->sections; asect; asect = asect->next)
|
||||
{
|
||||
asymbol *sym;
|
||||
|
||||
if (sect_syms[asect->index] != NULL)
|
||||
continue;
|
||||
|
||||
sym = bfd_make_empty_symbol (abfd);
|
||||
if (sym == NULL)
|
||||
return false;
|
||||
sym->the_bfd = abfd;
|
||||
sym->name = asect->name;
|
||||
sym->value = 0;
|
||||
/* Set the flags to 0 to indicate that this one was newly added. */
|
||||
sym->flags = 0;
|
||||
sym->section = asect;
|
||||
sect_syms[asect->index] = sym;
|
||||
num_sections++;
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr,
|
||||
_("creating section symbol, name = %s, value = 0x%.8lx, index = %d, section = 0x%.8lx\n"),
|
||||
asect->name, (long) asect->vma, asect->index, (long) asect);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Classify all of the symbols. */
|
||||
for (idx = 0; idx < symcount; idx++)
|
||||
{
|
||||
@ -2486,17 +2461,19 @@ elf_map_symbols (abfd)
|
||||
else
|
||||
num_globals++;
|
||||
}
|
||||
|
||||
/* We will be adding a section symbol for each BFD section. Most normal
|
||||
sections will already have a section symbol in outsymbols, but
|
||||
eg. SHT_GROUP sections will not, and we need the section symbol mapped
|
||||
at least in that case. */
|
||||
for (asect = abfd->sections; asect; asect = asect->next)
|
||||
{
|
||||
if (sect_syms[asect->index] != NULL
|
||||
&& sect_syms[asect->index]->flags == 0)
|
||||
if (sect_syms[asect->index] == NULL)
|
||||
{
|
||||
sect_syms[asect->index]->flags = BSF_SECTION_SYM;
|
||||
if (!sym_is_global (abfd, sect_syms[asect->index]))
|
||||
if (!sym_is_global (abfd, asect->symbol))
|
||||
num_locals++;
|
||||
else
|
||||
num_globals++;
|
||||
sect_syms[asect->index]->flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2521,13 +2498,12 @@ elf_map_symbols (abfd)
|
||||
}
|
||||
for (asect = abfd->sections; asect; asect = asect->next)
|
||||
{
|
||||
if (sect_syms[asect->index] != NULL
|
||||
&& sect_syms[asect->index]->flags == 0)
|
||||
if (sect_syms[asect->index] == NULL)
|
||||
{
|
||||
asymbol *sym = sect_syms[asect->index];
|
||||
asymbol *sym = asect->symbol;
|
||||
unsigned int i;
|
||||
|
||||
sym->flags = BSF_SECTION_SYM;
|
||||
sect_syms[asect->index] = sym;
|
||||
if (!sym_is_global (abfd, sym))
|
||||
i = num_locals2++;
|
||||
else
|
||||
@ -4233,7 +4209,8 @@ copy_private_bfd_data (ibfd, obfd)
|
||||
? iehdr->e_ehsize
|
||||
: 0)
|
||||
+ (map->includes_phdrs
|
||||
? iehdr->e_phnum * iehdr->e_phentsize
|
||||
? (iehdr->e_phnum
|
||||
* iehdr->e_phentsize)
|
||||
: 0))))
|
||||
map->p_paddr = segment->p_vaddr;
|
||||
|
||||
@ -4358,9 +4335,11 @@ copy_private_bfd_data (ibfd, obfd)
|
||||
/* If the gap between the end of the previous section
|
||||
and the start of this section is more than
|
||||
maxpagesize then we need to start a new segment. */
|
||||
if ((BFD_ALIGN (prev_sec->lma + prev_sec->_raw_size, maxpagesize)
|
||||
if ((BFD_ALIGN (prev_sec->lma + prev_sec->_raw_size,
|
||||
maxpagesize)
|
||||
< BFD_ALIGN (output_section->lma, maxpagesize))
|
||||
|| ((prev_sec->lma + prev_sec->_raw_size) > output_section->lma))
|
||||
|| ((prev_sec->lma + prev_sec->_raw_size)
|
||||
> output_section->lma))
|
||||
{
|
||||
if (suggested_lma == 0)
|
||||
suggested_lma = output_section->lma;
|
||||
@ -4592,15 +4571,9 @@ swap_out_syms (abfd, sttp, relocatable_p)
|
||||
struct bfd_strtab_hash **sttp;
|
||||
int relocatable_p;
|
||||
{
|
||||
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
|
||||
if (!elf_map_symbols (abfd))
|
||||
return false;
|
||||
|
||||
/* Dump out the symtabs. */
|
||||
{
|
||||
int symcount = bfd_get_symcount (abfd);
|
||||
asymbol **syms = bfd_get_outsymbols (abfd);
|
||||
struct elf_backend_data *bed;
|
||||
int symcount;
|
||||
asymbol **syms;
|
||||
struct bfd_strtab_hash *stt;
|
||||
Elf_Internal_Shdr *symtab_hdr;
|
||||
Elf_Internal_Shdr *symstrtab_hdr;
|
||||
@ -4608,10 +4581,16 @@ swap_out_syms (abfd, sttp, relocatable_p)
|
||||
int idx;
|
||||
bfd_size_type amt;
|
||||
|
||||
if (!elf_map_symbols (abfd))
|
||||
return false;
|
||||
|
||||
/* Dump out the symtabs. */
|
||||
stt = _bfd_elf_stringtab_init ();
|
||||
if (stt == NULL)
|
||||
return false;
|
||||
|
||||
bed = get_elf_backend_data (abfd);
|
||||
symcount = bfd_get_symcount (abfd);
|
||||
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
||||
symtab_hdr->sh_type = SHT_SYMTAB;
|
||||
symtab_hdr->sh_entsize = bed->s->sizeof_sym;
|
||||
@ -4641,6 +4620,8 @@ swap_out_syms (abfd, sttp, relocatable_p)
|
||||
bed->s->swap_symbol_out (abfd, &sym, (PTR) outbound_syms);
|
||||
outbound_syms += bed->s->sizeof_sym;
|
||||
}
|
||||
|
||||
syms = bfd_get_outsymbols (abfd);
|
||||
for (idx = 0; idx < symcount; idx++)
|
||||
{
|
||||
Elf_Internal_Sym sym;
|
||||
@ -4757,7 +4738,8 @@ swap_out_syms (abfd, sttp, relocatable_p)
|
||||
/* Processor-specific types */
|
||||
if (type_ptr != NULL
|
||||
&& bed->elf_backend_get_symbol_type)
|
||||
type = (*bed->elf_backend_get_symbol_type) (&type_ptr->internal_elf_sym, type);
|
||||
type = ((*bed->elf_backend_get_symbol_type)
|
||||
(&type_ptr->internal_elf_sym, type));
|
||||
|
||||
if (flags & BSF_SECTION_SYM)
|
||||
{
|
||||
@ -4808,7 +4790,6 @@ swap_out_syms (abfd, sttp, relocatable_p)
|
||||
symstrtab_hdr->sh_link = 0;
|
||||
symstrtab_hdr->sh_info = 0;
|
||||
symstrtab_hdr->sh_addralign = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -6032,8 +6013,9 @@ elfcore_grok_win32pstatus (abfd, note)
|
||||
return false;
|
||||
|
||||
sect->_raw_size = sizeof (pstatus.data.thread_info.thread_context);
|
||||
sect->filepos = note->descpos + offsetof (struct win32_pstatus,
|
||||
data.thread_info.thread_context);
|
||||
sect->filepos = (note->descpos
|
||||
+ offsetof (struct win32_pstatus,
|
||||
data.thread_info.thread_context));
|
||||
sect->flags = SEC_HAS_CONTENTS;
|
||||
sect->alignment_power = 2;
|
||||
|
||||
|
Reference in New Issue
Block a user