flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Not correctly initializes structure "Elf64_Rela".

Author
Thread Post new topic Reply to topic
ofCros



Joined: 20 Jan 2008
Posts: 1
ofCros
Fasm not correctly initializes in structure "Elf64_Rela".
FreeBSD7_amd64.
fasm - 1.67.26

typedef struct {
Elf64_Addr r_offset;
Elf64_Xword r_info;
Elf64_Sxword r_addend; <--Does not initialize.
} Elf64_Rela;

Code:
;Dynamic Kernel Linker Facility - KLD.
;http://www.freebsd.org.ua/doc/ru_RU.KOI8-R/books/arch-handbook/driverbasics-kld.html
;KLD driver "Skelet" for FreeBSD_amd64.
;++++++++++++++++++++++++++++++++++++++++++++
format ELF64                                   ;+
section '.text' executable              ;+
;===========================
  extrn uprintf
  extrn module_register_init
;===========================               ;+
;++++++++++++++++++++++++++++++++++++++++++++

Start:
   push rbp ;
   test esi,esi
   mov rbp,rsp
    jnz NextZapros
   
   mov rdi,MesLoad ;1-----LINK "00h"
NextEnter:
    xor eax,eax ;? 
   call uprintf ;2-----LINK "fffffffffffffffch"
 ;=============
 
     xor eax,eax
     ;^^^^^^^^^^^

ExitModul:
   leave
   ret      
;----------------------------

NextZapros:
    dec esi
    mov eax,16h
    jnz ExitModul

    mov rdi,MesUnload ;3-----LINK "13h" 
    jmp NextEnter

db (10h-(($-Start)and 0Fh))and 0Fh dup (0CCh)
          
;**************************START*****************************
;>>>>>>>>>>>>>>>>>>>>>>.rodata.str1.1<<<<<<<<<<<<<<<<<<<<<<<*
;**************************START*****************************
section '.rodata.str1.1'
rodata_start:
;+++++++++++++++++++++++++++



MesLoad db 'Skelet KLD loaded',0Ah,0 ;Skelet KLD load
MesUnload db 'Skelet KLD unloaded',0Ah,0 ;13h
NameModul db 'SKELET',0 ; 28h 


db (10h-(($-rodata_start)and 0Fh))and 0Fh dup ('?')
;################################END################################
;;>>>>>>>>>>>>>>>>>>>>>>>>>.rodata.str1.1<<<<<<<<<<<<<<<<<<<<<<<<<<#
;################################END################################
section '.data' writeable

  SKELETmodule_sys_init   dd 02000000h  ;SI_SUB_KLD  
                          dd 0FFFFFFFh  ;SI_ORDER_ANY 
                          dq module_register_init  ;4----LINK "0"
                          dq moduledata_SKELET  ;5----LINK  "30h"

  
  _mod_metadata_md_SKELET   dd 00000001h ;
                            dd 00000002h ;
                            dq moduledata_SKELET  ;6----LINK 30h
                            dq NameModul  ;7----LINK "28h"


  moduledata_SKELET dq NameModul  ;8----LINK "28h"
                    dq Start ;   ;9----LINK "0"
                    dq 0 ;Null
               
                    dq 0

;#####################################################################

section 'set_sysinit_set'
  __set_sysinit_set_sym_SKELETmodule_sys_init  dq SKELETmodule_sys_init

section 'set_modmetadata_set'
  __set_modmetadata_set_sym__mod_metadata_md_SKELET dq _mod_metadata_md_SKELET

;Fix address for driver works.

;1--LINK qword [120h]=0
;2---LINK qword [138h]=fffffffffffffffch
;3----LINK qword [150h]=13h 
;4-----LINK qword [168h]=0 
;5------LINK qword [180h]=30h
;6-------LINK qword  [198h]=30h
;7--------LINK qword  [1B0h]=28h
;8---------LINK qword  [1C8h]=28h
;9----------LINK qword  [1E0h]=0
;10----------LINK qword  [1F8h]=0
;11-----------LINK qword  [210h]=18h    
Post 04 Feb 2008, 00:20
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Moved from Unix to Compiler Internals
Post 04 Feb 2008, 15:25
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.