aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modutils-24.c117
1 files changed, 57 insertions, 60 deletions
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index a16cb1bbe..9f91c9979 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -511,8 +511,7 @@ int delete_module(const char *module, unsigned int flags);
511struct obj_string_patch; 511struct obj_string_patch;
512struct obj_symbol_patch; 512struct obj_symbol_patch;
513 513
514struct obj_section 514struct obj_section {
515{
516 ElfW(Shdr) header; 515 ElfW(Shdr) header;
517 const char *name; 516 const char *name;
518 char *contents; 517 char *contents;
@@ -520,8 +519,7 @@ struct obj_section
520 int idx; 519 int idx;
521}; 520};
522 521
523struct obj_symbol 522struct obj_symbol {
524{
525 struct obj_symbol *next; /* hash table link */ 523 struct obj_symbol *next; /* hash table link */
526 const char *name; 524 const char *name;
527 unsigned long value; 525 unsigned long value;
@@ -546,8 +544,8 @@ struct obj_file {
546 struct obj_section **load_order_search_start; 544 struct obj_section **load_order_search_start;
547 struct obj_string_patch *string_patches; 545 struct obj_string_patch *string_patches;
548 struct obj_symbol_patch *symbol_patches; 546 struct obj_symbol_patch *symbol_patches;
549 int (*symbol_cmp)(const char *, const char *); 547 int (*symbol_cmp)(const char *, const char *); /* cant be FAST_FUNC */
550 unsigned long (*symbol_hash)(const char *); 548 unsigned long (*symbol_hash)(const char *) FAST_FUNC;
551 unsigned long local_symtab_size; 549 unsigned long local_symtab_size;
552 struct obj_symbol **local_symtab; 550 struct obj_symbol **local_symtab;
553 struct obj_symbol *symtab[HASH_BUCKETS]; 551 struct obj_symbol *symtab[HASH_BUCKETS];
@@ -577,45 +575,45 @@ struct obj_symbol_patch {
577 575
578/* Generic object manipulation routines. */ 576/* Generic object manipulation routines. */
579 577
580static unsigned long obj_elf_hash(const char *); 578static unsigned long FAST_FUNC obj_elf_hash(const char *);
581 579
582static unsigned long obj_elf_hash_n(const char *, unsigned long len); 580static unsigned long obj_elf_hash_n(const char *, unsigned long len);
583 581
584static struct obj_symbol *obj_find_symbol(struct obj_file *f, 582static struct obj_symbol *obj_find_symbol(struct obj_file *f,
585 const char *name); 583 const char *name);
586 584
587static ElfW(Addr) obj_symbol_final_value(struct obj_file *f, 585static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
588 struct obj_symbol *sym); 586 struct obj_symbol *sym);
589 587
590#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING 588#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
591static void obj_set_symbol_compare(struct obj_file *f, 589static void obj_set_symbol_compare(struct obj_file *f,
592 int (*cmp)(const char *, const char *), 590 int (*cmp)(const char *, const char *),
593 unsigned long (*hash)(const char *)); 591 unsigned long (*hash)(const char *) FAST_FUNC);
594#endif 592#endif
595 593
596static struct obj_section *obj_find_section(struct obj_file *f, 594static struct obj_section *obj_find_section(struct obj_file *f,
597 const char *name); 595 const char *name);
598 596
599static void obj_insert_section_load_order(struct obj_file *f, 597static void obj_insert_section_load_order(struct obj_file *f,
600 struct obj_section *sec); 598 struct obj_section *sec);
601 599
602static struct obj_section *obj_create_alloced_section(struct obj_file *f, 600static struct obj_section *obj_create_alloced_section(struct obj_file *f,
603 const char *name, 601 const char *name,
604 unsigned long align, 602 unsigned long align,
605 unsigned long size); 603 unsigned long size);
606 604
607static struct obj_section *obj_create_alloced_section_first(struct obj_file *f, 605static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
608 const char *name, 606 const char *name,
609 unsigned long align, 607 unsigned long align,
610 unsigned long size); 608 unsigned long size);
611 609
612static void *obj_extend_section(struct obj_section *sec, unsigned long more); 610static void *obj_extend_section(struct obj_section *sec, unsigned long more);
613 611
614static void obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset, 612static void obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
615 const char *string); 613 const char *string);
616 614
617static void obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset, 615static void obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
618 struct obj_symbol *sym); 616 struct obj_symbol *sym);
619 617
620static void obj_check_undefineds(struct obj_file *f); 618static void obj_check_undefineds(struct obj_file *f);
621 619
@@ -642,10 +640,10 @@ static struct obj_section *arch_new_section(void);
642static struct obj_symbol *arch_new_symbol(void); 640static struct obj_symbol *arch_new_symbol(void);
643 641
644static enum obj_reloc arch_apply_relocation(struct obj_file *f, 642static enum obj_reloc arch_apply_relocation(struct obj_file *f,
645 struct obj_section *targsec, 643 struct obj_section *targsec,
646 /*struct obj_section *symsec,*/ 644 /*struct obj_section *symsec,*/
647 struct obj_symbol *sym, 645 struct obj_symbol *sym,
648 ElfW(RelM) *rel, ElfW(Addr) value); 646 ElfW(RelM) *rel, ElfW(Addr) value);
649 647
650static void arch_create_got(struct obj_file *f); 648static void arch_create_got(struct obj_file *f);
651#if ENABLE_FEATURE_CHECK_TAINTED_MODULE 649#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
@@ -679,8 +677,7 @@ enum { STRVERSIONLEN = 64 };
679 677
680#if defined(USE_LIST) 678#if defined(USE_LIST)
681 679
682struct arch_list_entry 680struct arch_list_entry {
683{
684 struct arch_list_entry *next; 681 struct arch_list_entry *next;
685 LIST_ARCHTYPE addend; 682 LIST_ARCHTYPE addend;
686 int offset; 683 int offset;
@@ -691,8 +688,7 @@ struct arch_list_entry
691 688
692#if defined(USE_SINGLE) 689#if defined(USE_SINGLE)
693 690
694struct arch_single_entry 691struct arch_single_entry {
695{
696 int offset; 692 int offset;
697 int inited : 1; 693 int inited : 1;
698 int allocated : 1; 694 int allocated : 1;
@@ -701,8 +697,7 @@ struct arch_single_entry
701#endif 697#endif
702 698
703#if defined(__mips__) 699#if defined(__mips__)
704struct mips_hi16 700struct mips_hi16 {
705{
706 struct mips_hi16 *next; 701 struct mips_hi16 *next;
707 ElfW(Addr) *addr; 702 ElfW(Addr) *addr;
708 ElfW(Addr) value; 703 ElfW(Addr) value;
@@ -776,10 +771,10 @@ static struct obj_symbol *arch_new_symbol(void)
776 771
777static enum obj_reloc 772static enum obj_reloc
778arch_apply_relocation(struct obj_file *f, 773arch_apply_relocation(struct obj_file *f,
779 struct obj_section *targsec, 774 struct obj_section *targsec,
780 /*struct obj_section *symsec,*/ 775 /*struct obj_section *symsec,*/
781 struct obj_symbol *sym, 776 struct obj_symbol *sym,
782 ElfW(RelM) *rel, ElfW(Addr) v) 777 ElfW(RelM) *rel, ElfW(Addr) v)
783{ 778{
784#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) \ 779#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) \
785 || defined(__sh__) || defined(__s390__) || defined(__x86_64__) \ 780 || defined(__sh__) || defined(__s390__) || defined(__x86_64__) \
@@ -1707,7 +1702,7 @@ static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
1707#if defined(USE_SINGLE) 1702#if defined(USE_SINGLE)
1708 1703
1709static int arch_single_init(/*ElfW(RelM) *rel,*/ struct arch_single_entry *single, 1704static int arch_single_init(/*ElfW(RelM) *rel,*/ struct arch_single_entry *single,
1710 int offset, int size) 1705 int offset, int size)
1711{ 1706{
1712 if (single->allocated == 0) { 1707 if (single->allocated == 0) {
1713 single->allocated = 1; 1708 single->allocated = 1;
@@ -1723,7 +1718,7 @@ static int arch_single_init(/*ElfW(RelM) *rel,*/ struct arch_single_entry *singl
1723#if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES) 1718#if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
1724 1719
1725static struct obj_section *arch_xsect_init(struct obj_file *f, const char *name, 1720static struct obj_section *arch_xsect_init(struct obj_file *f, const char *name,
1726 int offset, int size) 1721 int offset, int size)
1727{ 1722{
1728 struct obj_section *myrelsec = obj_find_section(f, name); 1723 struct obj_section *myrelsec = obj_find_section(f, name);
1729 1724
@@ -1916,7 +1911,7 @@ static unsigned long obj_elf_hash_n(const char *name, unsigned long n)
1916 return h; 1911 return h;
1917} 1912}
1918 1913
1919static unsigned long obj_elf_hash(const char *name) 1914static unsigned long FAST_FUNC obj_elf_hash(const char *name)
1920{ 1915{
1921 return obj_elf_hash_n(name, strlen(name)); 1916 return obj_elf_hash_n(name, strlen(name));
1922} 1917}
@@ -1939,7 +1934,7 @@ static int ncv_strcmp(const char *a, const char *b)
1939/* String hashing for non-co-versioned kernel and module. Here 1934/* String hashing for non-co-versioned kernel and module. Here
1940 we are simply forced to drop the crc from the hash. */ 1935 we are simply forced to drop the crc from the hash. */
1941 1936
1942static unsigned long ncv_symbol_hash(const char *str) 1937static unsigned long FAST_FUNC ncv_symbol_hash(const char *str)
1943{ 1938{
1944 size_t len = strlen(str); 1939 size_t len = strlen(str);
1945 if (len > 10 && str[len - 10] == '_' && str[len - 9] == 'R') 1940 if (len > 10 && str[len - 10] == '_' && str[len - 9] == 'R')
@@ -1949,8 +1944,8 @@ static unsigned long ncv_symbol_hash(const char *str)
1949 1944
1950static void 1945static void
1951obj_set_symbol_compare(struct obj_file *f, 1946obj_set_symbol_compare(struct obj_file *f,
1952 int (*cmp) (const char *, const char *), 1947 int (*cmp) (const char *, const char *),
1953 unsigned long (*hash) (const char *)) 1948 unsigned long (*hash) (const char *) FAST_FUNC)
1954{ 1949{
1955 if (cmp) 1950 if (cmp)
1956 f->symbol_cmp = cmp; 1951 f->symbol_cmp = cmp;
@@ -1963,13 +1958,14 @@ obj_set_symbol_compare(struct obj_file *f,
1963 memcpy(tmptab, f->symtab, sizeof(tmptab)); 1958 memcpy(tmptab, f->symtab, sizeof(tmptab));
1964 memset(f->symtab, 0, sizeof(f->symtab)); 1959 memset(f->symtab, 0, sizeof(f->symtab));
1965 1960
1966 for (i = 0; i < HASH_BUCKETS; ++i) 1961 for (i = 0; i < HASH_BUCKETS; ++i) {
1967 for (sym = tmptab[i]; sym; sym = next) { 1962 for (sym = tmptab[i]; sym; sym = next) {
1968 unsigned long h = hash(sym->name) % HASH_BUCKETS; 1963 unsigned long h = hash(sym->name) % HASH_BUCKETS;
1969 next = sym->next; 1964 next = sym->next;
1970 sym->next = f->symtab[h]; 1965 sym->next = f->symtab[h];
1971 f->symtab[h] = sym; 1966 f->symtab[h] = sym;
1972 } 1967 }
1968 }
1973 } 1969 }
1974} 1970}
1975 1971
@@ -1977,9 +1973,9 @@ obj_set_symbol_compare(struct obj_file *f,
1977 1973
1978static struct obj_symbol * 1974static struct obj_symbol *
1979obj_add_symbol(struct obj_file *f, const char *name, 1975obj_add_symbol(struct obj_file *f, const char *name,
1980 unsigned long symidx, int info, 1976 unsigned long symidx, int info,
1981 int secidx, ElfW(Addr) value, 1977 int secidx, ElfW(Addr) value,
1982 unsigned long size) 1978 unsigned long size)
1983{ 1979{
1984 struct obj_symbol *sym; 1980 struct obj_symbol *sym;
1985 unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS; 1981 unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
@@ -2140,9 +2136,9 @@ obj_insert_section_load_order(struct obj_file *f, struct obj_section *sec)
2140} 2136}
2141 2137
2142static struct obj_section *helper_create_alloced_section(struct obj_file *f, 2138static struct obj_section *helper_create_alloced_section(struct obj_file *f,
2143 const char *name, 2139 const char *name,
2144 unsigned long align, 2140 unsigned long align,
2145 unsigned long size) 2141 unsigned long size)
2146{ 2142{
2147 int newidx = f->header.e_shnum++; 2143 int newidx = f->header.e_shnum++;
2148 struct obj_section *sec; 2144 struct obj_section *sec;
@@ -2163,9 +2159,9 @@ static struct obj_section *helper_create_alloced_section(struct obj_file *f,
2163} 2159}
2164 2160
2165static struct obj_section *obj_create_alloced_section(struct obj_file *f, 2161static struct obj_section *obj_create_alloced_section(struct obj_file *f,
2166 const char *name, 2162 const char *name,
2167 unsigned long align, 2163 unsigned long align,
2168 unsigned long size) 2164 unsigned long size)
2169{ 2165{
2170 struct obj_section *sec; 2166 struct obj_section *sec;
2171 2167
@@ -2175,9 +2171,9 @@ static struct obj_section *obj_create_alloced_section(struct obj_file *f,
2175} 2171}
2176 2172
2177static struct obj_section *obj_create_alloced_section_first(struct obj_file *f, 2173static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
2178 const char *name, 2174 const char *name,
2179 unsigned long align, 2175 unsigned long align,
2180 unsigned long size) 2176 unsigned long size)
2181{ 2177{
2182 struct obj_section *sec; 2178 struct obj_section *sec;
2183 2179
@@ -2205,9 +2201,9 @@ static void *obj_extend_section(struct obj_section *sec, unsigned long more)
2205 new module. */ 2201 new module. */
2206 2202
2207static int add_symbols_from(struct obj_file *f, 2203static int add_symbols_from(struct obj_file *f,
2208 int idx, 2204 int idx,
2209 struct new_module_symbol *syms, 2205 struct new_module_symbol *syms,
2210 size_t nsyms) 2206 size_t nsyms)
2211{ 2207{
2212 struct new_module_symbol *s; 2208 struct new_module_symbol *s;
2213 size_t i; 2209 size_t i;
@@ -2885,7 +2881,7 @@ obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
2885 2881
2886static void 2882static void
2887obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset, 2883obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
2888 struct obj_symbol *sym) 2884 struct obj_symbol *sym)
2889{ 2885{
2890 struct obj_symbol_patch *p; 2886 struct obj_symbol_patch *p;
2891 2887
@@ -3491,7 +3487,8 @@ static int obj_gpl_license(struct obj_file *f, const char **license)
3491#define TAINT_URL "http://www.tux.org/lkml/#export-tainted" 3487#define TAINT_URL "http://www.tux.org/lkml/#export-tainted"
3492 3488
3493static void set_tainted(int fd, const char *m_name, 3489static void set_tainted(int fd, const char *m_name,
3494 int kernel_has_tainted, int taint, const char *text1, const char *text2) 3490 int kernel_has_tainted, int taint,
3491 const char *text1, const char *text2)
3495{ 3492{
3496 static smallint printed_info; 3493 static smallint printed_info;
3497 3494
@@ -3586,7 +3583,7 @@ get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
3586 */ 3583 */
3587static void 3584static void
3588add_ksymoops_symbols(struct obj_file *f, const char *filename, 3585add_ksymoops_symbols(struct obj_file *f, const char *filename,
3589 const char *m_name) 3586 const char *m_name)
3590{ 3587{
3591 static const char symprefix[] ALIGN1 = "__insmod_"; 3588 static const char symprefix[] ALIGN1 = "__insmod_";
3592 static const char section_names[][8] = { 3589 static const char section_names[][8] = {