aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mod')
-rw-r--r--scripts/mod/file2alias.c25
-rw-r--r--scripts/mod/modpost.c36
2 files changed, 60 insertions, 1 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e26e2fb462d4..f936d1fa969d 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -735,6 +735,27 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
735 return 1; 735 return 1;
736} 736}
737 737
738/*
739 * Looks like: vmbus:guid
740 * Each byte of the guid will be represented by two hex characters
741 * in the name.
742 */
743
744static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id,
745 char *alias)
746{
747 int i;
748 char guid_name[((sizeof(id->guid) + 1)) * 2];
749
750 for (i = 0; i < (sizeof(id->guid) * 2); i += 2)
751 sprintf(&guid_name[i], "%02x", id->guid[i/2]);
752
753 strcpy(alias, "vmbus:");
754 strcat(alias, guid_name);
755
756 return 1;
757}
758
738/* Looks like: i2c:S */ 759/* Looks like: i2c:S */
739static int do_i2c_entry(const char *filename, struct i2c_device_id *id, 760static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
740 char *alias) 761 char *alias)
@@ -994,6 +1015,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
994 do_table(symval, sym->st_size, 1015 do_table(symval, sym->st_size,
995 sizeof(struct virtio_device_id), "virtio", 1016 sizeof(struct virtio_device_id), "virtio",
996 do_virtio_entry, mod); 1017 do_virtio_entry, mod);
1018 else if (sym_is(symname, "__mod_vmbus_device_table"))
1019 do_table(symval, sym->st_size,
1020 sizeof(struct hv_vmbus_device_id), "vmbus",
1021 do_vmbus_entry, mod);
997 else if (sym_is(symname, "__mod_i2c_device_table")) 1022 else if (sym_is(symname, "__mod_i2c_device_table"))
998 do_table(symval, sym->st_size, 1023 do_table(symval, sym->st_size,
999 sizeof(struct i2c_device_id), "i2c", 1024 sizeof(struct i2c_device_id), "i2c",
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 413c53693e62..2bd594e6d1b4 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -254,6 +254,28 @@ static enum export export_no(const char *s)
254 return export_unknown; 254 return export_unknown;
255} 255}
256 256
257static const char *sec_name(struct elf_info *elf, int secindex);
258
259#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
260
261static enum export export_from_secname(struct elf_info *elf, unsigned int sec)
262{
263 const char *secname = sec_name(elf, sec);
264
265 if (strstarts(secname, "___ksymtab+"))
266 return export_plain;
267 else if (strstarts(secname, "___ksymtab_unused+"))
268 return export_unused;
269 else if (strstarts(secname, "___ksymtab_gpl+"))
270 return export_gpl;
271 else if (strstarts(secname, "___ksymtab_unused_gpl+"))
272 return export_unused_gpl;
273 else if (strstarts(secname, "___ksymtab_gpl_future+"))
274 return export_gpl_future;
275 else
276 return export_unknown;
277}
278
257static enum export export_from_sec(struct elf_info *elf, unsigned int sec) 279static enum export export_from_sec(struct elf_info *elf, unsigned int sec)
258{ 280{
259 if (sec == elf->export_sec) 281 if (sec == elf->export_sec)
@@ -563,7 +585,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
563 Elf_Sym *sym, const char *symname) 585 Elf_Sym *sym, const char *symname)
564{ 586{
565 unsigned int crc; 587 unsigned int crc;
566 enum export export = export_from_sec(info, get_secindex(info, sym)); 588 enum export export;
589
590 if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0)
591 export = export_from_secname(info, get_secindex(info, sym));
592 else
593 export = export_from_sec(info, get_secindex(info, sym));
567 594
568 switch (sym->st_shndx) { 595 switch (sym->st_shndx) {
569 case SHN_COMMON: 596 case SHN_COMMON:
@@ -1822,6 +1849,12 @@ static void add_header(struct buffer *b, struct module *mod)
1822 buf_printf(b, "};\n"); 1849 buf_printf(b, "};\n");
1823} 1850}
1824 1851
1852static void add_intree_flag(struct buffer *b, int is_intree)
1853{
1854 if (is_intree)
1855 buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
1856}
1857
1825static void add_staging_flag(struct buffer *b, const char *name) 1858static void add_staging_flag(struct buffer *b, const char *name)
1826{ 1859{
1827 static const char *staging_dir = "drivers/staging"; 1860 static const char *staging_dir = "drivers/staging";
@@ -2142,6 +2175,7 @@ int main(int argc, char **argv)
2142 buf.pos = 0; 2175 buf.pos = 0;
2143 2176
2144 add_header(&buf, mod); 2177 add_header(&buf, mod);
2178 add_intree_flag(&buf, !external_module);
2145 add_staging_flag(&buf, mod->name); 2179 add_staging_flag(&buf, mod->name);
2146 err |= add_versions(&buf, mod); 2180 err |= add_versions(&buf, mod);
2147 add_depends(&buf, mod, modules); 2181 add_depends(&buf, mod, modules);