VirtualBox

source: vbox/trunk/include/iprt/solaris/kmoddeps.mac@ 102126

Last change on this file since 102126 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1; $Id: kmoddeps.mac 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; Assembly macros for generating Solaris kernel module dependencies
4;
5
6;
7; Copyright (C) 2012-2023 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37; Solaris kernel modules use non-standard ELF constructions to express inter-
38; module dependencies, namely a DT_NEEDED tag inside a relocatable ELF file.
39; The Solaris linker can generate these automatically; since yasm can't
40; produce an ELF file which quite fits Solaris's requirements we create one
41; manually using flat binary output format. In order to save unnecessary
42; repetition, this file defines macros for the repetitive bits which can be
43; reused by the actual dependency objects. Certainly not the nicest way to
44; get the effect we want, but probably a reasonable compromise between
45; cleanness and required effort.
46;
47
48%ifdef RT_ARCH_AMD64
49
50BITS 64
51;;
52; Native word size
53%define DNAT dq
54
55;;
56; ELF machine number for the current architecture.
57%define EM_CUR 62 ; EM_X86_64
58
59;;
60; ELF header class for the current architecture.
61%define CLASS 2
62
63%else
64
65BITS 32
66%define DNAT dd
67%define EM_CUR 3 ; EM_386
68%define CLASS 1
69
70%endif
71
72;;
73; ELF file header, section tables and shared string table for the dependency
74; object.
75%macro kmoddeps_header 0
76elf_hdr: ; elfxx_hdr structure
77 db 7fh, "ELF" ; e_ident
78 db CLASS, 1, 1 ; e_ident
79 times 9 db 0 ; padding
80 dw 1 ; e_type ET_REL
81 dw EM_CUR ; e_machine
82 dd 1 ; e_version EV_CURRENT
83 DNAT 0 ; e_entry
84 DNAT 0 ; e_phoff
85 DNAT sect_hdr - $$ ; e_shoff
86 dd 0 ; e_flags
87 dw elf_hsize ; e_ehsize
88 dw 0 ; e_phentsize
89 dw 0 ; e_phnum
90 dw sect_hsize ; e_shentsize
91 dw 4 ; e_shnum
92 dw 1 ; e_shstrndx section .shstrtab
93elf_hsize equ $ - elf_hdr
94
95sect_hdr: ; elfxx_shdr structure
96 times sect_hsize db 0 ; undefined section
97
98sect_hdr1:
99 dd str_shstrtab ; sh_name .shstrtab
100 dd 3 ; sh_type SHT_STRTAB
101 DNAT 20h ; sh_flags SHF_STRINGS
102 DNAT 0 ; sh_addr
103 DNAT shstrtab - $$ ; sh_offset
104 DNAT shstrtab_size ; sh_size
105 dd 0 ; sh_link
106 dd 0 ; sh_info
107 DNAT 1 ; sh_addralign
108 DNAT 0 ; sh_entsize
109sect_hsize equ $ - sect_hdr1
110
111 dd str_dynstr ; sh_name .dynstr
112 dd 3 ; sh_type SHT_STRTAB
113 DNAT 20h ; sh_flags SHF_STRINGS
114 DNAT 0 ; sh_addr
115 DNAT dynstr - $$ ; sh_offset
116 DNAT dynstr_size ; sh_size
117 dd 0 ; sh_link
118 dd 0 ; sh_info
119 DNAT 1 ; sh_addralign
120 DNAT 0 ; sh_entsize
121
122 dd str_dynamic ; sh_name .dynamic
123 dd 6 ; sh_type SHT_DYNAMIC
124 DNAT 1 ; sh_flags SHF_WRITE
125 DNAT 0 ; sh_addr
126 DNAT dynamic - $$ ; sh_offset
127 DNAT dynamic_size ; sh_size
128 dd 2 ; sh_link .dynstr
129 dd 0 ; sh_info
130 DNAT 8 ; sh_addralign
131 DNAT 0 ; sh_entsize
132
133shstrtab:
134str_shstrtab equ $ - shstrtab
135 db ".shstrtab", 0
136str_dynstr equ $ - shstrtab
137 db ".dynstr", 0
138str_dynamic equ $ - shstrtab
139 db ".dynamic", 0
140shstrtab_size equ $ - shstrtab
141%endmacro ; kmoddeps_header
142
143;;
144; Start of the .dynstr section for the dependency object.
145%macro kmoddeps_dynstr_start 0
146dynstr:
147 db 0
148%endmacro
149
150;;
151; A .dynstr string entry for the dependency object.
152; The parameters are a symbolic name for the string and the string itself.
153%macro kmoddeps_dynstr_string 2
154dynstr_name_%1 equ $ - dynstr
155 db %2, 0
156%endmacro
157
158;;
159; End of the .dynstr section for the dependency object.
160%macro kmoddeps_dynstr_end 0
161dynstr_size equ $ - dynstr
162%endmacro
163
164;;
165; Start of the .dynamic section for the dependency object.
166%macro kmoddeps_dynamic_start 0
167dynamic:
168%endmacro
169
170;;
171; A .dynamic DT_NEEDED entry for the dependency object.
172; The parameter is a symbolic string name previously defined using
173; @a kmoddeps_dynstr_string.
174%macro kmoddeps_dynamic_needed 1
175 DNAT 1 ; DT_NEEDED
176 DNAT dynstr_name_%1
177%endmacro
178
179;;
180; End of the .dynamic section for the dependency object.
181%macro kmoddeps_dynamic_end 0
182 DNAT 1ah ; DT_FLAGS
183 DNAT 4 ; TEXTREL
184 DNAT 6ffffffbh ; DT_FLAGS1
185 DNAT 0
186 DNAT 601900h ; SUNW_STRPAD
187 DNAT 200h
188 DNAT 601b00h ; SUNW_LDMACH
189 DNAT 62 ; EM_X86_64
190 times 22 DNAT 0 ; padding
191dynamic_size equ $ - dynamic
192%endmacro ; kmoddeps_dynamic_end
193
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette