kmoddeps.mac revision 7473cac51fff527528e0a5b8768488ccc9acfee4
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Assembly macros for generating Solaris kernel module dependencies
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Copyright (C) 2012 Oracle Corporation
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; available from http://www.virtualbox.org. This file is free software;
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; you can redistribute it and/or modify it under the terms of the GNU
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; General Public License (GPL) as published by the Free Software
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Solaris kernel modules use non-standard ELF constructions to express inter-
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; module dependencies, namely a DT_NEEDED tag inside a relocatable ELF file.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; The Solaris linker can generate these automatically; since yasm can't
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; produce an ELF file which quite fits Solaris's requirements we create one
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; manually using flat binary output format. In order to save unnecessary
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; repetition, this file defines macros for the repetitive bits which can be
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; reused by the actual dependency objects. Certainly not the nicest way to
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; get the effect we want, but probably a reasonable compromise between
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; cleanness and required effort.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%ifdef RT_ARCH_AMD64
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Native word size
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%define DNAT dq
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; ELF machine number for the current architecture.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%define EM_CUR 62 ; EM_X86_64
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; ELF header class for the current architecture.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%define CLASS 2
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%define DNAT dd
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%define EM_CUR 3 ; EM_386
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%define CLASS 1
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; ELF file header, section tables and shared string table for the dependency
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_header 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncelf_hdr: ; elfxx_hdr structure
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync db 7fh, "ELF" ; e_ident
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync db CLASS, 1, 1 ; e_ident
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync times 9 db 0 ; padding
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw 1 ; e_type ET_REL
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw EM_CUR ; e_machine
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 1 ; e_version EV_CURRENT
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; e_entry
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; e_phoff
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT sect_hdr - $$ ; e_shoff
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 0 ; e_flags
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw elf_hsize ; e_ehsize
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw 0 ; e_phentsize
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw 0 ; e_phnum
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw sect_hsize ; e_shentsize
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw 4 ; e_shnum
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dw 1 ; e_shstrndx section .shstrtab
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncelf_hsize equ $ - elf_hdr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncsect_hdr: ; elfxx_shdr structure
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync times sect_hsize db 0 ; undefined section
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd str_shstrtab ; sh_name .shstrtab
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 3 ; sh_type SHT_STRTAB
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 20h ; sh_flags SHF_STRINGS
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; sh_addr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT shstrtab - $$ ; sh_offset
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT shstrtab_size ; sh_size
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 0 ; sh_link
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 0 ; sh_info
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 1 ; sh_addralign
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; sh_entsize
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncsect_hsize equ $ - sect_hdr1
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd str_dynstr ; sh_name .dynstr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 3 ; sh_type SHT_STRTAB
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 20h ; sh_flags SHF_STRINGS
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; sh_addr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT dynstr - $$ ; sh_offset
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT dynstr_size ; sh_size
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 0 ; sh_link
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 0 ; sh_info
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 1 ; sh_addralign
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; sh_entsize
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd str_dynamic ; sh_name .dynamic
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 6 ; sh_type SHT_DYNAMIC
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 1 ; sh_flags SHF_WRITE
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; sh_addr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT dynamic - $$ ; sh_offset
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT dynamic_size ; sh_size
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 2 ; sh_link .dynstr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync dd 0 ; sh_info
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 8 ; sh_addralign
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 0 ; sh_entsize
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncstr_shstrtab equ $ - shstrtab
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync db ".shstrtab", 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncstr_dynstr equ $ - shstrtab
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync db ".dynstr", 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncstr_dynamic equ $ - shstrtab
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync db ".dynamic", 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncshstrtab_size equ $ - shstrtab
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%endmacro ; kmoddeps_header
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Start of the .dynstr section for the dependency object.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_dynstr_start 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; A .dynstr string entry for the dependency object.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; The parameters are a symbolic name for the string and the string itself.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_dynstr_string 2
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncdynstr_name_%1 equ $ - dynstr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; End of the .dynstr section for the dependency object.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_dynstr_end 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncdynstr_size equ $ - dynstr
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; Start of the .dynamic section for the dependency object.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_dynamic_start 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; A .dynamic DT_NEEDED entry for the dependency object.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; The parameter is a symbolic string name previously defined using
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; @a kmoddeps_dynstr_string.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_dynamic_needed 1
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 1 ; DT_NEEDED
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT dynstr_name_%1
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync; End of the .dynamic section for the dependency object.
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%macro kmoddeps_dynamic_end 0
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 1ah ; DT_FLAGS
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 4 ; TEXTREL
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 6ffffffbh ; DT_FLAGS1
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 601900h ; SUNW_STRPAD
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 601b00h ; SUNW_LDMACH
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync DNAT 62 ; EM_X86_64
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync times 22 DNAT 0 ; padding
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsyncdynamic_size equ $ - dynamic
7473cac51fff527528e0a5b8768488ccc9acfee4vboxsync%endmacro ; kmoddeps_dynamic_end