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