aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog4
-rw-r--r--bfd/elf-strtab.c4
-rw-r--r--ld/ChangeLog4
-rw-r--r--ld/ldelfgen.c15
-rw-r--r--libctf/ChangeLog8
-rw-r--r--libctf/ctf-create.c16
-rw-r--r--libctf/ctf-link.c3
7 files changed, 42 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c4c4fa2..c56cfc4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2021-03-02 Nick Alcock <nick.alcock@oracle.com>
+
+ * elf-strtab.c (_bfd_elf_strtab_str): Skip strings with zero refcount.
+
2021-03-02 Alan Modra <amodra@gmail.com>
PR 27451
diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 3e5e162..a3cb4ef 100644
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -299,9 +299,11 @@ _bfd_elf_strtab_str (struct elf_strtab_hash *tab, size_t idx,
bfd_size_type *offset)
{
if (idx == 0)
- return 0;
+ return NULL;
BFD_ASSERT (idx < tab->size);
BFD_ASSERT (tab->sec_size);
+ if (tab->array[idx]->refcount == 0)
+ return NULL;
if (offset)
*offset = tab->array[idx]->u.index;
return tab->array[idx]->root.string;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index d12e537..9116ee0 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@
+2021-03-02 Nick Alcock <nick.alcock@oracle.com>
+
+ * ldelfgen.c (ldelf_ctf_strtab_iter_cb): Skip zero-refcount strings.
+
2021-03-02 Alan Modra <amodra@gmail.com>
* testsuite/ld-powerpc/startstop.d,
diff --git a/ld/ldelfgen.c b/ld/ldelfgen.c
index df3dae0..c49b854 100644
--- a/ld/ldelfgen.c
+++ b/ld/ldelfgen.c
@@ -375,13 +375,20 @@ ldelf_ctf_strtab_iter_cb (uint32_t *offset, void *arg_)
if (arg->next_i == 0)
arg->next_i = 1;
- if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
+ /* Hunt through strings until we fall off the end or find one with
+ a nonzero refcount. */
+ do
{
- arg->next_i = 0;
- return NULL;
+ if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
+ {
+ arg->next_i = 0;
+ return NULL;
+ }
+
+ ret = _bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
}
+ while (ret == NULL);
- ret = _bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
*offset = off;
/* If we've overflowed, we cannot share any further strings: the CTF
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 8fa98c6..f095c3e 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,13 @@
2021-03-02 Nick Alcock <nick.alcock@oracle.com>
+ * ctf-create.c (symtypetab_density): Report the symbol name as
+ well as index in the name != object error; note the likely
+ consequences.
+ * ctf-link.c (ctf_link_shuffle_syms): Report the symbol index
+ as well as name.
+
+2021-03-02 Nick Alcock <nick.alcock@oracle.com>
+
* ctf-link.c (ctf_link_shuffle_syms): Free ctf_dynsyms properly.
2021-03-02 Nick Alcock <nick.alcock@oracle.com>
diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index d417922..3f2c5da 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -318,18 +318,22 @@ symtypetab_density (ctf_dict_t *fp, ctf_dict_t *symfp, ctf_dynhash_t *symhash,
if ((flags & CTF_SYMTYPETAB_EMIT_FUNCTION)
&& sym->st_type != STT_FUNC)
{
- ctf_err_warn (fp, 1, 0, _("Symbol %x added to CTF as a function "
- "but is of type %x\n"),
- sym->st_symidx, sym->st_type);
+ ctf_err_warn (fp, 1, 0, _("symbol %s (%x) added to CTF as a "
+ "function but is of type %x. "
+ "The symbol type lookup tables "
+ "are probably corrupted"),
+ sym->st_name, sym->st_symidx, sym->st_type);
ctf_dynhash_remove (symhash, name);
continue;
}
else if (!(flags & CTF_SYMTYPETAB_EMIT_FUNCTION)
&& sym->st_type != STT_OBJECT)
{
- ctf_err_warn (fp, 1, 0, _("Symbol %x added to CTF as a data "
- "object but is of type %x\n"),
- sym->st_symidx, sym->st_type);
+ ctf_err_warn (fp, 1, 0, _("symbol %s (%x) added to CTF as a "
+ "data object but is of type %x. "
+ "The symbol type lookup tables "
+ "are probably corrupted"),
+ sym->st_name, sym->st_symidx, sym->st_type);
ctf_dynhash_remove (symhash, name);
continue;
}
diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index 882d429..5471fcc 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -1552,7 +1552,8 @@ ctf_link_shuffle_syms (ctf_dict_t *fp)
for skippability here. */
if (!ctf_symtab_skippable (&did->cid_sym))
{
- ctf_dprintf ("symbol name from linker: %s\n", did->cid_sym.st_name);
+ ctf_dprintf ("symbol from linker: %s (%x)\n", did->cid_sym.st_name,
+ did->cid_sym.st_symidx);
if ((new_sym = malloc (sizeof (ctf_link_sym_t))) == NULL)
goto local_oom;