~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to arch/m68k/kernel/module.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is subject to the terms and conditions of the GNU General Public
3
 
 * License.  See the file COPYING in the main directory of this archive
4
 
 * for more details.
5
 
 */
6
 
 
7
 
#include <linux/moduleloader.h>
8
 
#include <linux/elf.h>
9
 
#include <linux/vmalloc.h>
10
 
#include <linux/fs.h>
11
 
#include <linux/string.h>
12
 
#include <linux/kernel.h>
13
 
 
14
 
#if 0
15
 
#define DEBUGP printk
 
1
#ifdef CONFIG_MMU
 
2
#include "module_mm.c"
16
3
#else
17
 
#define DEBUGP(fmt...)
 
4
#include "module_no.c"
18
5
#endif
19
 
 
20
 
#ifdef CONFIG_MODULES
21
 
 
22
 
void *module_alloc(unsigned long size)
23
 
{
24
 
        if (size == 0)
25
 
                return NULL;
26
 
        return vmalloc(size);
27
 
}
28
 
 
29
 
 
30
 
/* Free memory returned from module_alloc */
31
 
void module_free(struct module *mod, void *module_region)
32
 
{
33
 
        vfree(module_region);
34
 
}
35
 
 
36
 
/* We don't need anything special. */
37
 
int module_frob_arch_sections(Elf_Ehdr *hdr,
38
 
                              Elf_Shdr *sechdrs,
39
 
                              char *secstrings,
40
 
                              struct module *mod)
41
 
{
42
 
        return 0;
43
 
}
44
 
 
45
 
int apply_relocate(Elf32_Shdr *sechdrs,
46
 
                   const char *strtab,
47
 
                   unsigned int symindex,
48
 
                   unsigned int relsec,
49
 
                   struct module *me)
50
 
{
51
 
        unsigned int i;
52
 
        Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
53
 
        Elf32_Sym *sym;
54
 
        uint32_t *location;
55
 
 
56
 
        DEBUGP("Applying relocate section %u to %u\n", relsec,
57
 
               sechdrs[relsec].sh_info);
58
 
        for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
59
 
                /* This is where to make the change */
60
 
                location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
61
 
                        + rel[i].r_offset;
62
 
                /* This is the symbol it is referring to.  Note that all
63
 
                   undefined symbols have been resolved.  */
64
 
                sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
65
 
                        + ELF32_R_SYM(rel[i].r_info);
66
 
 
67
 
                switch (ELF32_R_TYPE(rel[i].r_info)) {
68
 
                case R_68K_32:
69
 
                        /* We add the value into the location given */
70
 
                        *location += sym->st_value;
71
 
                        break;
72
 
                case R_68K_PC32:
73
 
                        /* Add the value, subtract its postition */
74
 
                        *location += sym->st_value - (uint32_t)location;
75
 
                        break;
76
 
                default:
77
 
                        printk(KERN_ERR "module %s: Unknown relocation: %u\n",
78
 
                               me->name, ELF32_R_TYPE(rel[i].r_info));
79
 
                        return -ENOEXEC;
80
 
                }
81
 
        }
82
 
        return 0;
83
 
}
84
 
 
85
 
int apply_relocate_add(Elf32_Shdr *sechdrs,
86
 
                       const char *strtab,
87
 
                       unsigned int symindex,
88
 
                       unsigned int relsec,
89
 
                       struct module *me)
90
 
{
91
 
        unsigned int i;
92
 
        Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
93
 
        Elf32_Sym *sym;
94
 
        uint32_t *location;
95
 
 
96
 
        DEBUGP("Applying relocate_add section %u to %u\n", relsec,
97
 
               sechdrs[relsec].sh_info);
98
 
        for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
99
 
                /* This is where to make the change */
100
 
                location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
101
 
                        + rel[i].r_offset;
102
 
                /* This is the symbol it is referring to.  Note that all
103
 
                   undefined symbols have been resolved.  */
104
 
                sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
105
 
                        + ELF32_R_SYM(rel[i].r_info);
106
 
 
107
 
                switch (ELF32_R_TYPE(rel[i].r_info)) {
108
 
                case R_68K_32:
109
 
                        /* We add the value into the location given */
110
 
                        *location = rel[i].r_addend + sym->st_value;
111
 
                        break;
112
 
                case R_68K_PC32:
113
 
                        /* Add the value, subtract its postition */
114
 
                        *location = rel[i].r_addend + sym->st_value - (uint32_t)location;
115
 
                        break;
116
 
                default:
117
 
                        printk(KERN_ERR "module %s: Unknown relocation: %u\n",
118
 
                               me->name, ELF32_R_TYPE(rel[i].r_info));
119
 
                        return -ENOEXEC;
120
 
                }
121
 
        }
122
 
        return 0;
123
 
}
124
 
 
125
 
int module_finalize(const Elf_Ehdr *hdr,
126
 
                    const Elf_Shdr *sechdrs,
127
 
                    struct module *mod)
128
 
{
129
 
        module_fixup(mod, mod->arch.fixup_start, mod->arch.fixup_end);
130
 
 
131
 
        return 0;
132
 
}
133
 
 
134
 
void module_arch_cleanup(struct module *mod)
135
 
{
136
 
}
137
 
 
138
 
#endif /* CONFIG_MODULES */
139
 
 
140
 
void module_fixup(struct module *mod, struct m68k_fixup_info *start,
141
 
                  struct m68k_fixup_info *end)
142
 
{
143
 
        struct m68k_fixup_info *fixup;
144
 
 
145
 
        for (fixup = start; fixup < end; fixup++) {
146
 
                switch (fixup->type) {
147
 
                case m68k_fixup_memoffset:
148
 
                        *(u32 *)fixup->addr = m68k_memoffset;
149
 
                        break;
150
 
                case m68k_fixup_vnode_shift:
151
 
                        *(u16 *)fixup->addr += m68k_virt_to_node_shift;
152
 
                        break;
153
 
                }
154
 
        }
155
 
}