#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2019 Peter Tribble.
#

# This file provides exceptions to the usual rules applied to ELF objects by
# check_rtime. All strings are Perl regular expressions that are compared to
# file paths. In addition to the standard Perl syntax, there is one extension:
#
#	MACH(dir)
#
# is expanded into a regular expression that matches the given
# directory, or a 64-bit subdirectory of the directory with the
# name of a 64-bit architecture. For example, MACH(lib) will match
# any of the following:
#
#	lib
#	lib/amd64
#	lib/sparcv9


# Directory hierarchies to skip completely
SKIP		^usr/lib/libc/			# optimized libc
SKIP		^usr/lib/rcm/			# 4426119
SKIP		^usr/perl5/			# alan's taking care of these :-)
SKIP		^usr/src/			# no objects in source code

# Individual files that we don't examine
SKIP		^boot/grub/bin/grub$
# USIII specific extns. cause ldd noise on USII bld. m/c
SKIP		^usr/lib/fps/sun4u/UltraSPARC.*/fptest$
SKIP		^usr/MACH(lib)/lddstub$		# lddstub has no dependencies
SKIP		^usr/MACH(lib)/libssagent\.so\.1$	# 4328854
SKIP		^usr/lib/MACH(iconv)/geniconvtbl.so$	# 4384329

# picl file exclusions (4385799)
SKIP		^usr/platform/.*/libpsvcplugin_psr\.so\.1
SKIP		^usr/platform/.*/libpsvcpolicy_psr\.so\.1
SKIP		^usr/platform/.*/libpsvcpolicy\.so\.1
SKIP		^usr/lib/sysevent/modules/picl_slm.so$

# Objects that are allowed to have executable data segments
EXEC_DATA	^MACH(lib)/ld\.so\.1$
EXEC_DATA	^lib/libc\.so\.1$	# 6524709, 32-bit, needed for x86 only
EXEC_DATA	^MACH(lib)/libumem\.so\.1$ # ptcumem
EXEC_DATA	^opt/SUNWdtrt/tst/.*/ustack/tst\.helper\.exe$
EXEC_DATA	^platform/.*/MACH(kernel)/unix$

# Objects that are allowed to have an executable stack
EXEC_STACK	^platform/.*/MACH(kernel)/unix$
EXEC_STACK	^platform/.*/multiboot$
EXEC_STACK	^opt/os-tests/tests/secflags/stacky$

# Objects for which we allow relocations to the text segment
TEXTREL		^platform/.*/MACH(kernel)/unix$

# Directories and files that are allowed to have no direct bound symbols
NODIRECT	^platform/.*/MACH(kernel)/unix$
NODIRECT	^usr/ucb
NODIRECT	^usr/4lib/sbcp$

# Identify any files that should be skipped when building a crle(1)
# configuration file.  As the hwcap libraries can be loop-back mounted onto
# libc, these can confuse crle(1) because of their identical dev/inode.
NOCRLEALT	^usr/lib/libc/libc_hwcap[1-3].so.1$

# Files that should contain debugging information.
STAB	^platform/.*/MACH(kernel)/unix$

# Files that are allowed undefined references
UNDEF_REF	^usr/lib/libnisdb\.so\.2$

# Objects allowed to have unused dependencies
UNUSED_DEPS	^usr/lib/picl/plugins/		# require devtree dependencies

# libnetsnmphelpers.so is empty in some net-snmp versions
UNUSED_OBJ	unused object=.*/libnetsnmphelpers\.so\..*
UNREF_OBJ	unreferenced object=.*/libnetsnmphelpers\.so\..*

# Unused runpaths due to dlopen() use
UNUSED_RPATH	/usr/lib/fs/autofs.*\ from\ .automountd
UNUSED_RPATH	/etc/ppp/plugins.*\ from\ .*pppd
UNUSED_RPATH	/usr/lib/inet/ppp.*\ from\ .*pppd
UNUSED_RPATH	/usr/platform/.*rsmlib.*\ from\ .*librsm\.so\.2
UNUSED_RPATH	\$ORIGIN.*\ from\ .*fcode.so
UNUSED_RPATH	/opt/VRTSvxvm/lib.*\ from\ .*libdiskmgt\.so\.1

# Unused runpaths in picl code
UNUSED_RPATH	/usr/platform/.*\ from\ .*/usr/platform
UNUSED_RPATH	/usr/lib/picl/.*\ from\ .*/usr/platform
UNUSED_RPATH	/usr/platform/.*\ from\ .*/usr/lib/picl

