Wed, 30 Oct 2013 15:35:25 +0100
8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
Summary: Use 2-byte loads to load indexes from the byte code stream to avoid out of bounds reads.
Reviewed-by: coleenp, sspitsyn
1 #
2 # Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation.
8 #
9 # This code is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # version 2 for more details (a copy is included in the LICENSE file that
13 # accompanied this code).
14 #
15 # You should have received a copy of the GNU General Public License version
16 # 2 along with this work; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 #
19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 # or visit www.oracle.com if you need additional information or have any
21 # questions.
22 #
23 #
25 # The common definitions for hotspot builds.
27 # Optionally include SPEC file generated by configure.
28 ifneq ($(SPEC),)
29 include $(SPEC)
30 endif
32 # Directory paths and user name
33 # Unless GAMMADIR is set on the command line, search upward from
34 # the current directory for a parent directory containing "src/share/vm".
35 # If that fails, look for $GAMMADIR in the environment.
36 # When the tree of subdirs is built, this setting is stored in each flags.make.
37 GAMMADIR := $(shell until ([ -d dev ]&&echo $${GAMMADIR:-/GAMMADIR/}) || ([ -d src/share/vm ]&&pwd); do cd ..; done)
38 HS_SRC_DIR=$(GAMMADIR)/src
39 HS_MAKE_DIR=$(GAMMADIR)/make
40 HS_BUILD_DIR=$(GAMMADIR)/build
42 ifeq ($(USER),)
43 USER=$(USERNAME)
44 endif
46 ifeq ($(HS_ALT_MAKE),)
47 ifneq ($(OPENJDK),true)
48 HS_ALT_MAKE=$(GAMMADIR)/make/closed
49 else
50 HS_ALT_MAKE=NO_SUCH_PATH
51 endif
52 endif
54 #
55 # Include alternate defs.make if it exists
56 #
57 -include $(HS_ALT_MAKE)/defs.make
59 # Default to verbose build logs (show all compile lines):
60 MAKE_VERBOSE=y
62 # Make macros for install files or preparing targets
63 CD=cd
64 CP=cp
65 ECHO=echo
66 GREP=grep
67 MKDIR=mkdir
68 MV=mv
69 PWD=pwd
70 RM=rm -f
71 SED=sed
72 TAR=tar
73 ZIPEXE=zip
75 define install-file
76 @$(MKDIR) -p $(@D)
77 @$(RM) $@
78 $(CP) $< $@
79 endef
81 # MacOS X strongly discourages 'cp -r' and provides 'cp -R' instead.
82 # May need to have a MacOS X specific definition of install-dir
83 # sometime in the future.
84 define install-dir
85 @$(MKDIR) -p $(@D)
86 @$(RM) -r $@
87 $(CP) -r $< $@
88 endef
90 define prep-target
91 @$(MKDIR) -p $(@D)
92 @$(RM) $@
93 endef
95 # Default values for JVM_VARIANT* variables if configure hasn't set
96 # it already.
97 ifeq ($(JVM_VARIANTS),)
98 ifeq ($(ZERO_BUILD), true)
99 ifeq ($(SHARK_BUILD), true)
100 JVM_VARIANTS:=zeroshark
101 JVM_VARIANT_ZEROSHARK:=true
102 else
103 JVM_VARIANTS:=zero
104 JVM_VARIANT_ZERO:=true
105 endif
106 else
107 # A default is needed
108 ifeq ($(BUILD_CLIENT_ONLY), true)
109 JVM_VARIANTS:=client
110 JVM_VARIANT_CLIENT:=true
111 endif
112 # Further defaults are platform and arch specific
113 endif
114 endif
116 # hotspot version definitions
117 include $(GAMMADIR)/make/hotspot_version
119 # Java versions needed
120 ifeq ($(PREVIOUS_JDK_VERSION),)
121 PREVIOUS_JDK_VERSION=$(JDK_PREVIOUS_VERSION)
122 endif
123 ifeq ($(JDK_MAJOR_VERSION),)
124 JDK_MAJOR_VERSION=$(JDK_MAJOR_VER)
125 endif
126 ifeq ($(JDK_MINOR_VERSION),)
127 JDK_MINOR_VERSION=$(JDK_MINOR_VER)
128 endif
129 ifeq ($(JDK_MICRO_VERSION),)
130 JDK_MICRO_VERSION=$(JDK_MICRO_VER)
131 endif
132 ifeq ($(JDK_MKTG_VERSION),)
133 JDK_MKTG_VERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
134 endif
135 ifeq ($(JDK_VERSION),)
136 JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
137 endif
138 ifeq ($(FULL_VERSION),)
139 FULL_VERSION="$(JDK_VERSION)"
140 endif
142 # FULL_VERSION is only used to define JRE_RELEASE_VERSION which is used
143 # as JRE version in VM -Xinternalversion output.
144 ifndef JRE_RELEASE_VERSION
145 JRE_RELEASE_VERSION=$(FULL_VERSION)
146 endif
148 ifndef HOTSPOT_RELEASE_VERSION
149 HOTSPOT_RELEASE_VERSION=$(HS_MAJOR_VER).$(HS_MINOR_VER)-b$(HS_BUILD_NUMBER)
150 endif
152 ifdef HOTSPOT_BUILD_VERSION
153 # specified in command line
154 else
155 ifdef COOKED_BUILD_NUMBER
156 # JRE build
157 HOTSPOT_BUILD_VERSION=
158 else
159 ifdef USER_RELEASE_SUFFIX
160 HOTSPOT_BUILD_VERSION=internal-$(USER_RELEASE_SUFFIX)
161 else
162 HOTSPOT_BUILD_VERSION=internal
163 endif
164 endif
165 endif
167 # Windows should have OS predefined
168 ifeq ($(OS),)
169 OS := $(shell uname -s)
170 ifneq ($(findstring BSD,$(OS)),)
171 OS=bsd
172 endif
173 ifeq ($(OS), Darwin)
174 OS=bsd
175 endif
176 HOST := $(shell uname -n)
177 endif
179 # If not SunOS, not Linux and not BSD, assume Windows
180 ifneq ($(OS), Linux)
181 ifneq ($(OS), SunOS)
182 ifneq ($(OS), bsd)
183 OSNAME=windows
184 else
185 OSNAME=bsd
186 endif
187 else
188 OSNAME=solaris
189 endif
190 else
191 OSNAME=linux
192 endif
194 # Determinations of default make arguments and platform specific settings
195 MAKE_ARGS=
197 # ARCH_DATA_MODEL==64 is equivalent to LP64=1
198 ifeq ($(ARCH_DATA_MODEL), 64)
199 ifndef LP64
200 LP64 := 1
201 endif
202 endif
204 # Defaults set for product build
205 EXPORT_SUBDIR=
207 # Change default /java path if requested
208 ifneq ($(ALT_SLASH_JAVA),)
209 SLASH_JAVA=$(ALT_SLASH_JAVA)
210 endif
212 # Default OUTPUTDIR
213 OUTPUTDIR=$(HS_BUILD_DIR)/$(OSNAME)
214 ifneq ($(ALT_OUTPUTDIR),)
215 OUTPUTDIR=$(ALT_OUTPUTDIR)
216 endif
218 # Find latest promoted JDK area
219 JDK_IMPORT_PATH=$(SLASH_JAVA)/re/j2se/$(JDK_VERSION)/promoted/latest/binaries/$(PLATFORM)
220 ifneq ($(ALT_JDK_IMPORT_PATH),)
221 JDK_IMPORT_PATH=$(ALT_JDK_IMPORT_PATH)
222 endif
224 # Other parts of JDK build may require an import JDK that can be executed
225 # on the build host. For cross-compile builds we also need an import JDK
226 # that matches the target arch, so for that we set ALT_JDK_TARGET_IMPORT_PATH
227 ifneq ($(ALT_JDK_TARGET_IMPORT_PATH),)
228 JDK_IMPORT_PATH=$(ALT_JDK_TARGET_IMPORT_PATH)
229 endif
231 # Find JDK used for javac compiles
232 BOOTDIR=$(SLASH_JAVA)/re/j2se/$(PREVIOUS_JDK_VERSION)/latest/binaries/$(PLATFORM)
233 ifneq ($(ALT_BOOTDIR),)
234 BOOTDIR=$(ALT_BOOTDIR)
235 endif
237 # Select name of the export directory and honor ALT overrides
238 EXPORT_PATH=$(OUTPUTDIR)/export-$(PLATFORM)$(EXPORT_SUBDIR)
239 ifneq ($(ALT_EXPORT_PATH),)
240 EXPORT_PATH=$(ALT_EXPORT_PATH)
241 endif
243 # Default jdk image if one is created for you with create_jdk
244 JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM)
245 ifneq ($(ALT_JDK_IMAGE_DIR),)
246 JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR)
247 endif
249 # The platform dependent defs.make defines platform specific variable such
250 # as ARCH, EXPORT_LIST etc. We must place the include here after BOOTDIR is defined.
251 include $(GAMMADIR)/make/$(OSNAME)/makefiles/defs.make
253 # We are trying to put platform specific defintions
254 # files to make/$(OSNAME)/makefiles dictory. However
255 # some definitions are common for both linux and solaris,
256 # so we put them here.
257 ifneq ($(OSNAME),windows)
258 ABS_OUTPUTDIR := $(shell mkdir -p $(OUTPUTDIR); $(CD) $(OUTPUTDIR); $(PWD))
259 ABS_BOOTDIR := $(shell $(CD) $(BOOTDIR); $(PWD))
260 ABS_GAMMADIR := $(shell $(CD) $(GAMMADIR); $(PWD))
261 ABS_OS_MAKEFILE := $(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME); $(PWD))/Makefile
263 # uname, HotSpot source directory, build directory and JDK use different names
264 # for CPU architectures.
265 # ARCH - uname output
266 # SRCARCH - where to find HotSpot cpu and os_cpu source files
267 # BUILDARCH - build directory
268 # LIBARCH - directory name in JDK/JRE
270 # Use uname output for SRCARCH, but deal with platform differences. If ARCH
271 # is not explicitly listed below, it is treated as x86.
272 SRCARCH = $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 arm ppc zero,$(ARCH)))
273 ARCH/ = x86
274 ARCH/sparc = sparc
275 ARCH/sparc64= sparc
276 ARCH/ia64 = ia64
277 ARCH/amd64 = x86
278 ARCH/x86_64 = x86
279 ARCH/ppc64 = ppc
280 ARCH/ppc = ppc
281 ARCH/arm = arm
282 ARCH/zero = zero
284 # BUILDARCH is usually the same as SRCARCH, except for sparcv9
285 BUILDARCH = $(SRCARCH)
286 ifeq ($(BUILDARCH), x86)
287 ifdef LP64
288 BUILDARCH = amd64
289 else
290 BUILDARCH = i486
291 endif
292 endif
293 ifeq ($(BUILDARCH), sparc)
294 ifdef LP64
295 BUILDARCH = sparcv9
296 endif
297 endif
299 # LIBARCH is 1:1 mapping from BUILDARCH
300 LIBARCH = $(LIBARCH/$(BUILDARCH))
301 LIBARCH/i486 = i386
302 LIBARCH/amd64 = amd64
303 LIBARCH/sparc = sparc
304 LIBARCH/sparcv9 = sparcv9
305 LIBARCH/ia64 = ia64
306 LIBARCH/ppc64 = ppc
307 LIBARCH/ppc = ppc
308 LIBARCH/arm = arm
309 LIBARCH/zero = $(ZERO_LIBARCH)
311 LP64_ARCH = sparcv9 amd64 ia64 zero
312 endif
314 # Required make macro settings for all platforms
315 MAKE_ARGS += BOOTDIR=$(ABS_BOOTDIR)
316 MAKE_ARGS += OUTPUTDIR=$(ABS_OUTPUTDIR)
317 MAKE_ARGS += GAMMADIR=$(ABS_GAMMADIR)
318 MAKE_ARGS += MAKE_VERBOSE=$(MAKE_VERBOSE)
319 MAKE_ARGS += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION)
320 MAKE_ARGS += JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
322 # Pass HOTSPOT_BUILD_VERSION as argument to OS specific Makefile
323 # to overwrite the default definition since OS specific Makefile also
324 # includes this make/defs.make file.
325 MAKE_ARGS += HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION)
327 # Various export sub directories
328 EXPORT_INCLUDE_DIR = $(EXPORT_PATH)/include
329 EXPORT_DOCS_DIR = $(EXPORT_PATH)/docs
330 EXPORT_LIB_DIR = $(EXPORT_PATH)/lib
331 EXPORT_JRE_DIR = $(EXPORT_PATH)/jre
332 EXPORT_JRE_BIN_DIR = $(EXPORT_JRE_DIR)/bin
333 EXPORT_JRE_LIB_DIR = $(EXPORT_JRE_DIR)/lib
334 EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)/$(LIBARCH)
336 # non-universal macosx builds need to appear universal
337 ifeq ($(OS_VENDOR), Darwin)
338 ifneq ($(MACOSX_UNIVERSAL), true)
339 EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)
340 endif
341 endif
343 # Common export list of files
344 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmti.h
345 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmticmlr.h
346 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h
347 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h
348 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h
350 .PHONY: $(HS_ALT_MAKE)/defs.make