xref: /illumos-gate/usr/src/cmd/sgs/rtld/Makefile.com (revision 763f1f5f97e4c16840af2ced98915f0ed0f46616)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
24# Copyright (c) 2018, Joyent, Inc.
25# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
26#
27
28RTLD=		ld.so.1
29
30AVLOBJ=		avl.o
31DTROBJ=		dtrace_data.o
32SGSCOMMONOBJ=	alist.o strhash.o
33BLTOBJ=		msg.o
34ELFCAPOBJ=	elfcap.o
35OBJECTS=	$(BLTOBJ) \
36		$(AVLOBJ) \
37		$(DTROBJ) \
38		$(SGSCOMMONOBJ) \
39		$(ELFCAPOBJ) \
40		$(P_ASOBJS)   $(P_COMOBJS)   $(P_MACHOBJS)   $(G_MACHOBJS)  \
41		$(S_ASOBJS)   $(S_COMOBJS)   $(S_MACHOBJS)   $(CP_MACHOBJS)
42
43COMOBJS=	$(P_COMOBJS)  $(S_COMOBJS)
44ASOBJS=		$(P_ASOBJS)   $(S_ASOBJS)
45MACHOBJS=	$(P_MACHOBJS) $(S_MACHOBJS)
46NOCTFOBJS=	$(ASOBJS)
47
48include		$(SRC)/lib/Makefile.lib
49include		$(SRC)/cmd/sgs/Makefile.com
50
51SRCDIR =	../common
52ELFCAP =	$(SRC)/common/elfcap
53
54PLAT_i386 =	intel/ia32
55PLAT_amd64 =	intel/amd64
56PLAT_sparc =	sparc
57PLAT = $(PLAT_$(BASEPLAT))
58
59# DTrace needs an executable data segment.
60MAPFILE.NED=
61
62MAPFILES +=	$(MAPFILE-ORDER)
63
64# For the libc/libthread unified world:
65# This library needs to be placed in /lib to allow
66# dlopen() functionality while in single-user mode.
67ROOTFS_DYNLIB=	$(RTLD:%=$(ROOTFS_LIBDIR)/%)
68ROOTFS_DYNLIB64=	$(RTLD:%=$(ROOTFS_LIBDIR64)/%)
69
70# For the libc/libthread separated world:
71# A version of this library needs to be placed in /etc/lib to allow
72# dlopen() functionality while in single-user mode.
73ETCLIBDIR=	$(ROOT)/etc/lib
74ETCDYNLIB=	$(RTLD:%=$(ETCLIBDIR)/%)
75
76ROOTDYNLIB=	$(RTLD:%=$(ROOTFS_LIBDIR)/%)
77ROOTDYNLIB64=	$(RTLD:%=$(ROOTFS_LIBDIR64)/%)
78
79COMPATLINKS=	etc/lib/ld.so.1 \
80		usr/lib/ld.so.1
81COMPATLINKS64=	usr/lib/$(MACH64)/ld.so.1
82
83$(ROOT)/etc/lib/ld.so.1 := COMPATLINKTARGET= ../../lib/ld.so.1
84$(ROOT)/usr/lib/ld.so.1 := COMPATLINKTARGET= ../../lib/ld.so.1
85$(ROOT)/usr/lib/$(MACH64)/ld.so.1 := \
86	COMPATLINKTARGET= ../../../lib/$(MACH64)/ld.so.1
87
88FILEMODE =	755
89
90CPPFLAGS +=	-I$(SRC)/lib/libc/inc \
91		-I$(SRC)/uts/common/krtld \
92		-I$(SRC)/uts/$(PLAT) \
93		-I$(SRC)/uts/$(PLAT)/krtld \
94		-I$(SRC)/common/sgsrtcid \
95		-I$(ELFCAP) \
96		 $(CPPFEATUREMACROS)
97
98ASFLAGS +=	-D_ASM $(CPPFLAGS)
99ASFLAGS64 +=	-D_ASM $(CPPFLAGS)
100LDLIB =		-L ../../libld/$(MACH)
101RTLDLIB =	-L ../../librtld/$(MACH)
102
103CERRWARN +=	$(CNOWARN_UNINIT)
104CERRWARN +=	-_gcc=-Wno-unused-variable
105
106# not linted
107SMATCH=off
108
109# These definitions require that libc be built in the same workspace
110# as the run-time linker and before the run-time linker is built.
111# This is required for the system's self-consistency in any case.
112CPICLIB =	-L $(SRC)/lib/libc/$(MACH)
113CPICLIB64 =	-L $(SRC)/lib/libc/$(MACH64)
114CLIB =		-lc_pic
115
116LDLIBS +=	$(CONVLIBDIR) -lconv \
117		$(CPICLIB) $(CLIB) \
118		$(LDDBGLIBDIR) -llddbg \
119		$(RTLDLIB) -lrtld \
120		$(LDLIB) -lld
121
122DYNFLAGS +=	-i -e _rt_boot $(VERSREF) $(ZNODLOPEN) \
123		$(ZINTERPOSE) -zdtrace=dtrace_data '-R$$ORIGIN'
124
125BLTDEFS=	msg.h
126BLTDATA=	msg.c
127BLTMESG=	$(SGSMSGDIR)/rtld
128
129BLTFILES=	$(BLTDEFS) $(BLTDATA) $(BLTMESG)
130
131SGSMSGCOM=	../common/rtld.msg
132SGSMSG32=	../common/rtld.32.msg
133SGSMSG64=	../common/rtld.64.msg
134SGSMSGSPARC=	../common/rtld.sparc.msg
135SGSMSGSPARC32=	../common/rtld.sparc32.msg
136SGSMSGSPARC64=	../common/rtld.sparc64.msg
137SGSMSGINTEL=	../common/rtld.intel.msg
138SGSMSGINTEL32=	../common/rtld.intel32.msg
139SGSMSGINTEL64=	../common/rtld.intel64.msg
140SGSMSGCHK=	../common/rtld.chk.msg
141SGSMSGTARG=	$(SGSMSGCOM)
142SGSMSGALL=	$(SGSMSGCOM) $(SGSMSG32) $(SGSMSG64) \
143		$(SGSMSGSPARC) $(SGSMSGSPARC32) $(SGSMSGSPARC64) \
144		$(SGSMSGINTEL) $(SGSMSGINTEL32) $(SGSMSGINTEL64)
145
146SGSMSGFLAGS1=	$(SGSMSGFLAGS) -m $(BLTMESG)
147SGSMSGFLAGS2=	$(SGSMSGFLAGS) -h $(BLTDEFS) -d $(BLTDATA) -n rtld_msg
148
149SRCS=		$(AVLOBJ:%.o=$(SRC)/common/avl/%.c) \
150		$(DTROBJ:%.o=$(SRC)/common/dtrace/%.c) \
151		$(SGSCOMMONOBJ:%.o=$(SGSCOMMON)/%.c) \
152		$(COMOBJS:%.o=../common/%.c)  $(MACHOBJS:%.o=%.c) $(BLTDATA) \
153		$(G_MACHOBJS:%.o=$(SRC)/uts/$(PLAT)/krtld/%.c) \
154		$(CP_MACHOBJS:%.o=../$(MACH)/%.c) \
155		$(ASOBJS:%.o=%.S)
156
157CLEANFILES +=	$(CRTS) $(BLTFILES)
158CLOBBERFILES +=	$(RTLD)
159
160#
161# We cannot currently enable the stack protector for rtld as it runs
162# before libc initializes, which is where we always enable the stack
163# protector values. Because rtld is likely on an alternate link map and
164# links in the relevant portions of libc through libc_pic.a, there is
165# probably a path to enabling an rtld specific version of the stack
166# protector.
167#
168# As a result, this currently disables the stack protector in two
169# related targets which really could use it. These are libconv and libc.
170# Both of these end up building position-independent archive libraries
171# that are directly linked into rtld. This situation can and should be
172# improved.
173#
174STACKPROTECT = none
175