# Unused runpaths in non-OSNET objects we can't change
UNUSED_RPATH	/usr/lib/mps.*\ from\ .*libnss3\.so
UNUSED_RPATH	/usr/lib/mps.*\ from\ .*libnssutil3\.so
UNUSED_RPATH	/usr/lib/mps.*\ from\ .*libsmime3\.so
UNUSED_RPATH	/usr/lib/mps.*\ from\ .*libssl3\.so
UNUSED_RPATH	/usr/lib.*\ from\ .*/usr/lib/mps
UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/libpython2\..
UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/64/libpython2\..
UNUSED_RPATH	/usr/gnu/lib.*\ from\ .*/usr/lib/64/libpython3\..
UNUSED_RPATH	/usr/snadm/lib.*\ from\ .*/usr/snadm/lib/libspmicommon\.so\.1
UNUSED_RPATH	/usr/gcc/.*/lib.*\ from\ .*

# Unused runpaths for reasons not captured above
UNUSED_RPATH	/usr/lib/smbsrv.*\ from\ .*libsmb\.so\.1	# future needs

# Unreferenced objects of non-OSnet objects we can't change
UNREF_OBJ	/lib.*\ of\ .*libcimapi\.so
UNREF_OBJ	/lib.*\ of\ .*libdbus-1\.so\.3
UNREF_OBJ	/lib.*\ of\ .*libdbus-glib-1\.so\.2
UNREF_OBJ	/lib.*\ of\ .*libgio-2.0\.so\.0
UNREF_OBJ	/lib.*\ of\ .*libglib-2.0\.so\.0
UNREF_OBJ	/lib.*\ of\ .*libgobject-2.0\.so\.0
UNREF_OBJ	/lib.*\ of\ .*libgthread-2\.0\.so\.0
UNREF_OBJ	/lib.*\ of\ .*libjvm\.so
UNREF_OBJ	/lib.*\ of\ .*libnetsnmp\.so\..*
UNREF_OBJ	/lib.*\ of\ .*libnetsnmpagent\.so\..*
UNREF_OBJ	/lib.*\ of\ .*libnetsnmpmibs\.so\..*
UNREF_OBJ	/lib.*\ of\ .*libnetsnmphelpers\.so\..*
UNREF_OBJ	/lib.*\ of\ .*libnspr4\.so
UNREF_OBJ	/lib.*\ of\ .*libpq\.so\.5
UNREF_OBJ	/lib.*\ of\ .*libsoftokn3\.so
UNREF_OBJ	/lib.*\ of\ .*libspmicommon\.so\.1
UNREF_OBJ	/lib.*\ of\ .*libspmocommon\.so\.1
UNREF_OBJ	/lib.*\ of\ .*libssl3\.so
UNREF_OBJ	/lib.*\ of\ .*libtspi\.so\.1
UNREF_OBJ	/lib.*\ of\ .*libxml2\.so\.2
UNREF_OBJ	/lib.*\ of\ .*libxslt\.so\.1
UNREF_OBJ	/lib.*\ of\ .*libpq\.so\.4
UNREF_OBJ	/lib.*\ of\ .*libpython2\.4\.so\.1\.0
UNREF_OBJ	/lib.*\ of\ .*libpython2\.6\.so\.1\.0
UNREF_OBJ	/lib.*\ of\ .*libpython2\.7\.so\.1\.0
UNREF_OBJ	/lib.*\ of\ .*libpython3\.[5678]m?\.so\.1\.0
UNREF_OBJ	/libgcc_s.*\ of\ .*libstdc\+\+\.so\.6
UNREF_OBJ	/libgcc_s.*\ of\ .*libgmodule-2\.0\.so\.0

# Unreferenced object of objects we can't change for other reasons
UNREF_OBJ	/libmapmalloc\.so\.1;\ unused\ dependency\ of	# interposer
UNREF_OBJ	/libstdc\+\+\.so\.6;\ unused\ dependency\ of	# gcc build
UNREF_OBJ	/libgcc_s\.so\.1;\ unused\ dependency\ of	# gcc build
UNREF_OBJ	/libgcc_s\.so\.1.*\ of\ .*libstdc\+\+\.so\.6	# omnios gcc mix
UNREF_OBJ	/libm\.so\.2.*\ of\ .*libstdc\+\+\.so\.6	# gcc build
UNREF_OBJ	/lib.*\ of\ .*/lib/picl/plugins/		# picl
UNREF_OBJ	/lib.*\ of\ .*kcfd				# interposer
UNREF_OBJ	/libpkcs11\.so\.1; .*\ of\ .*libkmf\.so\.1	# interposed
# Referenced by the Studio build, not the GCC build.  GCC eliminates the unused
# statics which have the dependence.
UNREF_OBJ	/libc\.so\.1.*\ of\ .*kldap\.so\.1


