diff options
author | Alan Modra <amodra@gmail.com> | 2017-10-04 09:54:52 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-10-04 14:25:37 +1030 |
commit | a5259595e7a6faac0240d257f7e9cfa599557d2e (patch) | |
tree | e0bd338df3d798db557c1cb3fde0bd78684084d2 /bfd/elf64-ppc.c | |
parent | 9ba5f27cdd15d22d6c5739ff5d2b1c81d796e114 (diff) | |
download | gdb-a5259595e7a6faac0240d257f7e9cfa599557d2e.zip gdb-a5259595e7a6faac0240d257f7e9cfa599557d2e.tar.gz gdb-a5259595e7a6faac0240d257f7e9cfa599557d2e.tar.bz2 |
PowerPC64 ELFv2 symbols not needed in get_synthetic_symtab
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't sort or
classify symbols for ELFv2.
Diffstat (limited to 'bfd/elf64-ppc.c')
-rw-r--r-- | bfd/elf64-ppc.c | 141 |
1 files changed, 75 insertions, 66 deletions
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 63c8984..53ea30e 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3270,77 +3270,86 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, return 0; } - symcount = static_count; - if (!relocatable) - symcount += dyn_count; - if (symcount == 0) - return 0; - - syms = bfd_malloc ((symcount + 1) * sizeof (*syms)); - if (syms == NULL) - return -1; - - if (!relocatable && static_count != 0 && dyn_count != 0) + syms = NULL; + codesecsym = 0; + codesecsymend = 0; + secsymend = 0; + opdsymend = 0; + symcount = 0; + if (opd != NULL) { - /* Use both symbol tables. */ - memcpy (syms, static_syms, static_count * sizeof (*syms)); - memcpy (syms + static_count, dyn_syms, (dyn_count + 1) * sizeof (*syms)); - } - else if (!relocatable && static_count == 0) - memcpy (syms, dyn_syms, (symcount + 1) * sizeof (*syms)); - else - memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms)); - - synthetic_relocatable = relocatable; - synthetic_opd = opd; - qsort (syms, symcount, sizeof (*syms), compare_symbols); - - if (!relocatable && symcount > 1) - { - long j; - /* Trim duplicate syms, since we may have merged the normal and - dynamic symbols. Actually, we only care about syms that have - different values, so trim any with the same value. */ - for (i = 1, j = 1; i < symcount; ++i) - if (syms[i - 1]->value + syms[i - 1]->section->vma - != syms[i]->value + syms[i]->section->vma) - syms[j++] = syms[i]; - symcount = j; - } - - i = 0; - /* Note that here and in compare_symbols we can't compare opd and - sym->section directly. With separate debug info files, the - symbols will be extracted from the debug file while abfd passed - to this function is the real binary. */ - if (opd != NULL && strcmp (syms[i]->section->name, ".opd") == 0) - ++i; - codesecsym = i; - - for (; i < symcount; ++i) - if (((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) - != (SEC_CODE | SEC_ALLOC)) - || (syms[i]->flags & BSF_SECTION_SYM) == 0) - break; - codesecsymend = i; + symcount = static_count; + if (!relocatable) + symcount += dyn_count; + if (symcount == 0) + return 0; - for (; i < symcount; ++i) - if ((syms[i]->flags & BSF_SECTION_SYM) == 0) - break; - secsymend = i; + syms = bfd_malloc ((symcount + 1) * sizeof (*syms)); + if (syms == NULL) + return -1; - if (opd != NULL) - for (; i < symcount; ++i) - if (strcmp (syms[i]->section->name, ".opd") != 0) - break; - opdsymend = i; + if (!relocatable && static_count != 0 && dyn_count != 0) + { + /* Use both symbol tables. */ + memcpy (syms, static_syms, static_count * sizeof (*syms)); + memcpy (syms + static_count, dyn_syms, + (dyn_count + 1) * sizeof (*syms)); + } + else if (!relocatable && static_count == 0) + memcpy (syms, dyn_syms, (symcount + 1) * sizeof (*syms)); + else + memcpy (syms, static_syms, (symcount + 1) * sizeof (*syms)); + + synthetic_relocatable = relocatable; + synthetic_opd = opd; + qsort (syms, symcount, sizeof (*syms), compare_symbols); + + if (!relocatable && symcount > 1) + { + long j; + /* Trim duplicate syms, since we may have merged the normal and + dynamic symbols. Actually, we only care about syms that have + different values, so trim any with the same value. */ + for (i = 1, j = 1; i < symcount; ++i) + if (syms[i - 1]->value + syms[i - 1]->section->vma + != syms[i]->value + syms[i]->section->vma) + syms[j++] = syms[i]; + symcount = j; + } + + i = 0; + /* Note that here and in compare_symbols we can't compare opd and + sym->section directly. With separate debug info files, the + symbols will be extracted from the debug file while abfd passed + to this function is the real binary. */ + if (opd != NULL && strcmp (syms[i]->section->name, ".opd") == 0) + ++i; + codesecsym = i; + + for (; i < symcount; ++i) + if (((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC + | SEC_THREAD_LOCAL)) + != (SEC_CODE | SEC_ALLOC)) + || (syms[i]->flags & BSF_SECTION_SYM) == 0) + break; + codesecsymend = i; - for (; i < symcount; ++i) - if ((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) - != (SEC_CODE | SEC_ALLOC)) - break; - symcount = i; + for (; i < symcount; ++i) + if ((syms[i]->flags & BSF_SECTION_SYM) == 0) + break; + secsymend = i; + + for (; i < symcount; ++i) + if (strcmp (syms[i]->section->name, ".opd") != 0) + break; + opdsymend = i; + for (; i < symcount; ++i) + if ((syms[i]->section->flags & (SEC_CODE | SEC_ALLOC | SEC_THREAD_LOCAL)) + != (SEC_CODE | SEC_ALLOC)) + break; + symcount = i; + } count = 0; if (relocatable) |