Manipulating symbol addresses in GNU Assember
Posted: Fri Feb 13, 2015 4:17 pm
Hi OSDev.org community,
I'm using GNU-Assembler in intel syntax to write my x86 initialization routines and want to set up an IDT. The IDT requires the target address to be split into two 16-bit parts.
Now my question is, is there a possibility to let the assembler do this? I would like to have the (absolute) addresses already stored in the binary, without the need to manually set up the individual IDT entries.
In practice I would like to be able to write the following code:
Running this code through as yields the assembler complaining about argument mismatch for the bitwise and operator, as the symbol reference is section relative.
Is there a way around this? Or is it a limitation of the relocation mechanism of stitching together different object files, so that as cannot emit a request for the upper/lower part of the symbol location to be stored at this place?
I'm using GNU-Assembler in intel syntax to write my x86 initialization routines and want to set up an IDT. The IDT requires the target address to be split into two 16-bit parts.
Now my question is, is there a possibility to let the assembler do this? I would like to have the (absolute) addresses already stored in the binary, without the need to manually set up the individual IDT entries.
In practice I would like to be able to write the following code:
Code: Select all
.macro IGATE SEL FN TP
.word (\FN & 0xffff)
.word \SEL
.byte 0
.byte \TP
.word ((\FN & 0xffff0000) >> 16)
.endm
.align 16
idt:
IGATE 0x08 gate_1 0x8f
idt_end:
gate_1:
call C_function
iret
Is there a way around this? Or is it a limitation of the relocation mechanism of stitching together different object files, so that as cannot emit a request for the upper/lower part of the symbol location to be stored at this place?