481
479
info->export_unused_gpl_sec = i;
482
480
else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
483
481
info->export_gpl_future_sec = i;
484
else if (strcmp(secname, "__markers_strings") == 0)
485
info->markers_strings_sec = i;
487
483
if (sechdrs[i].sh_type == SHT_SYMTAB) {
488
484
unsigned int sh_link_idx;
519
515
if (symtab_shndx_idx != ~0U) {
522
shndx2secindex(sechdrs[symtab_shndx_idx].sh_link))
517
if (symtab_idx != sechdrs[symtab_shndx_idx].sh_link)
523
518
fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n",
525
shndx2secindex(sechdrs[symtab_shndx_idx].sh_link),
519
filename, sechdrs[symtab_shndx_idx].sh_link,
527
521
/* Fix endianness */
528
522
for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop;
1315
1320
"variable with __init* or __refdata (see linux/init.h) "
1316
1321
"or name the variable:\n",
1317
1322
fromsym, to, prl_to, tosym, to_p);
1319
fprintf(stderr, "%s, ", *s++);
1320
fprintf(stderr, "\n");
1323
print_section_list(mismatch->symbol_white_list);
1340
1342
"variable with __exit* (see linux/init.h) or "
1341
1343
"name the variable:\n",
1342
1344
fromsym, to, prl_to, tosym, to_p);
1344
fprintf(stderr, "%s, ", *s++);
1345
fprintf(stderr, "\n");
1345
print_section_list(mismatch->symbol_white_list);
1646
static void get_markers(struct elf_info *info, struct module *mod)
1648
const Elf_Shdr *sh = &info->sechdrs[info->markers_strings_sec];
1649
const char *strings = (const char *) info->hdr + sh->sh_offset;
1650
const Elf_Sym *sym, *first_sym, *last_sym;
1653
if (!info->markers_strings_sec)
1657
* First count the strings. We look for all the symbols defined
1658
* in the __markers_strings section named __mstrtab_*. For
1659
* these local names, the compiler puts a random .NNN suffix on,
1660
* so the names don't correspond exactly.
1662
first_sym = last_sym = NULL;
1664
for (sym = info->symtab_start; sym < info->symtab_stop; sym++)
1665
if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
1666
sym->st_shndx == info->markers_strings_sec &&
1667
!strncmp(info->strtab + sym->st_name,
1668
"__mstrtab_", sizeof "__mstrtab_" - 1)) {
1669
if (first_sym == NULL)
1679
* Now collect each name and format into a line for the output.
1681
* marker_name vmlinux marker %s format %d
1682
* The format string after the second \t can use whitespace.
1684
mod->markers = NOFAIL(malloc(sizeof mod->markers[0] * n));
1688
for (sym = first_sym; sym <= last_sym; sym++)
1689
if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
1690
sym->st_shndx == info->markers_strings_sec &&
1691
!strncmp(info->strtab + sym->st_name,
1692
"__mstrtab_", sizeof "__mstrtab_" - 1)) {
1693
const char *name = strings + sym->st_value;
1694
const char *fmt = strchr(name, '\0') + 1;
1696
asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
1698
mod->markers[n++] = line;
1702
1646
static void read_symbols(char *modname)
1704
1648
const char *symname;
2110
2052
write_if_changed(&buf, fname);
2113
static void add_marker(struct module *mod, const char *name, const char *fmt)
2116
asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
2119
mod->markers = NOFAIL(realloc(mod->markers, ((mod->nmarkers + 1) *
2120
sizeof mod->markers[0])));
2121
mod->markers[mod->nmarkers++] = line;
2124
static void read_markers(const char *fname)
2126
unsigned long size, pos = 0;
2127
void *file = grab_file(fname, &size);
2130
if (!file) /* No old markers, silently ignore */
2133
while ((line = get_next_line(&pos, file, size))) {
2134
char *marker, *modname, *fmt;
2138
modname = strchr(marker, '\t');
2142
fmt = strchr(modname, '\t');
2146
if (*marker == '\0' || *modname == '\0')
2149
mod = find_module(modname);
2151
mod = new_module(modname);
2154
if (is_vmlinux(modname)) {
2160
add_marker(mod, marker, fmt);
2162
release_file(file, size);
2165
fatal("parse error in markers list file\n");
2168
static int compare_strings(const void *a, const void *b)
2170
return strcmp(*(const char **) a, *(const char **) b);
2173
static void write_markers(const char *fname)
2175
struct buffer buf = { };
2179
for (mod = modules; mod; mod = mod->next)
2180
if ((!external_module || !mod->skip) && mod->markers != NULL) {
2182
* Sort the strings so we can skip duplicates when
2183
* we write them out.
2185
qsort(mod->markers, mod->nmarkers,
2186
sizeof mod->markers[0], &compare_strings);
2187
for (i = 0; i < mod->nmarkers; ++i) {
2188
char *line = mod->markers[i];
2189
buf_write(&buf, line, strlen(line));
2190
while (i + 1 < mod->nmarkers &&
2191
!strcmp(mod->markers[i],
2192
mod->markers[i + 1]))
2193
free(mod->markers[i++]);
2194
free(mod->markers[i]);
2197
mod->markers = NULL;
2200
write_if_changed(&buf, fname);
2203
2055
struct ext_sym_list {
2204
2056
struct ext_sym_list *next;
2205
2057
const char *file;