VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/linux/Makefile-wrapper.gmk@ 88839

Last change on this file since 88839 was 87739, checked in by vboxsync, 4 years ago

SUP/Makefile-wrapper.gmk,iprt/asmdefs.mac: Call objtool on our .r0 object when ORCs are roaming freely accross our Linux kernel. Otherwise we won't get any callstacks. bugref:9937

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1# $Id: Makefile-wrapper.gmk 87739 2021-02-12 16:36:17Z vboxsync $
2## @file
3# Makefile template for a wrapper module.
4#
5
6#
7# Copyright (C) 2006-2020 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# The contents of this file may alternatively be used under the terms
18# of the Common Development and Distribution License Version 1.0
19# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20# VirtualBox OSE distribution, in which case the provisions of the
21# CDDL are applicable instead of those of the GPL.
22#
23# You may elect to license modified versions of this file under the
24# terms and conditions of either the GPL or the CDDL or both.
25#
26
27# Check template parameters.
28ifndef WRAPPED_MODULE_NAME
29$(error WRAPPED_MODULE_NAME not defined)
30endif
31ifndef VBOXMOD_NAME
32$(error VBOXMOD_NAME not defined)
33endif
34
35
36# Linux kbuild sets this to our source directory if we are called from there
37ifndef VBOX_MODULE_SRC_DIR
38 VBOX_MODULE_SRC_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))/
39endif
40VBOXDRV_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vboxdrv/)/
41VBOX_VMMR0_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vbox_vmmr0/)/
42include $(VBOXDRV_DIR)Makefile-header.gmk
43
44# All of these wrappers depend on
45ifndef KBUILD_EXTRA_SYMBOLS
46KBUILD_EXTRA_SYMBOLS := $(VBOXDRV_DIR)Module.symvers
47 ifdef WRAPPER_NEED_VMMR0
48KBUILD_EXTRA_SYMBOLS += $(VBOX_VMMR0_DIR)Module.symvers
49 endif
50endif
51
52VBOXMOD_OBJS = \
53 SUPWrapperMod-linux.o \
54 $(WRAPPED_MODULE_NAME).o
55
56VBOXMOD_INCL = \
57 $(VBOXDRV_DIR) \
58 $(VBOXDRV_DIR)include \
59 $(VBOXDRV_DIR)r0drv/linux
60
61VBOXMOD_DEFS += \
62 RT_OS_LINUX \
63 IN_RING0 \
64 IN_RT_R0 \
65 IN_SUP_R0 \
66 VBOX \
67 \
68 WRAPPED_MODULE_NAME=\"$(WRAPPED_MODULE_NAME).r0\" \
69 WRAPPED_MODULE_SYMBOL_INCLUDE=\"$(WRAPPED_MODULE_NAME)-symbols.h\"
70ifdef WRAPPED_MODULE_FLAGS
71VBOXMOD_DEFS += WRAPPED_MODULE_FLAGS="$(WRAPPED_MODULE_FLAGS)"
72endif
73ifdef WRAPPED_MODULE_LINUX_EXPORTS
74VBOXMOD_DEFS += WRAPPED_MODULE_LINUX_EXPORTS
75endif
76ifdef WRAPPED_MODULE_SRV_REQ_HANDLER
77VBOXMOD_DEFS += WRAPPED_MODULE_SRV_REQ_HANDLER="$(WRAPPED_MODULE_SRV_REQ_HANDLER)"
78endif
79ifdef WRAPPED_MODULE_IS_VMMR0
80VBOXMOD_DEFS += WRAPPED_MODULE_VMMR0_ENTRY_FAST=VMMR0EntryFast
81VBOXMOD_DEFS += WRAPPED_MODULE_VMMR0_ENTRY_EX=VMMR0EntryEx
82endif
83ifdef WRAPPED_MODULE_NO_INIT
84VBOXMOD_DEFS += WRAPPED_MODULE_INIT=NULL
85endif
86ifdef WRAPPED_MODULE_NO_TERM
87VBOXMOD_DEFS += WRAPPED_MODULE_TERM=NULL
88endif
89ifdef WRAPPED_MODULE_LICENSE_PROPRIETARY
90VBOXMOD_DEFS += WRAPPED_MODULE_LICENSE_PROPRIETARY
91endif
92
93VBOXMOD_CFLAGS = -include $(VBOXDRV_DIR)include/VBox/SUPDrvMangling.h \
94 -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement
95
96## @todo cleanup
97
98include $(VBOXDRV_DIR)Makefile-footer.gmk
99
100
101#
102# Custom rules (some of this could later be done before install).
103#
104SUPWrapperMod-linux.c \
105$(VBOX_MODULE_SRC_DIR)SUPWrapperMod-linux.c \
106$(VBOX_MODULE_SRC_DIR)SUPWrapperMod-linux.o \
107: $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h
108
109$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h: \
110 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).r0 \
111 $(VBOX_MODULE_SRC_DIR)Makefile-wrapper.gmk \
112 $(VBOX_MODULE_SRC_DIR)Makefile
113 rm -f -- "$@" "$@-tmp1" "$@-tmp2"
114 objdump --syms "$<" > "$@-tmp1"
115 sed -e '/[[:space:]].hidden[[:space:]]/d' \
116 -e '/[[:space:]]\*UND\*[[:space:]]/d' \
117 -e '/[[:space:]]vboxr0mod_/d' \
118 -e '/^[[:xdigit:]][[:xdigit:]]*[[:space:]][gu]/!d' \
119 -e 's/^\([[:xdigit:]]*\)[[:space:]].*000[[:xdigit:]]*[[:space:]]\([_a-zA-Z].*\)$$/SYMBOL_ENTRY(\2)/' \
120 -e '/SYMBOL_ENTRY(ModuleInit)/d' \
121 -e '/SYMBOL_ENTRY(ModuleTerm)/d' \
122 "$@-tmp1" > "$@-tmp2"
123 sort "$@-tmp2" > "$@"
124 rm -f -- "$@-tmp1" "$@-tmp2"
125
126
127$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).mangle-symbols: \
128 $(VBOXDRV_DIR)Module.symvers \
129 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h \
130 $(VBOX_MODULE_SRC_DIR)Makefile-wrapper.gmk \
131 $(VBOX_MODULE_SRC_DIR)Makefile
132 sed -e 's/SYMBOL_ENTRY(\([^)]*\))/\/\1 VBoxHost_\1\/d/' \
133 "$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME)-symbols.h" \
134 > "$@-ignore.sed"
135 sed -e '/[[:space:]]VBoxHost_/!d' \
136 -e 's/^0x[[:xdigit:]]*[[:space:]]VBoxHost_\([^[:space:]]*\)[[:space:]].*$$/\1 VBoxHost_\1/' \
137 -f "$@-ignore.sed" \
138 "$<" \
139 > "$@"
140
141$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).o: \
142 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).r0 \
143 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).debug \
144 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).mangle-symbols \
145 $(VBOX_MODULE_SRC_DIR)Makefile-wrapper.gmk \
146 $(VBOX_MODULE_SRC_DIR)Makefile \
147 $(if $(CONFIG_UNWINDER_ORC),$(objtool_dep),)
148 rm -f -- "$@" "$@-tmp"
149 eu-unstrip -o "$@-tmp" $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).r0 $(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).debug
150 objcopy --redefine-syms=$(VBOX_MODULE_SRC_DIR)$(WRAPPED_MODULE_NAME).mangle-symbols "$@-tmp" "$@"
151 rm -f -- "$@-tmp"
152ifdef CONFIG_UNWINDER_ORC # Must generate the ORC sections.
153 $(__objtool_obj) $(objtool_args) $@
154endif
155 touch $(VBOX_MODULE_SRC_DIR).$(WRAPPED_MODULE_NAME).o.cmd
156
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