重定位被截断以适合.bss的r_386_8 [英] relocation truncated to fit r_386_8 against .bss'

查看:105
本文介绍了重定位被截断以适合.bss的r_386_8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入ld -m elf_i386 -o loop loop.asm时,出现标题中所述的错误,是什么原因引起的?很抱歉,如果代码看起来不好,对于汇编来说还是很新的.

When i type ld -m elf_i386 -o loop loop.asm, i get the error stated in the title, any idea what causes it? Sorry if the code looks bad, fairly new to assembly.

cr equ 13 
lf equ 10 

section .bss
numA resb 1

section .text

global _start:

mov [numA],byte 0
call loop1
jmp endend
loop1:
xor cx,cx
mov al, $numA
cmp cx, 0x0A
jle else 
inc al
jmp end
else:
dec al
jmp end
end:
mov [$numA], al
inc cx
cmp cx,20
jle loop1

endend:
mov dl,$numA
mov ah,2
int 21h

推荐答案

在NASM中,$numAnumA相同. 前导$阻止汇编程序将其视为寄存器名称.因此,您可以编写mov eax, [$eax]来从名为eax的符号中加载eax寄存器. (因此,您可以链接到使用int eax = 123;的C)

In NASM, $numA is the same as numA. A leading $ stops the assembler from considering it as a register name. Thus you can write mov eax, [$eax] to load the eax register from a symbol called eax. (So you could link with C which used int eax = 123;)

所以mov [$numA], al看起来很奇怪,但实际上只是mov [numA], al,而不是警告的来源.

So mov [$numA], al looks weird, but it's really just mov [numA], al and isn't the source of the warning.

您会从mov dl,$numA得到警告,该警告将对地址的低字节进行mov dl, imm8.

You're getting the warning from mov dl,$numA which does a mov dl, imm8 of the low byte of the address.

链接器警告您,因为numA的地址不适合1个字节,因此r_386_8重定位会截断该地址.

The linker warns you because the address of numA doesn't fit in 1 byte, so the r_386_8 relocation truncated the address.

_8告诉您这是一个重定位,要求链接程序填写8位. r_386告诉您这是i386重定位,而不是某些系统V gABI中的重定位(通用ABI,用于i386 SysV psABI是处理器补充".

The _8 tells you it's a relocation that asks the linker to fill in 8 bits. The r_386 tells you it's an i386 relocation as opposed to some type of r_x86_64 relocation (which could be absolute or RIP-relative), or a MIPS jump-target relocation (which would need to right-shift the offset by 2). Possibly related: Relocations in the System V gABI (generic ABI, for which the i386 SysV psABI is a "processor supplement").

这篇关于重定位被截断以适合.bss的r_386_8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