Linking problem
Linking problem
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
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
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...
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...
Every good solution is obvious once you've found it.
Re:Linking problem
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).
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
Contact your nearest Wikkan coven. Can't promise on the virgins, though. ;DCurufir 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? )...
Every good solution is obvious once you've found it.
Re:Linking problem
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
You're not trying to, but perhaps you are doing so anyway.Federico Tomassetti wrote: I'm not trying to mix 16/32 bit code...
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.
Every good solution is obvious once you've found it.
Re:Linking problem
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)
[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
I admit my reply was flippant, but there was an answer in there if you read the whole thing.
From interrupt.asm
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.
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
Code: Select all
.text 0x18400 : {
*(.text)
}
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
>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
Now I understand what you mean, thanks a lot