mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-26 19:44:11 +08:00
Revert "get_synthetic_symtab fixes for commit 68bbe1183379"
This reverts commit 0c13ac533e
.
This commit is contained in:
parent
e022977bc5
commit
9b09ceea7d
21
bfd/elf.c
21
bfd/elf.c
@ -13537,19 +13537,17 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd,
|
||||
size = count * sizeof (asymbol);
|
||||
p = relplt->relocation;
|
||||
for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
{
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
{
|
||||
#ifdef BFD64
|
||||
size += (sizeof ("+0x") - 1 + 8
|
||||
+ 8 * (bed->s->elfclass == ELFCLASS64));
|
||||
size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64);
|
||||
#else
|
||||
size += sizeof ("+0x") - 1 + 8;
|
||||
size += sizeof ("+0x") - 1 + 8;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s = *ret = (asymbol *) bfd_malloc (size);
|
||||
if (s == NULL)
|
||||
@ -13567,9 +13565,6 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd,
|
||||
if (addr == (bfd_vma) -1)
|
||||
continue;
|
||||
|
||||
if ((*p->sym_ptr_ptr)->name == NULL)
|
||||
continue;
|
||||
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
|
@ -20100,7 +20100,6 @@ elf32_arm_get_synthetic_symtab (bfd *abfd,
|
||||
char *names;
|
||||
asection *plt;
|
||||
bfd_vma offset;
|
||||
bfd_vma plt_size;
|
||||
bfd_byte *data;
|
||||
|
||||
*ret = NULL;
|
||||
@ -20135,12 +20134,11 @@ elf32_arm_get_synthetic_symtab (bfd *abfd,
|
||||
size = count * sizeof (asymbol);
|
||||
p = relplt->relocation;
|
||||
for (i = 0; i < count; i++, p += elf32_arm_size_info.int_rels_per_ext_rel)
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 8;
|
||||
}
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 8;
|
||||
}
|
||||
|
||||
offset = elf32_arm_plt0_size (abfd, data, plt->size);
|
||||
if (offset == (bfd_vma) -1
|
||||
@ -20151,19 +20149,16 @@ elf32_arm_get_synthetic_symtab (bfd *abfd,
|
||||
}
|
||||
|
||||
names = (char *) (s + count);
|
||||
for (i = 0, p = relplt->relocation, n = 0;
|
||||
i < count;
|
||||
i++, p += elf32_arm_size_info.int_rels_per_ext_rel, offset += plt_size)
|
||||
p = relplt->relocation;
|
||||
n = 0;
|
||||
for (i = 0; i < count; i++, p += elf32_arm_size_info.int_rels_per_ext_rel)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
plt_size = elf32_arm_plt_size (abfd, data, offset, plt->size);
|
||||
bfd_vma plt_size = elf32_arm_plt_size (abfd, data, offset, plt->size);
|
||||
if (plt_size == (bfd_vma) -1)
|
||||
break;
|
||||
|
||||
if ((*p->sym_ptr_ptr)->name == NULL)
|
||||
continue;
|
||||
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
@ -20193,6 +20188,7 @@ elf32_arm_get_synthetic_symtab (bfd *abfd,
|
||||
memcpy (names, "@plt", sizeof ("@plt"));
|
||||
names += sizeof ("@plt");
|
||||
++s, ++n;
|
||||
offset += plt_size;
|
||||
}
|
||||
|
||||
free (data);
|
||||
|
@ -1806,7 +1806,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
|
||||
bfd_vma stub_off;
|
||||
asymbol *s;
|
||||
arelent *p;
|
||||
size_t count, n, i, stub_delta;
|
||||
size_t count, i, stub_delta;
|
||||
size_t size;
|
||||
char *names;
|
||||
bfd_byte buf[4];
|
||||
@ -1935,12 +1935,11 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
|
||||
size = count * sizeof (asymbol);
|
||||
p = relplt->relocation;
|
||||
for (i = 0; i < count; i++, p++)
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 8;
|
||||
}
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 8;
|
||||
}
|
||||
|
||||
size += sizeof (asymbol) + sizeof ("__glink");
|
||||
|
||||
@ -1954,40 +1953,38 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
|
||||
stub_off = glink_vma - glink->vma;
|
||||
names = (char *) (s + count + 1 + (resolv_vma != 0));
|
||||
p = relplt->relocation + count - 1;
|
||||
for (n = 0, i = 0; i < count; i++)
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size_t len;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
stub_off -= stub_delta;
|
||||
if (strcmp ((*p->sym_ptr_ptr)->name, "__tls_get_addr_opt") == 0)
|
||||
stub_off -= 32;
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
if ((s->flags & BSF_LOCAL) == 0)
|
||||
s->flags |= BSF_GLOBAL;
|
||||
s->flags |= BSF_SYNTHETIC;
|
||||
s->section = glink;
|
||||
s->value = stub_off;
|
||||
s->name = names;
|
||||
s->udata.p = NULL;
|
||||
len = strlen ((*p->sym_ptr_ptr)->name);
|
||||
memcpy (names, (*p->sym_ptr_ptr)->name, len);
|
||||
names += len;
|
||||
if (p->addend != 0)
|
||||
{
|
||||
memcpy (names, "+0x", sizeof ("+0x") - 1);
|
||||
names += sizeof ("+0x") - 1;
|
||||
bfd_sprintf_vma (abfd, names, p->addend);
|
||||
names += strlen (names);
|
||||
}
|
||||
memcpy (names, "@plt", sizeof ("@plt"));
|
||||
names += sizeof ("@plt");
|
||||
++s;
|
||||
--p;
|
||||
++n;
|
||||
}
|
||||
stub_off -= stub_delta;
|
||||
if (strcmp ((*p->sym_ptr_ptr)->name, "__tls_get_addr_opt") == 0)
|
||||
stub_off -= 32;
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
if ((s->flags & BSF_LOCAL) == 0)
|
||||
s->flags |= BSF_GLOBAL;
|
||||
s->flags |= BSF_SYNTHETIC;
|
||||
s->section = glink;
|
||||
s->value = stub_off;
|
||||
s->name = names;
|
||||
s->udata.p = NULL;
|
||||
len = strlen ((*p->sym_ptr_ptr)->name);
|
||||
memcpy (names, (*p->sym_ptr_ptr)->name, len);
|
||||
names += len;
|
||||
if (p->addend != 0)
|
||||
{
|
||||
memcpy (names, "+0x", sizeof ("+0x") - 1);
|
||||
names += sizeof ("+0x") - 1;
|
||||
bfd_sprintf_vma (abfd, names, p->addend);
|
||||
names += strlen (names);
|
||||
}
|
||||
memcpy (names, "@plt", sizeof ("@plt"));
|
||||
names += sizeof ("@plt");
|
||||
++s;
|
||||
--p;
|
||||
}
|
||||
|
||||
/* Add a symbol at the start of the glink branch table. */
|
||||
memset (s, 0, sizeof *s);
|
||||
@ -1999,7 +1996,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
|
||||
memcpy (names, "__glink", sizeof ("__glink"));
|
||||
names += sizeof ("__glink");
|
||||
s++;
|
||||
n++;
|
||||
count++;
|
||||
|
||||
if (resolv_vma)
|
||||
{
|
||||
@ -2013,10 +2010,10 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
|
||||
memcpy (names, "__glink_PLTresolve", sizeof ("__glink_PLTresolve"));
|
||||
names += sizeof ("__glink_PLTresolve");
|
||||
s++;
|
||||
n++;
|
||||
count++;
|
||||
}
|
||||
|
||||
return n;
|
||||
return count;
|
||||
}
|
||||
|
||||
/* The following functions are specific to the ELF linker, while
|
||||
|
@ -2402,8 +2402,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
||||
|
||||
sym = *r->sym_ptr_ptr;
|
||||
if (!sym_exists_at (syms, opdsymend, symcount,
|
||||
sym->section->id, sym->value + r->addend)
|
||||
&& syms[i]->name != NULL)
|
||||
sym->section->id, sym->value + r->addend))
|
||||
{
|
||||
++count;
|
||||
size += sizeof (asymbol);
|
||||
@ -2441,8 +2440,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
||||
|
||||
sym = *r->sym_ptr_ptr;
|
||||
if (!sym_exists_at (syms, opdsymend, symcount,
|
||||
sym->section->id, sym->value + r->addend)
|
||||
&& syms[i]->name != NULL)
|
||||
sym->section->id, sym->value + r->addend))
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@ -2493,8 +2491,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
||||
continue;
|
||||
|
||||
ent = bfd_get_64 (abfd, contents + syms[i]->value);
|
||||
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent)
|
||||
&& syms[i]->name != NULL)
|
||||
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent))
|
||||
{
|
||||
++count;
|
||||
size += sizeof (asymbol);
|
||||
@ -2582,12 +2579,11 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
||||
|
||||
p = relplt->relocation;
|
||||
for (i = 0; i < plt_count; i++, p++)
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 16;
|
||||
}
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2607,8 +2603,7 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
||||
continue;
|
||||
|
||||
ent = bfd_get_64 (abfd, contents + syms[i]->value);
|
||||
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent)
|
||||
&& syms[i]->name != NULL)
|
||||
if (!sym_exists_at (syms, opdsymend, symcount, -1, ent))
|
||||
{
|
||||
size_t lo, hi;
|
||||
size_t len;
|
||||
@ -2696,43 +2691,42 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
|
||||
for pending shared library loads. */
|
||||
p = relplt->relocation;
|
||||
for (i = 0; i < plt_count; i++, p++)
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size_t len;
|
||||
{
|
||||
size_t len;
|
||||
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
if ((s->flags & BSF_LOCAL) == 0)
|
||||
s->flags |= BSF_GLOBAL;
|
||||
s->flags |= BSF_SYNTHETIC;
|
||||
s->section = glink;
|
||||
s->value = glink_vma - glink->vma;
|
||||
s->name = names;
|
||||
s->udata.p = NULL;
|
||||
len = strlen ((*p->sym_ptr_ptr)->name);
|
||||
memcpy (names, (*p->sym_ptr_ptr)->name, len);
|
||||
names += len;
|
||||
if (p->addend != 0)
|
||||
{
|
||||
memcpy (names, "+0x", sizeof ("+0x") - 1);
|
||||
names += sizeof ("+0x") - 1;
|
||||
bfd_sprintf_vma (abfd, names, p->addend);
|
||||
names += strlen (names);
|
||||
}
|
||||
memcpy (names, "@plt", sizeof ("@plt"));
|
||||
names += sizeof ("@plt");
|
||||
s++;
|
||||
if (abi < 2)
|
||||
{
|
||||
glink_vma += 8;
|
||||
if (i >= 0x8000)
|
||||
glink_vma += 4;
|
||||
}
|
||||
else
|
||||
glink_vma += 4;
|
||||
count++;
|
||||
}
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
if ((s->flags & BSF_LOCAL) == 0)
|
||||
s->flags |= BSF_GLOBAL;
|
||||
s->flags |= BSF_SYNTHETIC;
|
||||
s->section = glink;
|
||||
s->value = glink_vma - glink->vma;
|
||||
s->name = names;
|
||||
s->udata.p = NULL;
|
||||
len = strlen ((*p->sym_ptr_ptr)->name);
|
||||
memcpy (names, (*p->sym_ptr_ptr)->name, len);
|
||||
names += len;
|
||||
if (p->addend != 0)
|
||||
{
|
||||
memcpy (names, "+0x", sizeof ("+0x") - 1);
|
||||
names += sizeof ("+0x") - 1;
|
||||
bfd_sprintf_vma (abfd, names, p->addend);
|
||||
names += strlen (names);
|
||||
}
|
||||
memcpy (names, "@plt", sizeof ("@plt"));
|
||||
names += sizeof ("@plt");
|
||||
s++;
|
||||
if (abi < 2)
|
||||
{
|
||||
glink_vma += 8;
|
||||
if (i >= 0x8000)
|
||||
glink_vma += 4;
|
||||
}
|
||||
else
|
||||
glink_vma += 4;
|
||||
}
|
||||
count += plt_count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16624,8 +16624,7 @@ _bfd_mips_elf_get_synthetic_symtab (bfd *abfd,
|
||||
size += count * (sizeof (mipssuffix) +
|
||||
(micromips_p ? sizeof (microsuffix) : sizeof (m16suffix)));
|
||||
for (pi = 0; pi < counti; pi += bed->s->int_rels_per_ext_rel)
|
||||
if ((*p[pi].sym_ptr_ptr)->name != NULL)
|
||||
size += 2 * strlen ((*p[pi].sym_ptr_ptr)->name);
|
||||
size += 2 * strlen ((*p[pi].sym_ptr_ptr)->name);
|
||||
|
||||
/* Add the size of "_PROCEDURE_LINKAGE_TABLE_" too. */
|
||||
size += sizeof (asymbol) + sizeof (pltname);
|
||||
@ -16755,34 +16754,31 @@ _bfd_mips_elf_get_synthetic_symtab (bfd *abfd,
|
||||
|
||||
if (i < count)
|
||||
{
|
||||
if ((*p[pi].sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size_t namelen;
|
||||
size_t len;
|
||||
size_t namelen;
|
||||
size_t len;
|
||||
|
||||
*s = **p[pi].sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
if ((s->flags & BSF_LOCAL) == 0)
|
||||
s->flags |= BSF_GLOBAL;
|
||||
s->flags |= BSF_SYNTHETIC;
|
||||
s->section = plt;
|
||||
s->value = plt_offset;
|
||||
s->name = names;
|
||||
s->udata.i = other;
|
||||
*s = **p[pi].sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since
|
||||
we are defining a symbol, ensure one of them is set. */
|
||||
if ((s->flags & BSF_LOCAL) == 0)
|
||||
s->flags |= BSF_GLOBAL;
|
||||
s->flags |= BSF_SYNTHETIC;
|
||||
s->section = plt;
|
||||
s->value = plt_offset;
|
||||
s->name = names;
|
||||
s->udata.i = other;
|
||||
|
||||
len = strlen ((*p[pi].sym_ptr_ptr)->name);
|
||||
namelen = len + suffixlen;
|
||||
if (names + namelen > nend)
|
||||
break;
|
||||
len = strlen ((*p[pi].sym_ptr_ptr)->name);
|
||||
namelen = len + suffixlen;
|
||||
if (names + namelen > nend)
|
||||
break;
|
||||
|
||||
memcpy (names, (*p[pi].sym_ptr_ptr)->name, len);
|
||||
names += len;
|
||||
memcpy (names, suffix, suffixlen);
|
||||
names += suffixlen;
|
||||
memcpy (names, (*p[pi].sym_ptr_ptr)->name, len);
|
||||
names += len;
|
||||
memcpy (names, suffix, suffixlen);
|
||||
names += suffixlen;
|
||||
|
||||
++s, ++n;
|
||||
}
|
||||
++s, ++n;
|
||||
pi = (pi + bed->s->int_rels_per_ext_rel) % counti;
|
||||
}
|
||||
}
|
||||
|
@ -3710,12 +3710,9 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd,
|
||||
for (i = 0; i < dynrelcount; i++)
|
||||
{
|
||||
p = dynrelbuf[i];
|
||||
if ((*p->sym_ptr_ptr)->name != NULL)
|
||||
{
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 8 + 8 * ABI_64_P (abfd);
|
||||
}
|
||||
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
|
||||
if (p->addend != 0)
|
||||
size += sizeof ("+0x") - 1 + 8 + 8 * ABI_64_P (abfd);
|
||||
}
|
||||
|
||||
s = *ret = (asymbol *) bfd_zmalloc (size);
|
||||
@ -3820,8 +3817,7 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd,
|
||||
/* Skip unknown relocation. PR 17512: file: bc9d6cf5. */
|
||||
if (got_vma == p->address
|
||||
&& p->howto != NULL
|
||||
&& valid_plt_reloc_p (p->howto->type)
|
||||
&& (*p->sym_ptr_ptr)->name != NULL)
|
||||
&& valid_plt_reloc_p (p->howto->type))
|
||||
{
|
||||
*s = **p->sym_ptr_ptr;
|
||||
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL
|
||||
|
Loading…
Reference in New Issue
Block a user