aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/mod/modpost.c164
-rw-r--r--scripts/mod/modpost.h3
2 files changed, 0 insertions, 167 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index fb0f9b711af3..c16c0a0e2464 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -460,8 +460,6 @@ static int parse_elf(struct elf_info *info, const char *filename)
460 info->export_unused_gpl_sec = i; 460 info->export_unused_gpl_sec = i;
461 else if (strcmp(secname, "__ksymtab_gpl_future") == 0) 461 else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
462 info->export_gpl_future_sec = i; 462 info->export_gpl_future_sec = i;
463 else if (strcmp(secname, "__markers_strings") == 0)
464 info->markers_strings_sec = i;
465 463
466 if (sechdrs[i].sh_type != SHT_SYMTAB) 464 if (sechdrs[i].sh_type != SHT_SYMTAB)
467 continue; 465 continue;
@@ -1518,62 +1516,6 @@ static void check_sec_ref(struct module *mod, const char *modname,
1518 } 1516 }
1519} 1517}
1520 1518
1521static void get_markers(struct elf_info *info, struct module *mod)
1522{
1523 const Elf_Shdr *sh = &info->sechdrs[info->markers_strings_sec];
1524 const char *strings = (const char *) info->hdr + sh->sh_offset;
1525 const Elf_Sym *sym, *first_sym, *last_sym;
1526 size_t n;
1527
1528 if (!info->markers_strings_sec)
1529 return;
1530
1531 /*
1532 * First count the strings. We look for all the symbols defined
1533 * in the __markers_strings section named __mstrtab_*. For
1534 * these local names, the compiler puts a random .NNN suffix on,
1535 * so the names don't correspond exactly.
1536 */
1537 first_sym = last_sym = NULL;
1538 n = 0;
1539 for (sym = info->symtab_start; sym < info->symtab_stop; sym++)
1540 if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
1541 sym->st_shndx == info->markers_strings_sec &&
1542 !strncmp(info->strtab + sym->st_name,
1543 "__mstrtab_", sizeof "__mstrtab_" - 1)) {
1544 if (first_sym == NULL)
1545 first_sym = sym;
1546 last_sym = sym;
1547 ++n;
1548 }
1549
1550 if (n == 0)
1551 return;
1552
1553 /*
1554 * Now collect each name and format into a line for the output.
1555 * Lines look like:
1556 * marker_name vmlinux marker %s format %d
1557 * The format string after the second \t can use whitespace.
1558 */
1559 mod->markers = NOFAIL(malloc(sizeof mod->markers[0] * n));
1560 mod->nmarkers = n;
1561
1562 n = 0;
1563 for (sym = first_sym; sym <= last_sym; sym++)
1564 if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
1565 sym->st_shndx == info->markers_strings_sec &&
1566 !strncmp(info->strtab + sym->st_name,
1567 "__mstrtab_", sizeof "__mstrtab_" - 1)) {
1568 const char *name = strings + sym->st_value;
1569 const char *fmt = strchr(name, '\0') + 1;
1570 char *line = NULL;
1571 asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
1572 NOFAIL(line);
1573 mod->markers[n++] = line;
1574 }
1575}
1576
1577static void read_symbols(char *modname) 1519static void read_symbols(char *modname)
1578{ 1520{
1579 const char *symname; 1521 const char *symname;
@@ -1629,8 +1571,6 @@ static void read_symbols(char *modname)
1629 get_src_version(modname, mod->srcversion, 1571 get_src_version(modname, mod->srcversion,
1630 sizeof(mod->srcversion)-1); 1572 sizeof(mod->srcversion)-1);
1631 1573
1632 get_markers(&info, mod);
1633
1634 parse_elf_finish(&info); 1574 parse_elf_finish(&info);
1635 1575
1636 /* Our trick to get versioning for module struct etc. - it's 1576 /* Our trick to get versioning for module struct etc. - it's
@@ -1985,96 +1925,6 @@ static void write_dump(const char *fname)
1985 write_if_changed(&buf, fname); 1925 write_if_changed(&buf, fname);
1986} 1926}
1987 1927
1988static void add_marker(struct module *mod, const char *name, const char *fmt)
1989{
1990 char *line = NULL;
1991 asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
1992 NOFAIL(line);
1993
1994 mod->markers = NOFAIL(realloc(mod->markers, ((mod->nmarkers + 1) *
1995 sizeof mod->markers[0])));
1996 mod->markers[mod->nmarkers++] = line;
1997}
1998
1999static void read_markers(const char *fname)
2000{
2001 unsigned long size, pos = 0;
2002 void *file = grab_file(fname, &size);
2003 char *line;
2004
2005 if (!file) /* No old markers, silently ignore */
2006 return;
2007
2008 while ((line = get_next_line(&pos, file, size))) {
2009 char *marker, *modname, *fmt;
2010 struct module *mod;
2011
2012 marker = line;
2013 modname = strchr(marker, '\t');
2014 if (!modname)
2015 goto fail;
2016 *modname++ = '\0';
2017 fmt = strchr(modname, '\t');
2018 if (!fmt)
2019 goto fail;
2020 *fmt++ = '\0';
2021 if (*marker == '\0' || *modname == '\0')
2022 goto fail;
2023
2024 mod = find_module(modname);
2025 if (!mod) {
2026 mod = new_module(modname);
2027 mod->skip = 1;
2028 }
2029 if (is_vmlinux(modname)) {
2030 have_vmlinux = 1;
2031 mod->skip = 0;
2032 }
2033
2034 if (!mod->skip)
2035 add_marker(mod, marker, fmt);
2036 }
2037 release_file(file, size);
2038 return;
2039fail:
2040 fatal("parse error in markers list file\n");
2041}
2042
2043static int compare_strings(const void *a, const void *b)
2044{
2045 return strcmp(*(const char **) a, *(const char **) b);
2046}
2047
2048static void write_markers(const char *fname)
2049{
2050 struct buffer buf = { };
2051 struct module *mod;
2052 size_t i;
2053
2054 for (mod = modules; mod; mod = mod->next)
2055 if ((!external_module || !mod->skip) && mod->markers != NULL) {
2056 /*
2057 * Sort the strings so we can skip duplicates when
2058 * we write them out.
2059 */
2060 qsort(mod->markers, mod->nmarkers,
2061 sizeof mod->markers[0], &compare_strings);
2062 for (i = 0; i < mod->nmarkers; ++i) {
2063 char *line = mod->markers[i];
2064 buf_write(&buf, line, strlen(line));
2065 while (i + 1 < mod->nmarkers &&
2066 !strcmp(mod->markers[i],
2067 mod->markers[i + 1]))
2068 free(mod->markers[i++]);
2069 free(mod->markers[i]);
2070 }
2071 free(mod->markers);
2072 mod->markers = NULL;
2073 }
2074
2075 write_if_changed(&buf, fname);
2076}
2077
2078struct ext_sym_list { 1928struct ext_sym_list {
2079 struct ext_sym_list *next; 1929 struct ext_sym_list *next;
2080 const char *file; 1930 const char *file;
@@ -2086,8 +1936,6 @@ int main(int argc, char **argv)
2086 struct buffer buf = { }; 1936 struct buffer buf = { };
2087 char *kernel_read = NULL, *module_read = NULL; 1937 char *kernel_read = NULL, *module_read = NULL;
2088 char *dump_write = NULL; 1938 char *dump_write = NULL;
2089 char *markers_read = NULL;
2090 char *markers_write = NULL;
2091 int opt; 1939 int opt;
2092 int err; 1940 int err;
2093 struct ext_sym_list *extsym_iter; 1941 struct ext_sym_list *extsym_iter;
@@ -2131,12 +1979,6 @@ int main(int argc, char **argv)
2131 case 'w': 1979 case 'w':
2132 warn_unresolved = 1; 1980 warn_unresolved = 1;
2133 break; 1981 break;
2134 case 'M':
2135 markers_write = optarg;
2136 break;
2137 case 'K':
2138 markers_read = optarg;
2139 break;
2140 default: 1982 default:
2141 exit(1); 1983 exit(1);
2142 } 1984 }
@@ -2191,11 +2033,5 @@ int main(int argc, char **argv)
2191 "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", 2033 "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
2192 sec_mismatch_count); 2034 sec_mismatch_count);
2193 2035
2194 if (markers_read)
2195 read_markers(markers_read);
2196
2197 if (markers_write)
2198 write_markers(markers_write);
2199
2200 return err; 2036 return err;
2201} 2037}
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 09f58e33d227..be987a44f250 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -112,8 +112,6 @@ struct module {
112 int has_init; 112 int has_init;
113 int has_cleanup; 113 int has_cleanup;
114 struct buffer dev_table_buf; 114 struct buffer dev_table_buf;
115 char **markers;
116 size_t nmarkers;
117 char srcversion[25]; 115 char srcversion[25];
118}; 116};
119 117
@@ -128,7 +126,6 @@ struct elf_info {
128 Elf_Section export_gpl_sec; 126 Elf_Section export_gpl_sec;
129 Elf_Section export_unused_gpl_sec; 127 Elf_Section export_unused_gpl_sec;
130 Elf_Section export_gpl_future_sec; 128 Elf_Section export_gpl_future_sec;
131 Elf_Section markers_strings_sec;
132 const char *strtab; 129 const char *strtab;
133 char *modinfo; 130 char *modinfo;
134 unsigned int modinfo_len; 131 unsigned int modinfo_len;