- uint32_t info, vlen;
- Elf64_Sym sym, *gsp;
- const char *name;
-
- /* The CTF data object and function type sections are ordered to match
- the relative order of the respective symbol types in the symtab.
- If no type information is available for a symbol table entry, a
- pad is inserted in the CTF section. As a further optimization,
- anonymous or undefined symbols are omitted from the CTF data. */
-
- for (; xp < xend; xp++, symp += sp->cts_entsize)
+ /* If the CTF_F_NEWFUNCINFO flag is not set, pretend the func info section
+ is empty: this compiler is too old to emit a function info section we
+ understand. */
+
+ if (!(hp->cth_flags & CTF_F_NEWFUNCINFO))
+ skip_func_info = 1;
+
+ if (hp->cth_objtidxoff < hp->cth_funcidxoff)
+ fp->ctf_objtidx_names = (uint32_t *) (fp->ctf_buf + hp->cth_objtidxoff);
+ if (hp->cth_funcidxoff < hp->cth_varoff && !skip_func_info)
+ fp->ctf_funcidx_names = (uint32_t *) (fp->ctf_buf + hp->cth_funcidxoff);
+
+ /* Don't bother doing the rest if everything is indexed, or if we don't have a
+ symbol table: we will never use it. */
+ if ((fp->ctf_objtidx_names && fp->ctf_funcidx_names) || !sp || !sp->cts_data)
+ return 0;
+
+ /* The CTF data object and function type sections are ordered to match the
+ relative order of the respective symbol types in the symtab, unless there
+ is an index section, in which case the order is arbitrary and the index
+ gives the mapping. If no type information is available for a symbol table
+ entry, a pad is inserted in the CTF section. As a further optimization,
+ anonymous or undefined symbols are omitted from the CTF data. If an
+ index is available for function symbols but not object symbols, or vice
+ versa, we populate the xslate table for the unindexed symbols only. */
+
+ for (i = 0, symp = sp->cts_data; xp < xend; xp++, symp += sp->cts_entsize,
+ i++)