Page 1 of 1

Linker has problem with addressing

Posted: Sun Jan 10, 2010 12:45 am
by brodeur235
If I try to access data at some location in the following way: "DWORD [ some_label ]" nasm will assemble fine as expected, but ld throws an error that I cannot fix... The error looks like this:

Code: Select all

./../assembled_modules/bl_s2.o: In function `bl_s2_main':
./../source/boot_loader/stage_2/bl_s2.asm:(.text+0x12): relocation truncated to fit: R_386_16 against `.text'
This is preventing me from addressing anything (I'm still in my boot loader and haven't even begun to switch from 16 to 32 bit at all yet).

Here's a cut-out of an example source that generates this error:

Code: Select all

%include "system.inc"

[BITS 16]
bl_s2_main:
	
	; disable interrupts
	cli
	
	; setup stack
	xor ax,ax
	mov ss,ax
	mov esp,0x00008000
	
	; setup data
	xor ax,ax
	mov ds,ax
	
	mov ax, [ (apple+0x7C00) ]
	
	; pause
	jmp $
	
	apple dw 0x0000
This error appears per occurrence.
Help appreciated,

Brodeur235

Re: Linker has problem with addressing

Posted: Sun Jan 10, 2010 2:51 am
by Gigasoft
Where is .text linked at? If the address is too high, it will warn you because it doesn't fit in 16 bits.