[LinkerScript.11] 符号赋值: 规定- Assigning Values to Symbols: PROVIDE
2015-09-06 23:39
459 查看
PROVIDE
In some cases, it is desirable for a linker script to define a symbol only if it is referenced and is not defined by any object included in the link. For example, traditional linkers defined
the symbol ‘etext’. However, ANSI C requires that the user be able to use ‘etext’ as a function name without encountering an error. The PROVIDE keyword may be used to define a symbol, such as ‘etext’, only if it is referenced but not defined. The syntax is
PROVIDE(symbol = expression).
在某些情况下, 由链接器脚本定义的符号,在链接中任何对象仅仅能引用,而不能定义.比如,传统链接器所定义的符号'etext'. 然而,ANSI C要求用户可以使用'etext'作为一个函数名,并且不能报错. PROVIDE关键字用于定义一个符号,如'etext',仅仅是一个引用而不是定义.
该语法是 PROVIDE(symbol = expression)
Here is an example of using PROVIDE to define ‘etext’:
使用PROVIDE定义一个'etext'的例子如下:
SECTIONS
{
.text :
{
*(.text)
_etext = .;
PROVIDE(etext = .);
}
}
In this example, if the program defines ‘_etext’ (with a leading underscore), the linker will give a multiple definition error. If, on the other hand, the program defines ‘etext’ (with no leading underscore), the linker will silently use the definition in the
program. If the program references ‘etext’ but does not define it, the linker will use the definition in the linker script.
在这个例子中,如果程序定义了'_etext' (带有前导下划线), 那么链接器将会报一个多重定义的错误. 另一方面,如果程序定义了'etext'(没有前导下划线),那么链接器将默默地使用程序中的定义.如果程序引用'etext',但没有定义,那么链接器将使用链接器脚本中的定义.
意思是: 在用使用PROVIDE规定一个符号时, 程序中又定义了该符号, 那么程序如果使用该符号,则使用程序中定义的,要是程序中没有定义,则使用链接器脚本中的定义.
PROVIDE_HIDDEN
Similar to PROVIDE. For ELF targeted ports, the symbol will be hidden and won't be exported.
与PROVIDE类似.对于ELF目标文件, 符号将被隐藏并且不会被导出.
In some cases, it is desirable for a linker script to define a symbol only if it is referenced and is not defined by any object included in the link. For example, traditional linkers defined
the symbol ‘etext’. However, ANSI C requires that the user be able to use ‘etext’ as a function name without encountering an error. The PROVIDE keyword may be used to define a symbol, such as ‘etext’, only if it is referenced but not defined. The syntax is
PROVIDE(symbol = expression).
在某些情况下, 由链接器脚本定义的符号,在链接中任何对象仅仅能引用,而不能定义.比如,传统链接器所定义的符号'etext'. 然而,ANSI C要求用户可以使用'etext'作为一个函数名,并且不能报错. PROVIDE关键字用于定义一个符号,如'etext',仅仅是一个引用而不是定义.
该语法是 PROVIDE(symbol = expression)
Here is an example of using PROVIDE to define ‘etext’:
使用PROVIDE定义一个'etext'的例子如下:
SECTIONS
{
.text :
{
*(.text)
_etext = .;
PROVIDE(etext = .);
}
}
In this example, if the program defines ‘_etext’ (with a leading underscore), the linker will give a multiple definition error. If, on the other hand, the program defines ‘etext’ (with no leading underscore), the linker will silently use the definition in the
program. If the program references ‘etext’ but does not define it, the linker will use the definition in the linker script.
在这个例子中,如果程序定义了'_etext' (带有前导下划线), 那么链接器将会报一个多重定义的错误. 另一方面,如果程序定义了'etext'(没有前导下划线),那么链接器将默默地使用程序中的定义.如果程序引用'etext',但没有定义,那么链接器将使用链接器脚本中的定义.
意思是: 在用使用PROVIDE规定一个符号时, 程序中又定义了该符号, 那么程序如果使用该符号,则使用程序中定义的,要是程序中没有定义,则使用链接器脚本中的定义.
PROVIDE_HIDDEN
Similar to PROVIDE. For ELF targeted ports, the symbol will be hidden and won't be exported.
与PROVIDE类似.对于ELF目标文件, 符号将被隐藏并且不会被导出.
相关文章推荐
- UI基础-03 按钮控制图片移动之transform
- UIAlertView
- [LinkerScript.10] 符号赋值: 隐藏 - Assigning Values to Symbols: HIDDEN
- 图片自动播放(用UIScrollView和NSTimer)时定时器的开启和关闭
- UIScrollView
- iOS面试题03-UI控件
- iOS开发UI篇—懒加载
- UI基础-02 按钮控制图片移动
- [LinkerScript.9] 符号赋值: 简单分配 - Assigning Values to Symbols: Simple Assignments
- HDU - 3157 Crazy Circuits(有下界的最小流)
- UE
- hdoj 1159 Common Subsequence 【LCS】
- require.resolve函数
- UIFont相关
- 手势 各大集锦 UI iOS
- zoj3792 Romantic Value 最大流<->最小割
- [NSNull intValue]: unrecognized selector sent to instance 0x375c9860
- UIMenuController的使用,对UILabel拷贝以及定制菜单
- mantis中issue的状态和解决转台说明
- iOS——UIImageView的使用方法详细