Linker has problem with addressing

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
brodeur235
Member
Member
Posts: 86
Joined: Sat Jun 06, 2009 11:55 am

Linker has problem with addressing

Post 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
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Linker has problem with addressing

Post 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.
Post Reply