当前位置:网站首页>Kernel link script parsing
Kernel link script parsing
2022-07-06 17:39:00 【Wzzzzzzx】
The original text can be found in Kernel link script parsing Check out , Subsequent updates will be updated to Personal blog
The specific code can be seen in Warehouse , Here, choose a few to talk about .
Output architecture
OUTPUT_ARCH
This command is used to specify the system architecture of the output file , What we use here is riscv.
entry point
ENTRY
Defines the entry point of the program ,xv6 The default entry point for is _entry
. The entry point code is entry.S Inside .
Position counter
Get into SECTIONS
after , The default initial address of the current program is 0x0. Here with Linux The file system of , use “.” To represent the current address . The name of this symbol is Position counter (location counter), Indicates the following paragraph / The memory address corresponding to the variable . This means that if you give it directly “.” assignment , It is equivalent to switching the working directory , The relative position of subsequent segments will change .
Here is a simple example
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
. = 0x8000000;
.data : { *(.data) }
.bss : { *(.bss) }
}
Get into SECTIONS
after , The position counter will be set to 0x10000, So the linker will .text
The address of is set to 0x10000. complete .text
After setting , The position counter will be changed to 0x8000000,.data
The address of will be set to 0x8000000. turn .bss
When , It will follow .data
paragraph , At this time, the value of the position counter is 0x8000000 add .data
The size of the segment .
xv6
Initial address setting
As soon as you enter SECTIONS
The script will set the current initial path to 0x80000000. The teacher said in class that this address is qemu Approved address , The first instruction that must be placed is it . Book 2.6 section The saying is 0x0 To 0x80000000 This address is used to place IO equipment , So the address of the first instruction must be 0x80000000.
Segment content parsing
.text : {
*(.text .text.*)
. = ALIGN(0x1000);
_trampoline = .;
*(trampsec)
. = ALIGN(0x1000);
ASSERT(. - _trampoline == 0x1000, "error: trampoline larger than one page");
PROVIDE(etext = .);
}
The segment settings of the kernel are similar , So look at one .text
That's all right. .
.text
The first expression of the segment *(.text .text.*)
, Among them *
The wildcard . It represents .text
and .text.*
Segments are placed in the output file .text
In the paragraph .
Then there are orders ALIGN(exp)
, This command will return the position counter to align to the next exp
Address of boundary , It does not modify the value of the position counter .
PROVIDE
This order is similar to GCC Medium attribute((weak))
. Now we only need to understand it simply as defining a symbol .
remainder _trampoline
and trampsec
The chapter of the page table will cover , Then you can go and understand .
Reference resources
边栏推荐
- 04 products and promotion developed by individuals - data push tool
- PySpark算子处理空间数据全解析(4): 先说说空间运算
- Interpretation of Flink source code (II): Interpretation of jobgraph source code
- 【MySQL入门】第四话 · 和kiko一起探索MySQL中的运算符
- [ciscn 2021 South China]rsa writeup
- Kali2021 installation and basic configuration
- 网络分层概念及基本知识
- Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
- Flink parsing (VII): time window
- 集成开发管理平台
猜你喜欢
Wu Jun trilogy insight (IV) everyone's wisdom
JVM 垃圾回收器之Serial SerialOld ParNew
JVM garbage collector part 2
BearPi-HM_ Nano development board "flower protector" case
JVM 垃圾回收器之Garbage First
全网最全tcpdump和Wireshark抓包实践
Flink analysis (II): analysis of backpressure mechanism
[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias
自动化运维利器ansible基础
About selenium starting Chrome browser flash back
随机推荐
Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
TCP connection is more than communicating with TCP protocol
[VNCTF 2022]ezmath wp
Akamai 反混淆篇
Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
Chrome prompts the solution of "your company management" (the startup page is bound to the company's official website and cannot be modified)
Selenium test of automatic answer runs directly in the browser, just like real users.
[rapid environment construction] openharmony 10 minute tutorial (cub pie)
mysql高級(索引,視圖,存儲過程,函數,修改密碼)
[reverse] repair IAT and close ASLR after shelling
The most complete tcpdump and Wireshark packet capturing practice in the whole network
02个人研发的产品及推广-短信平台
03个人研发的产品及推广-计划服务配置器V3.0
微信防撤回是怎么实现的?
Learn the wisdom of investment Masters
JVM garbage collector part 1
案例:检查空字段【注解+反射+自定义异常】
网络分层概念及基本知识
February database ranking: how long can Oracle remain the first?
JVM garbage collector part 2