make-rules/shared-macros.mk
branchs11-update
changeset 2910 f8b8cbc43356
parent 2855 576d5a7857b7
child 2994 3705b92dce6a
--- a/make-rules/shared-macros.mk	Fri Jan 17 12:16:54 2014 -0800
+++ b/make-rules/shared-macros.mk	Wed Jan 22 09:31:02 2014 -0800
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 PATH=/usr/bin:/usr/gnu/bin
@@ -653,6 +653,17 @@
 # use direct binding
 LD_B_DIRECT =		-Bdirect
 
+# use generic macro names for enabling/disabling ASLR
+ASLR_ENABLE = 		-z aslr=enable
+ASLR_DISABLE = 		-z aslr=disable
+ASLR_NOT_APPLICABLE = 	-z aslr=disable
+ASLR_MODE = 		$(ASLR_DISABLE)
+
+# by default, turn off Address Space Layout Randomization for ELF executables;
+# to explicitly enable ASLR, set ASLR_MODE = $(ASLR_ENABLE)
+# in that component's Makefile
+LD_Z_ASLR =		$(ASLR_MODE)
+
 #
 # More Solaris linker flags that we want to be sure that everyone gets.  This
 # is automatically added to the calling environment during the 'build' and
@@ -686,12 +697,17 @@
 		$(LD_MAP_PAGEALIGN) $(LD_B_DIRECT) $(LD_Z_IGNORE) \
 		$(LD_Z_STRIP_CLASS)
 
+# only used on executables
+LD_EXEC_OPTIONS = $(LD_Z_ASLR)
+
 # Environment variables and arguments passed into the build and install
 # environment(s).  These are the initial settings.
 COMPONENT_BUILD_ENV= \
-    LD_OPTIONS="$(LD_OPTIONS)"
+    LD_OPTIONS="$(LD_OPTIONS)" \
+    LD_EXEC_OPTIONS="$(LD_EXEC_OPTIONS)"
 COMPONENT_INSTALL_ENV= \
-    LD_OPTIONS="$(LD_OPTIONS)"
+    LD_OPTIONS="$(LD_OPTIONS)" \
+    LD_EXEC_OPTIONS="$(LD_EXEC_OPTIONS)"
 
 # Add any bit-specific settings
 COMPONENT_BUILD_ENV += $(COMPONENT_BUILD_ENV.$(BITS))