aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf64-ppc.c141
2 files changed, 80 insertions, 66 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ce948c8..cffa777 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-10-04 Alan Modra <amodra@gmail.com>
+
+ * elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't sort or
+ classify symbols for ELFv2.
+
2017-10-04 Pavel I. Kryukov <kryukov@frtk.ru>
PR 22245
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)