17c478bd9Sstevel@tonic-gate# 27c478bd9Sstevel@tonic-gate# CDDL HEADER START 37c478bd9Sstevel@tonic-gate# 47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 5*5aefb655Srie# Common Development and Distribution License (the "License"). 6*5aefb655Srie# You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate# 87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate# and limitations under the License. 127c478bd9Sstevel@tonic-gate# 137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate# 197c478bd9Sstevel@tonic-gate# CDDL HEADER END 207c478bd9Sstevel@tonic-gate# 21*5aefb655Srie 227c478bd9Sstevel@tonic-gate# 23*5aefb655Srie# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate# 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate################################################################################ 317c478bd9Sstevel@tonic-gate# 327c478bd9Sstevel@tonic-gate# Linting the Linker Libraries 337c478bd9Sstevel@tonic-gate# 34*5aefb655Srie# Several of the linker's libraries are, in whole or in part, built in two 35*5aefb655Srie# passes, once as Elf32 and once as Elf64 (i.e. with -D_ELF64 defined). Lint 36*5aefb655Srie# needs to be able to do both passes, but combining the two is problematic for 37*5aefb655Srie# the 2nd pass of lint, as it sees many interfaces as being defined both ways 38*5aefb655Srie# and considers them to be incompatible. The targets defined here allow for 39*5aefb655Srie# both passes to live independently. This means that both the lint.out, and 40*5aefb655Srie# the lint library itself get generated separately, to different output files. 41*5aefb655Srie# The lint.out's get combined into a single lint.out report, and the lint 42*5aefb655Srie# libraries get generated with a 32/64 suffix. The dependents on these lint 43*5aefb655Srie# libraries, then, choose which version they need to use. Substitutions can 44*5aefb655Srie# be made automatically if the macro's defined in ./Makefile.com are used to 45*5aefb655Srie# specify the dependency, for those libs that need them. 467c478bd9Sstevel@tonic-gate# 477c478bd9Sstevel@tonic-gate# Don't 487c478bd9Sstevel@tonic-gate# 49*5aefb655Srie# Don't use the /*LINTLIBRARY*/ directive in linker libraries, this disables 50*5aefb655Srie# some important checks, including the ability to test format strings from the 51*5aefb655Srie# msg.h files. 527c478bd9Sstevel@tonic-gate# 53*5aefb655Srie# Don't use the `-x' option to lint when linting linker libraries. This masks 54*5aefb655Srie# all the dead wood in our own header files. Instead, there has been added to 55*5aefb655Srie# the relevant common directories a file called `lintsup.c' which is used to 56*5aefb655Srie# mask out the headers that we aren't interested in. This method is used for 57*5aefb655Srie# libraries, like libld, which have their own header files, but is irrelevant 58*5aefb655Srie# to libraries like libldstab which exports no interface of it's own. 597c478bd9Sstevel@tonic-gate# 60*5aefb655Srie# The `lintsup.c' file can also be used, in some cases, to mask out other 61*5aefb655Srie# issues that lint won't otherwise shut up about. 627c478bd9Sstevel@tonic-gate# 637c478bd9Sstevel@tonic-gate# Other Lint Options 647c478bd9Sstevel@tonic-gate# 65*5aefb655Srie# `-m' has been added to the LINTFLAGS. Warnings about globals that could be 66*5aefb655Srie# static are irrelevant as we use mapfiles to scope down unnecessary globals. 677c478bd9Sstevel@tonic-gate# 68*5aefb655Srie# `-u' is used in the LINTFLAGS for libraries, otherwise lint tends to be very 69*5aefb655Srie# noisy. 707c478bd9Sstevel@tonic-gate# 71*5aefb655Srie# `-x' is avoided for libraries, but is used for executables because all we 72*5aefb655Srie# care about is that what we use is defined, not about declarations in public 73*5aefb655Srie# headers that we don't use. 747c478bd9Sstevel@tonic-gate# 757c478bd9Sstevel@tonic-gate# Relevant variables: 767c478bd9Sstevel@tonic-gate# 777c478bd9Sstevel@tonic-gate# */Makefile.com 787c478bd9Sstevel@tonic-gate# SRCS= ../common/llib-l<libname> 797c478bd9Sstevel@tonic-gate# LINTSRCS= <source files> 807c478bd9Sstevel@tonic-gate# LDLIBS= ... [$(LDDBG_LIB) $(LD_LIB)] 817c478bd9Sstevel@tonic-gate# LINTFLAGS= ... 827c478bd9Sstevel@tonic-gate# LINTFLAGS64= ... 837c478bd9Sstevel@tonic-gate# CLEANFILES += ... $(LINTOUTS) 847c478bd9Sstevel@tonic-gate# CLOBBERFILES += ... $(LINTLIBS) 857c478bd9Sstevel@tonic-gate# 867c478bd9Sstevel@tonic-gate# Relevant targets: 877c478bd9Sstevel@tonic-gate# 887c478bd9Sstevel@tonic-gate# */Makefile.targ 897c478bd9Sstevel@tonic-gate# # this file for SGS lint targets. 907c478bd9Sstevel@tonic-gate# include $(SRC)/cmd/sgs/Makefile.targ 917c478bd9Sstevel@tonic-gate# 927c478bd9Sstevel@tonic-gate# lint: <choose the desired functionality> $(SGSLINTOUT) 937c478bd9Sstevel@tonic-gate# 947c478bd9Sstevel@tonic-gate# $(LINTLIB32), 957c478bd9Sstevel@tonic-gate# $(LINTLIB64) Create an Elf32 or Elf64 lint library from 967c478bd9Sstevel@tonic-gate# a proto file indicated by the $(SRCS) variable. 977c478bd9Sstevel@tonic-gate# 987c478bd9Sstevel@tonic-gate# $(LINTOUT32), 997c478bd9Sstevel@tonic-gate# $(LINTOUT64) Run lint on the sources indicated by the 1007c478bd9Sstevel@tonic-gate# $(LINTSRCS) variable with respect to Elf32 1017c478bd9Sstevel@tonic-gate# or Elf64. Dependencies are gathered from 1027c478bd9Sstevel@tonic-gate# the $(LDLIBS) variable. 1037c478bd9Sstevel@tonic-gate# 1047c478bd9Sstevel@tonic-gate# $(SGSLINTOUT) Create a `lint.out' file as the concatination 1057c478bd9Sstevel@tonic-gate# of the lint output from the previous targets. 1067c478bd9Sstevel@tonic-gate# This should be specified *last* in the list. 1077c478bd9Sstevel@tonic-gate# 1087c478bd9Sstevel@tonic-gate################################################################################ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate# 1117c478bd9Sstevel@tonic-gate# Override the OS's $(LINTOUT) target to avoid confusion. 1127c478bd9Sstevel@tonic-gate# 1137c478bd9Sstevel@tonic-gateLINTOUT = $(LINTOUT1) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate# 116*5aefb655Srie# If LD_LIB, LDDBG_LIB, or CONV_LIB is added to LDLIBS, then the right lint 117*5aefb655Srie# library should be picked up automatically. 1187c478bd9Sstevel@tonic-gate# 1197c478bd9Sstevel@tonic-gate$(LINTOUT32) := LD_LIB=$(LD_LIB32) 1207c478bd9Sstevel@tonic-gate$(LINTOUT32) := LDDBG_LIB=$(LDDBG_LIB32) 121*5aefb655Srie$(LINTOUT32) := CONV_LIB=$(CONV_LIB32) 122*5aefb655Srie 1237c478bd9Sstevel@tonic-gate$(LINTOUT64) := LD_LIB=$(LD_LIB64) 1247c478bd9Sstevel@tonic-gate$(LINTOUT64) := LDDBG_LIB=$(LDDBG_LIB64) 125*5aefb655Srie$(LINTOUT64) := CONV_LIB=$(CONV_LIB64) 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate# 1287c478bd9Sstevel@tonic-gate# Force $(LINTLIB) in order to help the $(SGSLINTOUT) 1297c478bd9Sstevel@tonic-gate# target produce the same output on successive runs. 1307c478bd9Sstevel@tonic-gate# 1317c478bd9Sstevel@tonic-gate$(LINTLIB): FRC 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate$(LINTLIB32): $(SRCS) 1347c478bd9Sstevel@tonic-gate $(LINT.c) -o $(LIBNAME32) $(SRCS) 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate$(LINTLIB64): $(SRCS) 1377c478bd9Sstevel@tonic-gate $(LINT.c) -D_ELF64 -o $(LIBNAME64) $(SRCS) 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate$(LINTOUT32): $(LINTSRCS) $(LINTSRCS32) 1407c478bd9Sstevel@tonic-gate $(LINT.c) $(LINTSRCS) $(LINTSRCS32) $(LDLIBS) > $(LINTOUT32) 2>&1 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate$(LINTOUT64): $(LINTSRCS) $(LINTSRCS64) 1437c478bd9Sstevel@tonic-gate $(LINT.c) -D_ELF64 $(LINTSRCS) $(LINTSRCS64) \ 1447c478bd9Sstevel@tonic-gate $(LDLIBS) > $(LINTOUT64) 2>&1 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate$(SGSLINTOUT): FRC 1477c478bd9Sstevel@tonic-gate @ rm -f $(SGSLINTOUT) 1487c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT1) ]; then \ 1497c478bd9Sstevel@tonic-gate echo "\n"$(LINTLIB) >> $(SGSLINTOUT); \ 1507c478bd9Sstevel@tonic-gate echo $(DASHES) >> $(SGSLINTOUT); \ 1517c478bd9Sstevel@tonic-gate cat $(LINTOUT1) >> $(SGSLINTOUT); \ 1527c478bd9Sstevel@tonic-gate fi 1537c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT32) ]; then \ 1547c478bd9Sstevel@tonic-gate if [ -n "$(DYNLIB)" ] ; then \ 1557c478bd9Sstevel@tonic-gate echo "\nElf32 - $(DYNLIB)" >> $(SGSLINTOUT); \ 1567c478bd9Sstevel@tonic-gate elif [ -n "$(RTLD)" ] ; then \ 1577c478bd9Sstevel@tonic-gate echo "\nElf32 - $(RTLD)" >> $(SGSLINTOUT); \ 1587c478bd9Sstevel@tonic-gate else echo "\nElf32 - $(PROG)" >> $(SGSLINTOUT); \ 1597c478bd9Sstevel@tonic-gate fi; \ 1607c478bd9Sstevel@tonic-gate echo $(DASHES) >> $(SGSLINTOUT); \ 1617c478bd9Sstevel@tonic-gate cat $(LINTOUT32) >> $(SGSLINTOUT); \ 1627c478bd9Sstevel@tonic-gate fi 1637c478bd9Sstevel@tonic-gate @ if [ -r $(LINTOUT64) ]; then \ 1647c478bd9Sstevel@tonic-gate if [ -n "$(DYNLIB)" ] ; then \ 1657c478bd9Sstevel@tonic-gate if [ $(DYNLIB) = "libld.so.2" ] ; then \ 1667c478bd9Sstevel@tonic-gate echo "\nElf64 - libld.so.3" >> $(SGSLINTOUT); \ 1677c478bd9Sstevel@tonic-gate else \ 1687c478bd9Sstevel@tonic-gate echo "\nElf64 - $(DYNLIB)" >> $(SGSLINTOUT); \ 1697c478bd9Sstevel@tonic-gate fi; \ 1707c478bd9Sstevel@tonic-gate elif [ -n "$(RTLD)" ] ; then \ 1717c478bd9Sstevel@tonic-gate echo "\nElf64 - $(RTLD)" >> $(SGSLINTOUT); \ 1727c478bd9Sstevel@tonic-gate else echo "\nElf64 - $(PROG)" >> $(SGSLINTOUT); \ 1737c478bd9Sstevel@tonic-gate fi; \ 1747c478bd9Sstevel@tonic-gate echo $(DASHES) >> $(SGSLINTOUT); \ 1757c478bd9Sstevel@tonic-gate cat $(LINTOUT64) >> $(SGSLINTOUT); \ 1767c478bd9Sstevel@tonic-gate fi 1777c478bd9Sstevel@tonic-gate @ rm -f $(LINTOUT1) $(LINTOUT32) $(LINTOUT64) 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate# 1807c478bd9Sstevel@tonic-gate# For those that install the lint library source file. 1817c478bd9Sstevel@tonic-gate# 1827c478bd9Sstevel@tonic-gate$(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC) 1837c478bd9Sstevel@tonic-gate $(INS.file) ../common/$(LINTLIBSRC) 1847c478bd9Sstevel@tonic-gate 185*5aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKS): \ 186*5aefb655Srie $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS) 1877c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblink) 1887c478bd9Sstevel@tonic-gate 189*5aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKS): \ 190*5aefb655Srie $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS) 1917c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblink64) 1927c478bd9Sstevel@tonic-gate 193*5aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): \ 194*5aefb655Srie $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS) 1957c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblinkccc) 1967c478bd9Sstevel@tonic-gate 197*5aefb655Srie$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): \ 198*5aefb655Srie $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS) 1997c478bd9Sstevel@tonic-gate$(VAR_POUND_1) $(INS.liblinkccc64) 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gateFRC: 202