Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
3f2d5aed
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f2d5aed
编写于
3月 22, 2019
作者:
D
Download-Fritz
提交者:
vit9696
3月 23, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcAppleKernelLib: Discard undefined and resolve indirect symbols of KPIs.
上级
be490767
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
2 deletion
+61
-2
Library/OcAppleKernelLib/PrelinkedKext.c
Library/OcAppleKernelLib/PrelinkedKext.c
+61
-2
未找到文件。
Library/OcAppleKernelLib/PrelinkedKext.c
浏览文件 @
3f2d5aed
...
...
@@ -204,15 +204,21 @@ InternalScanCurrentPrelinkedKext (
STATIC
EFI_STATUS
InternalScanBuildLinkedSymbolTable
(
IN
OUT
PRELINKED_KEXT
*
Kext
IN
OUT
PRELINKED_KEXT
*
Kext
,
IN
PRELINKED_CONTEXT
*
Context
)
{
CONST
MACH_HEADER_64
*
MachHeader
;
BOOLEAN
ResolveSymbols
;
PRELINKED_KEXT_SYMBOL
*
SymbolTable
;
PRELINKED_KEXT_SYMBOL
*
WalkerBottom
;
PRELINKED_KEXT_SYMBOL
*
WalkerTop
;
UINT32
NumCxxSymbols
;
UINT32
NumDiscardedSyms
;
UINT32
Index
;
CONST
MACH_NLIST_64
*
Symbol
;
MACH_NLIST_64
SymbolScratch
;
CONST
PRELINKED_KEXT_SYMBOL
*
ResolvedSymbol
;
CONST
CHAR8
*
Name
;
BOOLEAN
Result
;
...
...
@@ -225,6 +231,14 @@ InternalScanBuildLinkedSymbolTable (
return
EFI_OUT_OF_RESOURCES
;
}
MachHeader
=
MachoGetMachHeader64
(
&
Kext
->
Context
.
MachContext
);
ASSERT
(
MachHeader
!=
NULL
);
//
// KPIs declare undefined and indirect symbols even in prelinkedkernel.
//
ResolveSymbols
=
((
MachHeader
->
Flags
&
MACH_HEADER_FLAG_NO_UNDEFINED_REFERENCES
)
==
0
);
NumDiscardedSyms
=
0
;
WalkerBottom
=
&
SymbolTable
[
0
];
WalkerTop
=
&
SymbolTable
[
Kext
->
NumberOfSymbols
-
1
];
...
...
@@ -235,6 +249,39 @@ InternalScanBuildLinkedSymbolTable (
Name
=
MachoGetSymbolName64
(
&
Kext
->
Context
.
MachContext
,
Symbol
);
Result
=
MachoSymbolNameIsCxx
(
Name
);
if
(
ResolveSymbols
)
{
//
// Undefined symbols will be resolved via the KPI's dependencies and
// hence do not need to be included (again).
//
if
((
Symbol
->
Type
&
MACH_N_TYPE_TYPE
)
==
MACH_N_TYPE_UNDF
)
{
++
NumDiscardedSyms
;
continue
;
}
//
// Resolve indirect symbols via the KPI's dependencies (kernel).
//
if
((
Symbol
->
Type
&
MACH_N_TYPE_TYPE
)
==
MACH_N_TYPE_INDR
)
{
Name
=
MachoGetIndirectSymbolName64
(
&
Kext
->
Context
.
MachContext
,
Symbol
);
if
(
Name
==
NULL
)
{
return
EFI_LOAD_ERROR
;
}
CopyMem
(
&
SymbolScratch
,
Symbol
,
sizeof
(
SymbolScratch
));
ResolvedSymbol
=
InternalOcGetSymbolByName
(
Context
,
Kext
,
Name
,
OcGetSymbolFirstLevel
);
if
(
ResolvedSymbol
==
NULL
)
{
return
EFI_NOT_FOUND
;
}
SymbolScratch
.
Value
=
ResolvedSymbol
->
Value
;
Symbol
=
&
SymbolScratch
;
}
}
if
(
!
Result
)
{
WalkerBottom
->
StringIndex
=
Symbol
->
UnifiedName
.
StringIndex
;
WalkerBottom
->
Value
=
Symbol
->
Value
;
...
...
@@ -247,6 +294,18 @@ InternalScanBuildLinkedSymbolTable (
++
NumCxxSymbols
;
}
}
//
// Move the C++ symbols to the actual end of the non-C++ symbols as undefined
// symbols got discarded.
//
if
(
NumDiscardedSyms
>
0
)
{
CopyMem
(
&
SymbolTable
[
Kext
->
NumberOfSymbols
-
NumCxxSymbols
-
NumDiscardedSyms
],
&
SymbolTable
[
Kext
->
NumberOfSymbols
-
NumCxxSymbols
],
(
NumCxxSymbols
*
sizeof
(
*
SymbolTable
))
);
Kext
->
NumberOfSymbols
-=
NumDiscardedSyms
;
}
Kext
->
LinkedSymbolTable
=
SymbolTable
;
Kext
->
NumberOfCxxSymbols
=
NumCxxSymbols
;
...
...
@@ -357,7 +416,7 @@ InternalInsertPrelinkedKextDependency (
return
Status
;
}
Status
=
InternalScanBuildLinkedSymbolTable
(
DependencyKext
);
Status
=
InternalScanBuildLinkedSymbolTable
(
DependencyKext
,
Context
);
if
(
EFI_ERROR
(
Status
))
{
return
Status
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录