flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > as fails to resolve ljmp[ptr16:32] to non absolute segment

Author
Thread Post new topic Reply to topic
dstyl



Joined: 23 Jul 2015
Posts: 61
Im trying to get this header for a bootloader assembled.
It was written for the gnu assembler but still fails to compile for no apparent reason.
Code:
/*gnu stuff, 
 * head.S for bootstub to load protected mode kernel
 *
 * Copyright (C) 2008-2010 Intel Corporation.
 * Author: Alek Du <alek.du@intel.com>
*/
#include "bootstub.h"

.text

.section ".text.head","ax",@progbits
        .globl _start

_start:
        cld
        cli
        /* setup stack, because we are heading off to "C" */
        movl $STACK_OFFSET, %esp
        calll bootstub
        /* after call bootstub, GDT is set, IDT is clear
        * eax contains 32-bit entry of bzImage
        */
        movl $__BOOT_DS, %ebx   
        movl %ebx, %ds
        movl %ebx, %es
        movl %ebx, %fs
        movl %ebx, %gs
        movl %ebx, %ss
//.code16//Does nothing
//  ljmp $__BOOT_CS,$1f
    ljmp $__BOOT_CS,$1f
//.code32//Same here
1:
        /* tell kernel where is boot_param */
        movl $(BOOT_PARAMS_OFFSET), %esi
        xor %ebp, %ebp
        xor %edi, %edi
        mov %eax, %ecx
        mov mb_magic, %eax
        mov mb_info, %ebx

        jmpl *%ecx    # Jump to the 32-bit entrypoint
    

The syntax is already in the required 16bit ptr for the segement and 32 bit variable and i changed nothing in the code and it still fails to assemble.
My compile flags are as -32 -o head.o head.S .
Code:
head.S: Assembler messages:
head.S:79: Error: can't handle non absolute segment in `ljmp'
    

Thanks a lot in advance.
Post 10 Dec 2018, 07:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16364
Location: Bricksburg
Rewrite it in human readable fasm syntax and then I'm sure we can get it to work for you. Smile
Post 10 Dec 2018, 09:53
View user's profile Send private message Visit poster's website Reply with quote
dstyl



Joined: 23 Jul 2015
Posts: 61
Thanks a lot, i agree with you att syntax is horrible.
And there are 2 versions of it Very Happy so intel2gas didnt work.
i tried to rewrite it in fasm syntax as good as i could.
It compiles when extrn(i only know extern from nasm) , call bootstub and jmp 0x10:0x10f000222 are commented out.
Code:
;/*
;* head.S for bootstub to load protected mode kernel
;*
;* Copyright (C) 2008-2010 Intel Corporation.
;* Author: Alek Du <alek.du@intel.com>
;*etc....*/
;format ???
;include "bootstub.h"
;extrn '_bootstub' doesnt work
;Unkown what this means...
;.section ".text.head","ax",@progbits"
;entry start
        ;GLOBAL _start

        cld
        cli
        ;setup stack, because we are heading off to "C"
        mov  esp, 0x10f00000;STACK_OFFSET
        ;call  bootstub ;doesnt work adress is seg:0x372
        ;calll bootstub ???
        ;after call bootstub, GDT is set, IDT is clear
        ;eax contains 32-bit entry of bzImage
        mov  ebx, 0x18;__BOOT_DS
        mov  ds,bx ;fails with mov ds, ebx
        mov  es,bx ;//
        mov  fs,bx ;//
        mov  gs,bx ;//
        mov  ss,bx ;//
        ;jmp  FAR $__BOOT_CS,$1f
        jmp  0x10:0x10f000222;out of range
l1: 
        ;/* tell kernel where is boot_param */
        mov  esi, 0x8000;(BOOT_PARAMS_OFFSET)
        xor ebp, ebp
        xor edi, edi
        mov ecx, eax
        mov eax, [ds:0x10f01784] ;mb_magic
        mov ebx, DWORD PTR ds:0x10f00022 ;mb_info

        ;jmpl ecx      ; Jump to the 32-bit entrypoint
        jmp ecx ;this should work???
    
Post 10 Dec 2018, 17:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16364
Location: Bricksburg
Code:
jmp  0x10:0x10f000222;out of range    
That value of 0x10f000222 requires 33 bits to encode, so fasm correctly reports it as out of range for 32 bit code.
Post 10 Dec 2018, 22:38
View user's profile Send private message Visit poster's website Reply with quote
dstyl



Joined: 23 Jul 2015
Posts: 61
Thanks a lot for your help, i will try "jmp 0x10:0x10f00022" in the worst case i will just paste the raw opcode from the working bootstub as hex into the binary. What still confuses me is that 2 disassemblers claim the instruction is invalid while oda says its correct and shows that out of range value.
Post 11 Dec 2018, 21:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.