ONLY_IF_RO
ONLY_IF_RO 关键字用于表示在所有输入文件的 section 为只读的时候,输出 section
才能生成。语法如下:
一个简单例子
e.g. 三个源文件 DemoA.c,DemoB.c 和 DemoC.c,其中 DemoA.c 引用 DemoA.c 和
DemoB.c 里面的函数,使用 GCC 生成独立的目标文件 DemoA.o,DemoB.o 和 DemoC.o。
ld 使用链接脚本 Demo.lds, 并且在 Demo.lds 里面通过使用 ONLY_IF_RO 关键字生成一
个只读的输出 section:
DemoA.c
DemoB.c
DemoC.c
Demo.lds
使用如下命令进行编译和链接:
通过运行的数据可知,输出 DemoRD section 只包含输入文件的只读 section。
附录
BiscuitOS Home
BiscuitOS Driver
BiscuitOS Kernel Build
Linux Kernel
Bootlin: Elixir Cross Referencer
赞赏一下吧 🙂