assembly - Nasm ld 重定位被截断以适应:R_X86_64_16
问题描述
我是一个组装新手,我的代码如下所示:
section .text
global _start
_start:
call print_string
.inf_loop:
hlt
jmp .inf_loop
print_string:
cld
mov si, string
.loop
lodsb
cmp al, BYTE 0
je .done
out 0xe9, al
jmp .loop
.done
ret
; The stivale header our kernel needs to be booted via limine
section .stivale2hdr
; This is set to zero, so the bootloader will use the elf entry point
entry_point: dq 0
; This tells the bootloader where our stack is
; Remember the stack grows downwards :)
stack: dq this_is_the_stack+8192
flags: dq 011b
tags: dq 0
section .bss
align 16
this_is_the_stack: resb 8192
section .rodata
string: db "Hello, world!", 0
然后我正在组装:
yasm --arch=x86 --oformat=elf64 --machine=amd64
并与此链接:
ld -Tlinker.ld -nosdtlib -zmax-page-size=0x1000 -static --no-dynamic-linker -ztext
Ld 给我以下错误:
./arch/x86_64/boot.o: in function `no symbol':
arch/x86_64/boot.S:(.text+0xb): relocation truncated to fit: R_X86_64_16 against `.rodata'
make: *** [Makefile:29: kernel.elf] Error 1
我可以改变什么来解决这个问题?您需要查看我的链接器脚本吗?
解决方案
推荐阅读
- ios - 使用 FirebaseAnalytics 的 setAPNSToken 方法上的应用程序崩溃
- puppet - 维护子文件夹和文件的权限,如源:puppet
- javascript - 在 d3.json 中放一个链接
- neo4j - 如果 Cypher 查询中的属性为 Null,则跳过其他属性的关系创建
- python - 一个模型类可以与另一组模型类 django 有特定的关系吗?
- c# - C# xPath 不是有效的表达式
- .net-core - .NET Core 2.1 使用环境变量在 dotnet core 命令 CLI 中使用 git hash 进行构建
- node.js - 使用 nodejs 客户端插入 postgres 时出错
- jquery - Mysql 表列不是 null ,但列我需要在 codeingiter 中为 null
- sql - 如何使用超过 1500 万行的表聚合来调整查询?