~ubuntu-branches/ubuntu/precise/linux-linaro-u8500/precise

« back to all changes in this revision

Viewing changes to scripts/mod/modpost.c

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

Show diffs side-by-side

added added

removed removed

Lines of Context:
481
481
                        info->export_unused_gpl_sec = i;
482
482
                else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
483
483
                        info->export_gpl_future_sec = i;
 
484
                else if (strcmp(secname, "__markers_strings") == 0)
 
485
                        info->markers_strings_sec = i;
484
486
 
485
487
                if (sechdrs[i].sh_type == SHT_SYMTAB) {
486
488
                        unsigned int sh_link_idx;
798
800
        ".note*",
799
801
        ".got*",
800
802
        ".toc*",
 
803
        "__discard",
801
804
        NULL
802
805
};
803
806
 
1640
1643
        }
1641
1644
}
1642
1645
 
 
1646
static void get_markers(struct elf_info *info, struct module *mod)
 
1647
{
 
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;
 
1651
        size_t n;
 
1652
 
 
1653
        if (!info->markers_strings_sec)
 
1654
                return;
 
1655
 
 
1656
        /*
 
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.
 
1661
         */
 
1662
        first_sym = last_sym = NULL;
 
1663
        n = 0;
 
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)
 
1670
                                first_sym = sym;
 
1671
                        last_sym = sym;
 
1672
                        ++n;
 
1673
                }
 
1674
 
 
1675
        if (n == 0)
 
1676
                return;
 
1677
 
 
1678
        /*
 
1679
         * Now collect each name and format into a line for the output.
 
1680
         * Lines look like:
 
1681
         *      marker_name     vmlinux marker %s format %d
 
1682
         * The format string after the second \t can use whitespace.
 
1683
         */
 
1684
        mod->markers = NOFAIL(malloc(sizeof mod->markers[0] * n));
 
1685
        mod->nmarkers = n;
 
1686
 
 
1687
        n = 0;
 
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;
 
1695
                        char *line = NULL;
 
1696
                        asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
 
1697
                        NOFAIL(line);
 
1698
                        mod->markers[n++] = line;
 
1699
                }
 
1700
}
 
1701
 
1643
1702
static void read_symbols(char *modname)
1644
1703
{
1645
1704
        const char *symname;
1695
1754
                get_src_version(modname, mod->srcversion,
1696
1755
                                sizeof(mod->srcversion)-1);
1697
1756
 
 
1757
        get_markers(&info, mod);
 
1758
 
1698
1759
        parse_elf_finish(&info);
1699
1760
 
1700
1761
        /* Our trick to get versioning for module struct etc. - it's
2049
2110
        write_if_changed(&buf, fname);
2050
2111
}
2051
2112
 
 
2113
static void add_marker(struct module *mod, const char *name, const char *fmt)
 
2114
{
 
2115
        char *line = NULL;
 
2116
        asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
 
2117
        NOFAIL(line);
 
2118
 
 
2119
        mod->markers = NOFAIL(realloc(mod->markers, ((mod->nmarkers + 1) *
 
2120
                                                     sizeof mod->markers[0])));
 
2121
        mod->markers[mod->nmarkers++] = line;
 
2122
}
 
2123
 
 
2124
static void read_markers(const char *fname)
 
2125
{
 
2126
        unsigned long size, pos = 0;
 
2127
        void *file = grab_file(fname, &size);
 
2128
        char *line;
 
2129
 
 
2130
        if (!file)              /* No old markers, silently ignore */
 
2131
                return;
 
2132
 
 
2133
        while ((line = get_next_line(&pos, file, size))) {
 
2134
                char *marker, *modname, *fmt;
 
2135
                struct module *mod;
 
2136
 
 
2137
                marker = line;
 
2138
                modname = strchr(marker, '\t');
 
2139
                if (!modname)
 
2140
                        goto fail;
 
2141
                *modname++ = '\0';
 
2142
                fmt = strchr(modname, '\t');
 
2143
                if (!fmt)
 
2144
                        goto fail;
 
2145
                *fmt++ = '\0';
 
2146
                if (*marker == '\0' || *modname == '\0')
 
2147
                        goto fail;
 
2148
 
 
2149
                mod = find_module(modname);
 
2150
                if (!mod) {
 
2151
                        mod = new_module(modname);
 
2152
                        mod->skip = 1;
 
2153
                }
 
2154
                if (is_vmlinux(modname)) {
 
2155
                        have_vmlinux = 1;
 
2156
                        mod->skip = 0;
 
2157
                }
 
2158
 
 
2159
                if (!mod->skip)
 
2160
                        add_marker(mod, marker, fmt);
 
2161
        }
 
2162
        release_file(file, size);
 
2163
        return;
 
2164
fail:
 
2165
        fatal("parse error in markers list file\n");
 
2166
}
 
2167
 
 
2168
static int compare_strings(const void *a, const void *b)
 
2169
{
 
2170
        return strcmp(*(const char **) a, *(const char **) b);
 
2171
}
 
2172
 
 
2173
static void write_markers(const char *fname)
 
2174
{
 
2175
        struct buffer buf = { };
 
2176
        struct module *mod;
 
2177
        size_t i;
 
2178
 
 
2179
        for (mod = modules; mod; mod = mod->next)
 
2180
                if ((!external_module || !mod->skip) && mod->markers != NULL) {
 
2181
                        /*
 
2182
                         * Sort the strings so we can skip duplicates when
 
2183
                         * we write them out.
 
2184
                         */
 
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]);
 
2195
                        }
 
2196
                        free(mod->markers);
 
2197
                        mod->markers = NULL;
 
2198
                }
 
2199
 
 
2200
        write_if_changed(&buf, fname);
 
2201
}
 
2202
 
2052
2203
struct ext_sym_list {
2053
2204
        struct ext_sym_list *next;
2054
2205
        const char *file;
2060
2211
        struct buffer buf = { };
2061
2212
        char *kernel_read = NULL, *module_read = NULL;
2062
2213
        char *dump_write = NULL;
 
2214
        char *markers_read = NULL;
 
2215
        char *markers_write = NULL;
2063
2216
        int opt;
2064
2217
        int err;
2065
2218
        struct ext_sym_list *extsym_iter;
2103
2256
                case 'w':
2104
2257
                        warn_unresolved = 1;
2105
2258
                        break;
 
2259
                        case 'M':
 
2260
                                markers_write = optarg;
 
2261
                                break;
 
2262
                        case 'K':
 
2263
                                markers_read = optarg;
 
2264
                                break;
2106
2265
                default:
2107
2266
                        exit(1);
2108
2267
                }
2157
2316
                     "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
2158
2317
                     sec_mismatch_count);
2159
2318
 
 
2319
        if (markers_read)
 
2320
                read_markers(markers_read);
 
2321
 
 
2322
        if (markers_write)
 
2323
                write_markers(markers_write);
 
2324
 
2160
2325
        return err;
2161
2326
}