Page 1 of 1
Linking problem
Posted: Mon Sep 13, 2004 5:47 am
by Federico Tomassetti
Hello,
I obtained this error:
..objects/interrupt.obj: relocation truncated to fit: 16 .text
linking 32 bit code compiled with nasm (aout output).
I understood that this error usually regards 16 bit code but
the incriminated file (interrupt.asm compiled as objects/interrupt.obj
start with [BITS 32] (NASM directive).
Maybe some other os developer encountered the same problem...
Federico
Re:Linking problem
Posted: Mon Sep 13, 2004 6:59 am
by Solar
Hmmm... what linker are you using, what output formal are you targeting?
Have you googled for your error message?
I got
http://my.execpc.com/~geezer/osd/gotchas/ and
http://my.execpc.com/~geezer/temp/qna.txt on my google, hinting that you might have attempted to mix 16 bit and 32 bit code...
Re:Linking problem
Posted: Mon Sep 13, 2004 8:19 am
by Curufir
That's definitely a 32-bit -> 16-bit label problem.
After checking the alignment of Jupiter and Venus, sacrificing a bushel of grapes at the witching hour, and dancing naked with virgins in the rain (I can dream can't I?
) I surmise that you're probably trying to use a 32-bit label in one of the 16-bit IDT address fields (Or linking somewhere that is high enough to need more than 16-bits for sucha a label).
Re:Linking problem
Posted: Mon Sep 13, 2004 10:14 pm
by Solar
Curufir wrote:
After checking the alignment of Jupiter and Venus, sacrificing a bushel of grapes at the witching hour, and dancing naked with virgins in the rain (I can dream can't I?
)...
Contact your nearest Wikkan coven. Can't promise on the virgins, though. ;D
Re:Linking problem
Posted: Tue Sep 14, 2004 12:42 pm
by Federico Tomassetti
I read the documents are you talkin' about. I'm not trying to mix 16/32 bit code, I generate 32 bit code with nasm and link with ld this objects and others C source file compiled with gcc. I think that NASM is compiling my code as 16 bit code...
Re:Linking problem
Posted: Tue Sep 14, 2004 10:52 pm
by Solar
Federico Tomassetti wrote:
I'm not trying to mix 16/32 bit code...
You're not trying to, but perhaps you are doing so anyway.
It's hard to tell without further input. What are the command lines for NASM, GCC, and LD? What does your linker script look like? What are the sources?
Pack a small ZIP archive and attach it to a post, then we can have a look at it.
Re:Linking problem
Posted: Wed Sep 15, 2004 1:26 am
by Federico Tomassett
Every *.asm file begins with this:
[BITS 32]
ld's script:
OUTPUT_FORMAT("binary")
ENTRY(code32bit)
SECTIONS
{
.text 0x18400 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
Line to compile *.asm:
nasm -f aout $< -o $@ -i${INCLUDE_ASM}/
Linking command line:
ld -T stage2.ld ${STAGE2_OBJ_ASM} ${STAGE2_OBJ_C} -o $@
In the zip there's also switch.asm that is in 16 bit assembler but is not linked with others file (anyway the linker complaint on a 32 bit file, interrupt.asm)
Re:Linking problem
Posted: Wed Sep 15, 2004 4:48 am
by Curufir
I admit my reply was flippant, but there was an answer in there if you read the whole thing.
From interrupt.asm
Code: Select all
%macro IDT_SELECTOR 3
dw %2 ; offset 00-15
dw %1 ; selector
dw 0x8E00 ; Ring 0, present
dw %3 ; offset 16-31
%endmacro
...
IDT_SELECTOR LINEAR_CODE_SEL, isr00, 0
From stage2.ld
Label isr00 gets altered to something greater than 0x18400 as part of the linking process and you then try to place this 32-bit address into a 16-bit field. At this point the linker takes its teddy bear home and doesn't want to play any more. This applies to all your IDT entries.
If you want to use addresses that are 32-bit for IDT entries you're going to have to seperate out the high/low 16-bits yourself.
Re:Linking problem
Posted: Wed Sep 15, 2004 12:48 pm
by Federico Tomassett
>Label isr00 gets altered to something greater than 0x18400 as >part of the linking process and you then try to place this 32-bit >address into a 16-bit field. At this point the linker takes its teddy >bear home and doesn't want to play any more. This applies to all >your IDT entries.
Now I understand what you mean, thanks a lot