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) 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 124BLTDEFS= msg.h 125BLTDATA= msg.c 126BLTMESG= $(SGSMSGDIR)/rtld 127 128BLTFILES= $(BLTDEFS) $(BLTDATA) $(BLTMESG) 129 130SGSMSGCOM= ../common/rtld.msg 131SGSMSG32= ../common/rtld.32.msg 132SGSMSG64= ../common/rtld.64.msg 133SGSMSGSPARC= ../common/rtld.sparc.msg 134SGSMSGSPARC32= ../common/rtld.sparc32.msg 135SGSMSGSPARC64= ../common/rtld.sparc64.msg 136SGSMSGINTEL= ../common/rtld.intel.msg 137SGSMSGINTEL32= ../common/rtld.intel32.msg 138SGSMSGINTEL64= ../common/rtld.intel64.msg 139SGSMSGCHK= ../common/rtld.chk.msg 140SGSMSGTARG= $(SGSMSGCOM) 141SGSMSGALL= $(SGSMSGCOM) $(SGSMSG32) $(SGSMSG64) \ 142 $(SGSMSGSPARC) $(SGSMSGSPARC32) $(SGSMSGSPARC64) \ 143 $(SGSMSGINTEL) $(SGSMSGINTEL32) $(SGSMSGINTEL64) 144 145SGSMSGFLAGS1= $(SGSMSGFLAGS) -m $(BLTMESG) 146SGSMSGFLAGS2= $(SGSMSGFLAGS) -h $(BLTDEFS) -d $(BLTDATA) -n rtld_msg 147 148SRCS= $(AVLOBJ:%.o=$(SRC)/common/avl/%.c) \ 149 $(DTROBJ:%.o=$(SRC)/common/dtrace/%.c) \ 150 $(SGSCOMMONOBJ:%.o=$(SGSCOMMON)/%.c) \ 151 $(COMOBJS:%.o=../common/%.c) $(MACHOBJS:%.o=%.c) $(BLTDATA) \ 152 $(G_MACHOBJS:%.o=$(SRC)/uts/$(PLAT)/krtld/%.c) \ 153 $(CP_MACHOBJS:%.o=../$(MACH)/%.c) \ 154 $(ASOBJS:%.o=%.S) 155 156CLEANFILES += $(CRTS) $(BLTFILES) 157CLOBBERFILES += $(RTLD) 158 159# 160# We cannot currently enable the stack protector for rtld as it runs 161# before libc initializes, which is where we always enable the stack 162# protector values. Because rtld is likely on an alternate link map and 163# links in the relevant portions of libc through libc_pic.a, there is 164# probably a path to enabling an rtld specific version of the stack 165# protector. 166# 167# As a result, this currently disables the stack protector in two 168# related targets which really could use it. These are libconv and libc. 169# Both of these end up building position-independent archive libraries 170# that are directly linked into rtld. This situation can and should be 171# improved. 172# 173STACKPROTECT = none 174