Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
597ced79
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
597ced79
编写于
9月 08, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 08, 2021
浏览文件
操作
浏览文件
下载
差异文件
!595 fix: dyload open close failed
Merge pull request !595 from MGY917/dyload_fd
上级
de8257bc
5e87d8c1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
17 deletion
+33
-17
kernel/extended/dynload/include/los_load_elf.h
kernel/extended/dynload/include/los_load_elf.h
+1
-1
kernel/extended/dynload/src/los_load_elf.c
kernel/extended/dynload/src/los_load_elf.c
+32
-16
未找到文件。
kernel/extended/dynload/include/los_load_elf.h
浏览文件 @
597ced79
...
...
@@ -89,7 +89,7 @@ typedef struct {
LD_ELF_EHDR
elfEhdr
;
LD_ELF_PHDR
*
elfPhdr
;
UINT32
fileLen
;
INT32
fd
;
INT32
proc
fd
;
}
ELFInfo
;
typedef
struct
{
...
...
kernel/extended/dynload/src/los_load_elf.c
浏览文件 @
597ced79
...
...
@@ -68,6 +68,20 @@ static int OsELFOpen(const CHAR *fileName, INT32 oflags)
}
AssociateSystemFd
(
procFd
,
ret
);
return
procFd
;
}
static
int
OsELFClose
(
int
procFd
)
{
int
ret
;
/* Process procfd convert to system global procfd */
int
sysfd
=
DisassociateProcessFd
(
procFd
);
ret
=
close
(
sysfd
);
if
(
ret
<
0
)
{
AssociateSystemFd
(
procFd
,
sysfd
);
return
-
get_errno
();
}
FreeProcessFd
(
procFd
);
return
ret
;
}
...
...
@@ -101,10 +115,11 @@ STATIC INT32 OsGetFileLength(UINT32 *fileLen, const CHAR *fileName)
return
LOS_OK
;
}
STATIC
INT32
OsReadELFInfo
(
INT32
fd
,
UINT8
*
buffer
,
size_t
readSize
,
off_t
offset
)
STATIC
INT32
OsReadELFInfo
(
INT32
proc
fd
,
UINT8
*
buffer
,
size_t
readSize
,
off_t
offset
)
{
ssize_t
byteNum
;
off_t
returnPos
;
INT32
fd
=
GetAssociatedSystemFd
(
procfd
);
if
(
readSize
>
0
)
{
returnPos
=
lseek
(
fd
,
offset
,
SEEK_SET
);
...
...
@@ -178,8 +193,8 @@ STATIC VOID OsLoadInit(ELFLoadInfo *loadInfo)
#else
loadInfo
->
oldFiles
=
NULL
;
#endif
loadInfo
->
execInfo
.
fd
=
INVALID_FD
;
loadInfo
->
interpInfo
.
fd
=
INVALID_FD
;
loadInfo
->
execInfo
.
proc
fd
=
INVALID_FD
;
loadInfo
->
interpInfo
.
proc
fd
=
INVALID_FD
;
}
STATIC
INT32
OsReadEhdr
(
const
CHAR
*
fileName
,
ELFInfo
*
elfInfo
,
BOOL
isExecFile
)
...
...
@@ -196,17 +211,17 @@ STATIC INT32 OsReadEhdr(const CHAR *fileName, ELFInfo *elfInfo, BOOL isExecFile)
PRINT_ERR
(
"%s[%d], Failed to open ELF file: %s!
\n
"
,
__FUNCTION__
,
__LINE__
,
fileName
);
return
ret
;
}
elfInfo
->
fd
=
ret
;
elfInfo
->
proc
fd
=
ret
;
#ifdef LOSCFG_DRIVERS_TZDRIVER
if
(
isExecFile
)
{
ret
=
fs_getfilep
(
elfInfo
->
fd
,
&
OsCurrProcessGet
()
->
execFile
);
ret
=
fs_getfilep
(
GetAssociatedSystemFd
(
elfInfo
->
procfd
)
,
&
OsCurrProcessGet
()
->
execFile
);
if
(
ret
)
{
PRINT_ERR
(
"%s[%d], Failed to get struct file %s!
\n
"
,
__FUNCTION__
,
__LINE__
,
fileName
);
}
}
#endif
ret
=
OsReadELFInfo
(
elfInfo
->
fd
,
(
UINT8
*
)
&
elfInfo
->
elfEhdr
,
sizeof
(
LD_ELF_EHDR
),
0
);
ret
=
OsReadELFInfo
(
elfInfo
->
proc
fd
,
(
UINT8
*
)
&
elfInfo
->
elfEhdr
,
sizeof
(
LD_ELF_EHDR
),
0
);
if
(
ret
!=
LOS_OK
)
{
PRINT_ERR
(
"%s[%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
EIO
;
...
...
@@ -246,7 +261,7 @@ STATIC INT32 OsReadPhdrs(ELFInfo *elfInfo, BOOL isExecFile)
return
-
ENOMEM
;
}
ret
=
OsReadELFInfo
(
elfInfo
->
fd
,
(
UINT8
*
)
elfInfo
->
elfPhdr
,
size
,
elfEhdr
->
elfPhoff
);
ret
=
OsReadELFInfo
(
elfInfo
->
proc
fd
,
(
UINT8
*
)
elfInfo
->
elfPhdr
,
size
,
elfEhdr
->
elfPhoff
);
if
(
ret
!=
LOS_OK
)
{
(
VOID
)
LOS_MemFree
(
m_aucSysMem0
,
elfInfo
->
elfPhdr
);
elfInfo
->
elfPhdr
=
NULL
;
...
...
@@ -287,7 +302,7 @@ STATIC INT32 OsReadInterpInfo(ELFLoadInfo *loadInfo)
return
-
ENOMEM
;
}
ret
=
OsReadELFInfo
(
loadInfo
->
execInfo
.
fd
,
(
UINT8
*
)
elfInterpName
,
elfPhdr
->
fileSize
,
elfPhdr
->
offset
);
ret
=
OsReadELFInfo
(
loadInfo
->
execInfo
.
proc
fd
,
(
UINT8
*
)
elfInterpName
,
elfPhdr
->
fileSize
,
elfPhdr
->
offset
);
if
(
ret
!=
LOS_OK
)
{
PRINT_ERR
(
"%s[%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
ret
=
-
EIO
;
...
...
@@ -450,13 +465,14 @@ STATIC INT32 OsSetBss(const LD_ELF_PHDR *elfPhdr, INT32 fd, UINTPTR bssStart, UI
return
LOS_OK
;
}
STATIC
INT32
OsMmapELFFile
(
INT32
fd
,
const
LD_ELF_PHDR
*
elfPhdr
,
const
LD_ELF_EHDR
*
elfEhdr
,
UINTPTR
*
elfLoadAddr
,
STATIC
INT32
OsMmapELFFile
(
INT32
proc
fd
,
const
LD_ELF_PHDR
*
elfPhdr
,
const
LD_ELF_EHDR
*
elfEhdr
,
UINTPTR
*
elfLoadAddr
,
UINT32
mapSize
,
UINTPTR
*
loadBase
)
{
const
LD_ELF_PHDR
*
elfPhdrTemp
=
elfPhdr
;
UINTPTR
vAddr
,
mapAddr
,
bssStart
;
UINT32
bssEnd
,
elfProt
,
elfFlags
;
INT32
ret
,
i
;
INT32
fd
=
GetAssociatedSystemFd
(
procfd
);
for
(
i
=
0
;
i
<
elfEhdr
->
elfPhNum
;
++
i
,
++
elfPhdrTemp
)
{
if
(
elfPhdrTemp
->
type
!=
LD_PT_LOAD
)
{
...
...
@@ -522,7 +538,7 @@ STATIC INT32 OsLoadInterpBinary(const ELFLoadInfo *loadInfo, UINTPTR *interpMapB
return
-
EINVAL
;
}
ret
=
OsMmapELFFile
(
loadInfo
->
interpInfo
.
fd
,
loadInfo
->
interpInfo
.
elfPhdr
,
&
loadInfo
->
interpInfo
.
elfEhdr
,
ret
=
OsMmapELFFile
(
loadInfo
->
interpInfo
.
proc
fd
,
loadInfo
->
interpInfo
.
elfPhdr
,
&
loadInfo
->
interpInfo
.
elfEhdr
,
interpMapBase
,
mapSize
,
&
loadBase
);
if
(
ret
!=
LOS_OK
)
{
PRINT_ERR
(
"%s[%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
@@ -911,14 +927,14 @@ STATIC INT32 OsLoadELFSegment(ELFLoadInfo *loadInfo)
}
}
ret
=
OsMmapELFFile
(
loadInfo
->
execInfo
.
fd
,
loadInfo
->
execInfo
.
elfPhdr
,
&
loadInfo
->
execInfo
.
elfEhdr
,
ret
=
OsMmapELFFile
(
loadInfo
->
execInfo
.
proc
fd
,
loadInfo
->
execInfo
.
elfPhdr
,
&
loadInfo
->
execInfo
.
elfEhdr
,
&
loadInfo
->
loadAddr
,
mapSize
,
&
loadBase
);
if
(
ret
!=
LOS_OK
)
{
PRINT_ERR
(
"%s[%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
ret
;
}
if
(
loadInfo
->
interpInfo
.
fd
!=
INVALID_FD
)
{
if
(
loadInfo
->
interpInfo
.
proc
fd
!=
INVALID_FD
)
{
ret
=
OsLoadInterpBinary
(
loadInfo
,
&
interpMapBase
);
if
(
ret
!=
LOS_OK
)
{
return
ret
;
...
...
@@ -974,12 +990,12 @@ STATIC VOID OsDeInitLoadInfo(ELFLoadInfo *loadInfo)
STATIC
VOID
OsDeInitFiles
(
ELFLoadInfo
*
loadInfo
)
{
if
(
loadInfo
->
execInfo
.
fd
!=
INVALID_FD
)
{
(
VOID
)
close
(
loadInfo
->
execInfo
.
fd
);
if
(
loadInfo
->
execInfo
.
proc
fd
!=
INVALID_FD
)
{
(
VOID
)
OsELFClose
(
loadInfo
->
execInfo
.
proc
fd
);
}
if
(
loadInfo
->
interpInfo
.
fd
!=
INVALID_FD
)
{
(
VOID
)
close
(
loadInfo
->
interpInfo
.
fd
);
if
(
loadInfo
->
interpInfo
.
proc
fd
!=
INVALID_FD
)
{
(
VOID
)
OsELFClose
(
loadInfo
->
interpInfo
.
proc
fd
);
}
#ifdef LOSCFG_FS_VFS
delete_files_snapshot
((
struct
files_struct
*
)
loadInfo
->
oldFiles
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录