MCPcopy Create free account
hub / github.com/F-Stack/f-stack / link_elf_lookup_set

Function link_elf_lookup_set

freebsd/kern/link_elf.c:1638–1689  ·  view source on GitHub ↗

* Look up a linker set on an ELF system. */

Source from the content-addressed store, hash-verified

1636 * Look up a linker set on an ELF system.
1637 */
1638static int
1639link_elf_lookup_set(linker_file_t lf, const char *name,
1640 void ***startp, void ***stopp, int *countp)
1641{
1642 c_linker_sym_t sym;
1643 linker_symval_t symval;
1644 char *setsym;
1645 void **start, **stop;
1646 int len, error = 0, count;
1647
1648 len = strlen(name) + sizeof("__start_set_"); /* sizeof includes \0 */
1649 setsym = malloc(len, M_LINKER, M_WAITOK);
1650
1651 /* get address of first entry */
1652 snprintf(setsym, len, "%s%s", "__start_set_", name);
1653 error = link_elf_lookup_symbol(lf, setsym, &sym);
1654 if (error != 0)
1655 goto out;
1656 link_elf_symbol_values(lf, sym, &symval);
1657 if (symval.value == 0) {
1658 error = ESRCH;
1659 goto out;
1660 }
1661 start = (void **)symval.value;
1662
1663 /* get address of last entry */
1664 snprintf(setsym, len, "%s%s", "__stop_set_", name);
1665 error = link_elf_lookup_symbol(lf, setsym, &sym);
1666 if (error != 0)
1667 goto out;
1668 link_elf_symbol_values(lf, sym, &symval);
1669 if (symval.value == 0) {
1670 error = ESRCH;
1671 goto out;
1672 }
1673 stop = (void **)symval.value;
1674
1675 /* and the number of entries */
1676 count = stop - start;
1677
1678 /* and copy out */
1679 if (startp != NULL)
1680 *startp = start;
1681 if (stopp != NULL)
1682 *stopp = stop;
1683 if (countp != NULL)
1684 *countp = count;
1685
1686out:
1687 free(setsym, M_LINKER);
1688 return (error);
1689}
1690
1691static int
1692link_elf_each_function_name(linker_file_t file,

Callers 2

parse_dpcpuFunction · 0.70
parse_vnetFunction · 0.70

Calls 5

mallocFunction · 0.85
snprintfFunction · 0.85
link_elf_lookup_symbolFunction · 0.70
link_elf_symbol_valuesFunction · 0.70
freeFunction · 0.70

Tested by

no test coverage detected