xref: /illumos-gate/usr/src/cmd/sgs/rtld/Makefile.com (revision a4955f4fa65e38d70c07d38e657a9aff43fa155f)
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=	-P -D_ASM $(CPPFLAGS)
99LDLIB =		-L ../../libld/$(MACH)
100RTLDLIB =	-L ../../librtld/$(MACH)
101
102CERRWARN +=	$(CNOWARN_UNINIT)
103CERRWARN +=	-_gcc=-Wno-unused-variable
104
105# not linted
106SMATCH=off
107
108# These definitions require that libc be built in the same workspace
109# as the run-time linker and before the run-time linker is built.
110# This is required for the system's self-consistency in any case.
111CPICLIB =	-L $(SRC)/lib/libc/$(MACH)
112CPICLIB64 =	-L $(SRC)/lib/libc/$(MACH64)
113CLIB =		-lc_pic
114
115LDLIBS +=	$(CONVLIBDIR) -lconv \
116		$(CPICLIB) $(CLIB) \
117		$(LDDBGLIBDIR) -llddbg \
118		$(RTLDLIB) -lrtld \
119		$(LDLIB) -lld
120
121DYNFLAGS +=	-i -e _rt_boot $(VERSREF) $(ZNODLOPEN) \
122		$(ZINTERPOSE) -zdtrace=dtrace_data '-R$$ORIGIN'
123
124BUILD.s=	$(AS) $(ASFLAGS) $< -o $@
125
126BLTDEFS=	msg.h
127BLTDATA=	msg.c
128BLTMESG=	$(SGSMSGDIR)/rtld
129
130BLTFILES=	$(BLTDEFS) $(BLTDATA) $(BLTMESG)
131
132SGSMSGCOM=	../common/rtld.msg
133SGSMSG32=	../common/rtld.32.msg
134SGSMSG64=	../common/rtld.64.msg
135SGSMSGSPARC=	../common/rtld.sparc.msg
136SGSMSGSPARC32=	../common/rtld.sparc32.msg
137SGSMSGSPARC64=	../common/rtld.sparc64.msg
138SGSMSGINTEL=	../common/rtld.intel.msg
139SGSMSGINTEL32=	../common/rtld.intel32.msg
140SGSMSGINTEL64=	../common/rtld.intel64.msg
141SGSMSGCHK=	../common/rtld.chk.msg
142SGSMSGTARG=	$(SGSMSGCOM)
143SGSMSGALL=	$(SGSMSGCOM) $(SGSMSG32) $(SGSMSG64) \
144		$(SGSMSGSPARC) $(SGSMSGSPARC32) $(SGSMSGSPARC64) \
145		$(SGSMSGINTEL) $(SGSMSGINTEL32) $(SGSMSGINTEL64)
146
147SGSMSGFLAGS1=	$(SGSMSGFLAGS) -m $(BLTMESG)
148SGSMSGFLAGS2=	$(SGSMSGFLAGS) -h $(BLTDEFS) -d $(BLTDATA) -n rtld_msg
149
150SRCS=		$(AVLOBJ:%.o=$(SRC)/common/avl/%.c) \
151		$(DTROBJ:%.o=$(SRC)/common/dtrace/%.c) \
152		$(SGSCOMMONOBJ:%.o=$(SGSCOMMON)/%.c) \
153		$(COMOBJS:%.o=../common/%.c)  $(MACHOBJS:%.o=%.c) $(BLTDATA) \
154		$(G_MACHOBJS:%.o=$(SRC)/uts/$(PLAT)/krtld/%.c) \
155		$(CP_MACHOBJS:%.o=../$(MACH)/%.c) \
156		$(ASOBJS:%.o=%.s)
157
158CLEANFILES +=	$(CRTS) $(BLTFILES)
159CLOBBERFILES +=	$(RTLD)
160
161#
162# We cannot currently enable the stack protector for rtld as it runs
163# before libc initializes, which is where we always enable the stack
164# protector values. Because rtld is likely on an alternate link map and
165# links in the relevant portions of libc through libc_pic.a, there is
166# probably a path to enabling an rtld specific version of the stack
167# protector.
168#
169# As a result, this currently disables the stack protector in two
170# related targets which really could use it. These are libconv and libc.
171# Both of these end up building position-independent archive libraries
172# that are directly linked into rtld. This situation can and should be
173# improved.
174#
175STACKPROTECT = none
176