Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
ff6fd469
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ff6fd469
编写于
17年前
作者:
C
Chris Zankel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XTENSA] Add kernel module support
Add kernel module support. Signed-off-by:
N
Chris Zankel
<
chris@zankel.net
>
上级
01858d1b
无相关合并请求
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
227 addition
and
18 deletion
+227
-18
arch/xtensa/kernel/module.c
arch/xtensa/kernel/module.c
+177
-18
include/asm-xtensa/elf.h
include/asm-xtensa/elf.h
+50
-0
未找到文件。
arch/xtensa/kernel/module.c
浏览文件 @
ff6fd469
...
...
@@ -7,7 +7,7 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2001 - 200
5
Tensilica Inc.
* Copyright (C) 2001 - 200
6
Tensilica Inc.
*
* Chris Zankel <chris@zankel.net>
*
...
...
@@ -22,57 +22,216 @@
#include <linux/kernel.h>
#include <linux/cache.h>
LIST_HEAD
(
module_buf_list
);
#undef DEBUG_RELOCATE
void
*
module_alloc
(
unsigned
long
size
)
{
panic
(
"module_alloc not implemented"
);
if
(
size
==
0
)
return
NULL
;
return
vmalloc
(
size
);
}
void
module_free
(
struct
module
*
mod
,
void
*
module_region
)
{
panic
(
"module_free not implemented"
);
vfree
(
module_region
);
/* FIXME: If module_region == mod->init_region, trim exception
table entries. */
}
int
module_frob_arch_sections
(
Elf32_Ehdr
*
hdr
,
Elf32_Shdr
*
sechdrs
,
char
*
secstrings
,
struct
module
*
m
e
)
struct
module
*
m
od
)
{
panic
(
"module_frob_arch_sections not implemented"
);
return
0
;
}
static
int
decode_calln_opcode
(
unsigned
char
*
location
)
{
#ifdef __XTENSA_EB__
return
(
location
[
0
]
&
0xf0
)
==
0x50
;
#endif
#ifdef __XTENSA_EL__
return
(
location
[
0
]
&
0xf
)
==
0x5
;
#endif
}
static
int
decode_l32r_opcode
(
unsigned
char
*
location
)
{
#ifdef __XTENSA_EB__
return
(
location
[
0
]
&
0xf0
)
==
0x10
;
#endif
#ifdef __XTENSA_EL__
return
(
location
[
0
]
&
0xf
)
==
0x1
;
#endif
}
int
apply_relocate
(
Elf32_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
mod
ule
)
struct
module
*
mod
)
{
panic
(
"apply_relocate not implemented"
);
printk
(
KERN_ERR
"module %s: REL RELOCATION unsupported
\n
"
,
mod
->
name
);
return
-
ENOEXEC
;
}
int
apply_relocate_add
(
Elf32_Shdr
*
sechdrs
,
const
char
*
strtab
,
unsigned
int
symindex
,
unsigned
int
relsec
,
struct
module
*
mod
ule
)
struct
module
*
mod
)
{
panic
(
"apply_relocate_add not implemented"
);
unsigned
int
i
;
Elf32_Rela
*
rela
=
(
void
*
)
sechdrs
[
relsec
].
sh_addr
;
Elf32_Sym
*
sym
;
unsigned
char
*
location
;
uint32_t
value
;
#ifdef DEBUG_RELOCATE
printk
(
"Applying relocate section %u to %u
\n
"
,
relsec
,
sechdrs
[
relsec
].
sh_info
);
#endif
for
(
i
=
0
;
i
<
sechdrs
[
relsec
].
sh_size
/
sizeof
(
*
rela
);
i
++
)
{
location
=
(
char
*
)
sechdrs
[
sechdrs
[
relsec
].
sh_info
].
sh_addr
+
rela
[
i
].
r_offset
;
sym
=
(
Elf32_Sym
*
)
sechdrs
[
symindex
].
sh_addr
+
ELF32_R_SYM
(
rela
[
i
].
r_info
);
value
=
sym
->
st_value
+
rela
[
i
].
r_addend
;
switch
(
ELF32_R_TYPE
(
rela
[
i
].
r_info
))
{
case
R_XTENSA_NONE
:
case
R_XTENSA_DIFF8
:
case
R_XTENSA_DIFF16
:
case
R_XTENSA_DIFF32
:
case
R_XTENSA_ASM_EXPAND
:
break
;
case
R_XTENSA_32
:
case
R_XTENSA_PLT
:
*
(
uint32_t
*
)
location
+=
value
;
break
;
case
R_XTENSA_SLOT0_OP
:
if
(
decode_calln_opcode
(
location
))
{
value
-=
((
unsigned
long
)
location
&
-
4
)
+
4
;
if
((
value
&
3
)
!=
0
||
((
value
+
(
1
<<
19
))
>>
20
)
!=
0
)
{
printk
(
"%s: relocation out of range, "
"section %d reloc %d "
"sym '%s'
\n
"
,
mod
->
name
,
relsec
,
i
,
strtab
+
sym
->
st_name
);
return
-
ENOEXEC
;
}
value
=
(
signed
int
)
value
>>
2
;
#ifdef __XTENSA_EB__
location
[
0
]
=
((
location
[
0
]
&
~
0x3
)
|
((
value
>>
16
)
&
0x3
));
location
[
1
]
=
(
value
>>
8
)
&
0xff
;
location
[
2
]
=
value
&
0xff
;
#endif
#ifdef __XTENSA_EL__
location
[
0
]
=
((
location
[
0
]
&
~
0xc0
)
|
((
value
<<
6
)
&
0xc0
));
location
[
1
]
=
(
value
>>
2
)
&
0xff
;
location
[
2
]
=
(
value
>>
10
)
&
0xff
;
#endif
}
else
if
(
decode_l32r_opcode
(
location
))
{
value
-=
(((
unsigned
long
)
location
+
3
)
&
-
4
);
if
((
value
&
3
)
!=
0
||
(
signed
int
)
value
>>
18
!=
-
1
)
{
printk
(
"%s: relocation out of range, "
"section %d reloc %d "
"sym '%s'
\n
"
,
mod
->
name
,
relsec
,
i
,
strtab
+
sym
->
st_name
);
return
-
ENOEXEC
;
}
value
=
(
signed
int
)
value
>>
2
;
#ifdef __XTENSA_EB__
location
[
1
]
=
(
value
>>
8
)
&
0xff
;
location
[
2
]
=
value
&
0xff
;
#endif
#ifdef __XTENSA_EL__
location
[
1
]
=
value
&
0xff
;
location
[
2
]
=
(
value
>>
8
)
&
0xff
;
#endif
}
/* FIXME: Ignore any other opcodes. The Xtensa
assembler currently assumes that the linker will
always do relaxation and so all PC-relative
operands need relocations. (The assembler also
writes out the tentative PC-relative values,
assuming no link-time relaxation, so it is usually
safe to ignore the relocations.) If the
assembler's "--no-link-relax" flag can be made to
work, and if all kernel modules can be assembled
with that flag, then unexpected relocations could
be detected here. */
break
;
case
R_XTENSA_SLOT1_OP
:
case
R_XTENSA_SLOT2_OP
:
case
R_XTENSA_SLOT3_OP
:
case
R_XTENSA_SLOT4_OP
:
case
R_XTENSA_SLOT5_OP
:
case
R_XTENSA_SLOT6_OP
:
case
R_XTENSA_SLOT7_OP
:
case
R_XTENSA_SLOT8_OP
:
case
R_XTENSA_SLOT9_OP
:
case
R_XTENSA_SLOT10_OP
:
case
R_XTENSA_SLOT11_OP
:
case
R_XTENSA_SLOT12_OP
:
case
R_XTENSA_SLOT13_OP
:
case
R_XTENSA_SLOT14_OP
:
printk
(
"%s: unexpected FLIX relocation: %u
\n
"
,
mod
->
name
,
ELF32_R_TYPE
(
rela
[
i
].
r_info
));
return
-
ENOEXEC
;
case
R_XTENSA_SLOT0_ALT
:
case
R_XTENSA_SLOT1_ALT
:
case
R_XTENSA_SLOT2_ALT
:
case
R_XTENSA_SLOT3_ALT
:
case
R_XTENSA_SLOT4_ALT
:
case
R_XTENSA_SLOT5_ALT
:
case
R_XTENSA_SLOT6_ALT
:
case
R_XTENSA_SLOT7_ALT
:
case
R_XTENSA_SLOT8_ALT
:
case
R_XTENSA_SLOT9_ALT
:
case
R_XTENSA_SLOT10_ALT
:
case
R_XTENSA_SLOT11_ALT
:
case
R_XTENSA_SLOT12_ALT
:
case
R_XTENSA_SLOT13_ALT
:
case
R_XTENSA_SLOT14_ALT
:
printk
(
"%s: unexpected ALT relocation: %u
\n
"
,
mod
->
name
,
ELF32_R_TYPE
(
rela
[
i
].
r_info
));
return
-
ENOEXEC
;
default:
printk
(
"%s: unexpected relocation: %u
\n
"
,
mod
->
name
,
ELF32_R_TYPE
(
rela
[
i
].
r_info
));
return
-
ENOEXEC
;
}
}
return
0
;
}
int
module_finalize
(
const
Elf_Ehdr
*
hdr
,
const
Elf_Shdr
*
sechdrs
,
struct
module
*
m
e
)
struct
module
*
m
od
)
{
panic
(
"module_finalize not implemented"
)
;
return
0
;
}
void
module_arch_cleanup
(
struct
module
*
mod
)
{
panic
(
"module_arch_cleanup not implemented"
);
}
struct
bug_entry
*
module_find_bug
(
unsigned
long
bugaddr
)
{
panic
(
"module_find_bug not implemented"
);
}
This diff is collapsed.
Click to expand it.
include/asm-xtensa/elf.h
浏览文件 @
ff6fd469
...
...
@@ -20,6 +20,56 @@
#define EM_XTENSA 94
#define EM_XTENSA_OLD 0xABC7
/* Xtensa relocations defined by the ABIs */
#define R_XTENSA_NONE 0
#define R_XTENSA_32 1
#define R_XTENSA_RTLD 2
#define R_XTENSA_GLOB_DAT 3
#define R_XTENSA_JMP_SLOT 4
#define R_XTENSA_RELATIVE 5
#define R_XTENSA_PLT 6
#define R_XTENSA_OP0 8
#define R_XTENSA_OP1 9
#define R_XTENSA_OP2 10
#define R_XTENSA_ASM_EXPAND 11
#define R_XTENSA_ASM_SIMPLIFY 12
#define R_XTENSA_GNU_VTINHERIT 15
#define R_XTENSA_GNU_VTENTRY 16
#define R_XTENSA_DIFF8 17
#define R_XTENSA_DIFF16 18
#define R_XTENSA_DIFF32 19
#define R_XTENSA_SLOT0_OP 20
#define R_XTENSA_SLOT1_OP 21
#define R_XTENSA_SLOT2_OP 22
#define R_XTENSA_SLOT3_OP 23
#define R_XTENSA_SLOT4_OP 24
#define R_XTENSA_SLOT5_OP 25
#define R_XTENSA_SLOT6_OP 26
#define R_XTENSA_SLOT7_OP 27
#define R_XTENSA_SLOT8_OP 28
#define R_XTENSA_SLOT9_OP 29
#define R_XTENSA_SLOT10_OP 30
#define R_XTENSA_SLOT11_OP 31
#define R_XTENSA_SLOT12_OP 32
#define R_XTENSA_SLOT13_OP 33
#define R_XTENSA_SLOT14_OP 34
#define R_XTENSA_SLOT0_ALT 35
#define R_XTENSA_SLOT1_ALT 36
#define R_XTENSA_SLOT2_ALT 37
#define R_XTENSA_SLOT3_ALT 38
#define R_XTENSA_SLOT4_ALT 39
#define R_XTENSA_SLOT5_ALT 40
#define R_XTENSA_SLOT6_ALT 41
#define R_XTENSA_SLOT7_ALT 42
#define R_XTENSA_SLOT8_ALT 43
#define R_XTENSA_SLOT9_ALT 44
#define R_XTENSA_SLOT10_ALT 45
#define R_XTENSA_SLOT11_ALT 46
#define R_XTENSA_SLOT12_ALT 47
#define R_XTENSA_SLOT13_ALT 48
#define R_XTENSA_SLOT14_ALT 49
/* ELF register definitions. This is needed for core dump support. */
/*
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部