当前位置:网站首页>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
边栏推荐
- [mmdetection] solves the installation problem
- Wu Jun's trilogy insight (V) refusing fake workers
- Wu Jun's trilogy experience (VII) the essence of Commerce
- Akamai talking about risk control principles and Solutions
- 连接局域网MySql
- Integrated development management platform
- 当前系统缺少NTFS格式转换器(convert.exe)
- Selenium test of automatic answer runs directly in the browser, just like real users.
- CTF逆向入门题——掷骰子
- Hongmeng introduction and development environment construction
猜你喜欢

【逆向中级】跃跃欲试
![[ASM] introduction and use of bytecode operation classwriter class](/img/0b/87c9851e577df8dcf8198a272b81bd.png)
[ASM] introduction and use of bytecode operation classwriter class

05 personal R & D products and promotion - data synchronization tool
![[reverse intermediate] eager to try](/img/5a/568533850ddfd1c41117da0df50e20.png)
[reverse intermediate] eager to try
![[rapid environment construction] openharmony 10 minute tutorial (cub pie)](/img/b5/feb9c56a65c3b07403710e23078a6f.jpg)
[rapid environment construction] openharmony 10 minute tutorial (cub pie)

Pyspark operator processing spatial data full parsing (4): let's talk about spatial operations first

JVM garbage collector part 2

Final review of information and network security (full version)
![[getting started with MySQL] fourth, explore operators in MySQL with Kiko](/img/11/66b4908ed8f253d599942f35bde96a.png)
[getting started with MySQL] fourth, explore operators in MySQL with Kiko

Grafana 9 is officially released, which is easier to use and more cool!
随机推荐
Detailed explanation of data types of MySQL columns
Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
[ASM] introduction and use of bytecode operation classwriter class
【ASM】字节码操作 ClassWriter 类介绍与使用
Application service configurator (regular, database backup, file backup, remote backup)
Flink parsing (III): memory management
Junit单元测试
06个人研发的产品及推广-代码统计工具
2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally
【MMdetection】一文解决安装问题
03个人研发的产品及推广-计划服务配置器V3.0
EasyRE WriteUp
Integrated development management platform
复盘网鼎杯Re-Signal Writeup
分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
Akamai浅谈风控原理与解决方案
Display picture of DataGridView cell in C WinForm
MySQL advanced (index, view, stored procedure, function, password modification)
Summary of study notes for 2022 soft exam information security engineer preparation
JVM 垃圾回收器之Garbage First