当前位置:网站首页>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
边栏推荐
- Xin'an Second Edition: Chapter 12 network security audit technology principle and application learning notes
- Flink analysis (II): analysis of backpressure mechanism
- Flink analysis (I): basic concept analysis
- PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
- 02 personal developed products and promotion - SMS platform
- 华为认证云计算HICA
- Solr appears write Lock, solrexception: could not get leader props in the log
- JVM 垃圾回收器之Serial SerialOld ParNew
- Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
- [ASM] introduction and use of bytecode operation classwriter class
猜你喜欢

信息与网络安全期末复习(完整版)

yarn : 无法加载文件 D:\ProgramFiles\nodejs\yarn.ps1,因为在此系统上禁止运行脚本

【MySQL入门】第一话 · 初入“数据库”大陆

基于LNMP部署flask项目

February database ranking: how long can Oracle remain the first?

Garbage first of JVM garbage collector

复盘网鼎杯Re-Signal Writeup

The NTFS format converter (convert.exe) is missing from the current system

C # nanoframework lighting and key esp32

Grafana 9 正式发布,更易用,更酷炫了!
随机推荐
自动化运维利器-Ansible-Playbook
【逆向初级】独树一帜
CTF reverse entry question - dice
Virtual machine startup prompt probing EDD (edd=off to disable) error
分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
JVM 垃圾回收器之Serial SerialOld ParNew
05 personal R & D products and promotion - data synchronization tool
【MySQL入门】第三话 · MySQL中常见的数据类型
Redis installation on centos7
【MySQL入门】第一话 · 初入“数据库”大陆
Error: Publish of Process project to Orchestrator failed. The operation has timed out.
Program counter of JVM runtime data area
How does wechat prevent withdrawal come true?
Hongmeng introduction and development environment construction
Flink parsing (IV): recovery mechanism
[CISCN 2021 华南赛区]rsa Writeup
网络分层概念及基本知识
Flink parsing (VII): time window
Selenium test of automatic answer runs directly in the browser, just like real users.
Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system