# Objects that used to contain system functionalty that has since
# migrated to libc. We preserve these libraries as pure filters for
# backward compatability but nothing needs to link to them.
OLDDEP		libaio\.so\.1			# onnv build 44
OLDDEP		libdl\.so\.1			# on10 build 49
OLDDEP		libdoor\.so\.1			# onnv build 12
OLDDEP		libintl\.so\.1			# on297 build 7
OLDDEP		libpthread\.so\.1		# on10 build 53
OLDDEP		librt\.so\.1			# onnv build 44
OLDDEP		libsched\.so\.1			# on10 build 36
OLDDEP		libthread\.so\.1		# on10 build 53
OLDDEP		libw\.so\.1			# on297 build 7

# Files for which we skip checking of duplicate addresses in the
# symbol sort sections. Such exceptions should be rare --- most code will
# not have duplicate addresses, since it takes assember or a "#pragma weak"
# to do such aliasing in C. C++ is different: The compiler generates aliases
# for implementation reasons, and the mangled names used to encode argument
# and return value types are difficult to handle well in mapfiles.
# Furthermore, the Sun compiler and gcc use different and incompatible
# name mangling conventions. Since illumos must be buildable by either, we
# would have to maintain two sets of mapfiles for each such object.
# C++ use is rare in illumos, so this is not worth pursuing.
#
NOSYMSORT	opt/SUNWdtrt/tst/common/pid/tst.weak2.exe	# DTrace test
NOSYMSORT	ld\.so\.1					# libc_pic.a user
NOSYMSORT	usr/bin/audioconvert				# C++
NOSYMSORT	usr/bin/make					# C++
NOSYMSORT	usr/MACH(lib)/libsun_fc\.so\.1			# C++
NOSYMSORT	usr/MACH(lib)/libfru\.so\.1			# C++
NOSYMSORT	usr/lib/libnisdb\.so\.2				# C++

# The majority of illumos deliverables should not depend on the GCC runtime
# (any necessary runtime symbol should be provided by libc.so, instead).
# However, the GNU C++ runtime requires the GCC runtime, so certain objects
# must be excepted.
FORBIDDEN	libgcc_s\.so
FORBIDDEN_DEP	usr/bin/audioconvert            # C++
FORBIDDEN_DEP   usr/bin/make                    # C++
FORBIDDEN_DEP   usr/MACH(lib)/libfru.so.1       # C++
FORBIDDEN_DEP   usr/MACH(lib)/libsun_fc.so.1    # C++
FORBIDDEN_DEP   usr/lib/netsvc/yp/rpc.yppasswdd # C++
FORBIDDEN_DEP   usr/lib/netsvc/yp/ypserv        # C++
FORBIDDEN_DEP   usr/lib/netsvc/yp/ypxfr         # C++
FORBIDDEN_DEP   usr/lib/netsvc/yp/ypxfrd        # C++

# libfakekernel is a test environment, not intended for general use
FORBIDDEN libfakekernel\.so
FORBIDDEN_DEP usr/MACH(lib)/libzpool.so.1
FORBIDDEN_DEP usr/bin/amd64/ztest
FORBIDDEN_DEP usr/bin/i86/ztest
FORBIDDEN_DEP usr/bin/sparcv7/ztest
FORBIDDEN_DEP usr/bin/sparcv9/ztest
FORBIDDEN_DEP usr/lib/MACH(smbfs)/libfknsmb.so.1
FORBIDDEN_DEP usr/lib/MACH(smbfs)/libfksmbfs.so.1
FORBIDDEN_DEP usr/lib/MACH(smbsrv)/libfksmbsrv.so.1
FORBIDDEN_DEP usr/lib/smbsrv/fksmbd
FORBIDDEN_DEP usr/lib/smbsrv/test-msgbuf
FORBIDDEN_DEP usr/lib/smbsrv/testoplock
FORBIDDEN_DEP usr/sbin/amd64/zdb
FORBIDDEN_DEP usr/sbin/i86/zdb
FORBIDDEN_DEP usr/sbin/sparcv7/zdb
FORBIDDEN_DEP usr/sbin/sparcv9/zdb

# libucb is intended for legacy compatibility, not general use
FORBIDDEN libucb\.so
FORBIDDEN_DEP usr/ucb/
FORBIDDEN_DEP usr/ucblib/

# Older versions of libraries only provided for binary compatibility
FORBIDDEN libm\.so\.1
FORBIDDEN libresolv\.so\.1
FORBIDDEN libxcurses\.so\.1

#
# the SUNWonld directory contains built versions of demos, built only to
# ensure their correctness.
#
EXEC_STACK	^opt/SUNWonld
EXEC_DATA	^opt/SUNWonld
NODIRECT	^opt/SUNWonld