1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
#
# 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) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, Joyent, Inc.
# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
#
RTLD= ld.so.1
AVLOBJ= avl.o
DTROBJ= dtrace_data.o
SGSCOMMONOBJ= alist.o strhash.o
BLTOBJ= msg.o
ELFCAPOBJ= elfcap.o
OBJECTS= $(BLTOBJ) \
$(AVLOBJ) \
$(DTROBJ) \
$(SGSCOMMONOBJ) \
$(ELFCAPOBJ) \
$(P_ASOBJS) $(P_COMOBJS) $(P_MACHOBJS) $(G_MACHOBJS) \
$(S_ASOBJS) $(S_COMOBJS) $(S_MACHOBJS) $(CP_MACHOBJS)
COMOBJS= $(P_COMOBJS) $(S_COMOBJS)
ASOBJS= $(P_ASOBJS) $(S_ASOBJS)
MACHOBJS= $(P_MACHOBJS) $(S_MACHOBJS)
NOCTFOBJS= $(ASOBJS)
include $(SRC)/lib/Makefile.lib
include $(SRC)/cmd/sgs/Makefile.com
# Hammerhead: ld.so.1 MUST be linked by illumos ld (not GNU ld).
# GNU ld produces ELFOSABI_NONE, missing PT_SUNWDTRACE/PT_SUNW_UNWIND headers,
# and wrong segment alignment — the kernel cannot properly map the result.
# The actual LD override is in the arch-specific Makefile (amd64/Makefile)
# because it must come AFTER Makefile.master.64 which resets LD.
SRCDIR = ../common
ELFCAP = $(SRC)/common/elfcap
PLAT_i386 = intel/ia32
PLAT_amd64 = intel/amd64
PLAT_sparc = sparc
PLAT = $(PLAT_$(BASEPLAT))
# DTrace needs an executable data segment.
MAPFILE.NED=
MAPFILES += $(MAPFILE-ORDER)
# For the libc/libthread unified world:
# This library needs to be placed in /lib to allow
# dlopen() functionality while in single-user mode.
ROOTFS_DYNLIB= $(RTLD:%=$(ROOTFS_LIBDIR)/%)
ROOTFS_DYNLIB64= $(RTLD:%=$(ROOTFS_LIBDIR64)/%)
# For the libc/libthread separated world:
# A version of this library needs to be placed in /etc/lib to allow
# dlopen() functionality while in single-user mode.
ETCLIBDIR= $(ROOT)/etc/lib
ETCDYNLIB= $(RTLD:%=$(ETCLIBDIR)/%)
ROOTDYNLIB= $(RTLD:%=$(ROOTFS_LIBDIR)/%)
ROOTDYNLIB64= $(RTLD:%=$(ROOTFS_LIBDIR64)/%)
COMPATLINKS= etc/lib/ld.so.1 \
usr/lib/ld.so.1
# Hammerhead: 64-bit only - no amd64 compat links needed (covered by COMPATLINKS)
COMPATLINKS64=
$(ROOT)/etc/lib/ld.so.1 : COMPATLINKTARGET= ../../lib/ld.so.1
$(ROOT)/usr/lib/ld.so.1 : COMPATLINKTARGET= ../../lib/ld.so.1
FILEMODE = 755
CPPFLAGS += -I$(SRC)/lib/libc/inc \
-I$(SRC)/uts/common/krtld \
-I$(SRC)/uts/$(PLAT) \
-I$(SRC)/uts/$(PLAT)/krtld \
-I$(SRC)/common/sgsrtcid \
-I$(ELFCAP) \
$(CPPFEATUREMACROS)
ASFLAGS += -D_ASM $(CPPFLAGS)
ASFLAGS64 += -D_ASM $(CPPFLAGS)
LDLIB = -L ../../libld/$(MACH)
RTLDLIB = -L ../../librtld/$(MACH)
CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
# These definitions require that libc be built in the same workspace
# as the run-time linker and before the run-time linker is built.
# This is required for the system's self-consistency in any case.
CPICLIB = -L $(SRC)/lib/libc/$(MACH)
CPICLIB64 = -L $(SRC)/lib/libc/$(MACH64)
CLIB = -lc_pic
LDLIBS += $(CONVLIBDIR) -lconv \
$(CPICLIB) $(CLIB) \
$(LDDBGLIBDIR) -llddbg \
$(RTLDLIB) -lrtld \
$(LDLIB) -lld
# -Bsymbolic: all global symbols resolve locally (no interposition).
# Safe for rtld because it IS the runtime linker - never interposed.
DYNFLAGS += -i -e _rt_boot $(VERSREF) $(ZNODLOPEN) \
$(ZINTERPOSE) -zdtrace=dtrace_data '-R$$ORIGIN' \
-Bsymbolic
BLTDEFS= msg.h
BLTDATA= msg.c
BLTMESG= $(SGSMSGDIR)/rtld
BLTFILES= $(BLTDEFS) $(BLTDATA) $(BLTMESG)
# Hammerhead: amd64-only (sparc, 32-bit variants removed).
SGSMSGCOM= ../common/rtld.msg
SGSMSG64= ../common/rtld.64.msg
SGSMSGINTEL= ../common/rtld.intel.msg
SGSMSGINTEL64= ../common/rtld.intel64.msg
SGSMSGCHK= ../common/rtld.chk.msg
SGSMSGTARG= $(SGSMSGCOM)
SGSMSGALL= $(SGSMSGCOM) $(SGSMSG64) \
$(SGSMSGINTEL) $(SGSMSGINTEL64)
SGSMSGFLAGS1= $(SGSMSGFLAGS) -m $(BLTMESG)
SGSMSGFLAGS2= $(SGSMSGFLAGS) -h $(BLTDEFS) -d $(BLTDATA) -n rtld_msg
SRCS= $(AVLOBJ:%.o=$(SRC)/common/avl/%.c) \
$(DTROBJ:%.o=$(SRC)/common/dtrace/%.c) \
$(SGSCOMMONOBJ:%.o=$(SGSCOMMON)/%.c) \
$(COMOBJS:%.o=../common/%.c) $(MACHOBJS:%.o=%.c) $(BLTDATA) \
$(G_MACHOBJS:%.o=$(SRC)/uts/$(PLAT)/krtld/%.c) \
$(CP_MACHOBJS:%.o=../$(MACH)/%.c) \
$(ASOBJS:%.o=%.S)
CLEANFILES += $(CRTS) $(BLTFILES)
CLOBBERFILES += $(RTLD)
#
# We cannot currently enable the stack protector for rtld as it runs
# before libc initializes, which is where we always enable the stack
# protector values. Because rtld is likely on an alternate link map and
# links in the relevant portions of libc through libc_pic.a, there is
# probably a path to enabling an rtld specific version of the stack
# protector.
#
# As a result, this currently disables the stack protector in two
# related targets which really could use it. These are libconv and libc.
# Both of these end up building position-independent archive libraries
# that are directly linked into rtld. This situation can and should be
# improved.
#
STACKPROTECT = none
|