x86: Add SSE2 optimized chacha20
[glibc.git] / csu / Makefile
blob2e8a28e851614aa828aff330538ecee609c5f4dd
1 # Makefile for csu code for GNU C library.
2 # Copyright (C) 1995-2022 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
19 # This directory contains the C startup code (that which calls main). This
20 # consists of the startfile, built from start.c and installed as crt0.o
21 # (traditionally) or crt1.o (for ELF). In ELF we also install crti.o and
22 # crtn.o, special "initializer" and "finalizer" files used in the link
23 # to make the .init and .fini sections work right.
25 subdir := csu
27 include ../Makeconfig
29 routines = init-first libc-start $(libc-init) sysdep version check_fds \
30 libc-tls dso_handle
31 aux = errno
32 elide-routines.os = libc-tls
33 csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
34 extra-objs = start.o \
35 $(start-installed-name) g$(start-installed-name) $(csu-dummies) \
36 S$(start-installed-name)
37 omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
38 b$(start-installed-name) $(csu-dummies) \
39 S$(start-installed-name) \
40 r$(start-installed-name) \
41 gr$(start-installed-name))
42 install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
44 # No tests are allowed in the csu/ subdirectory because the startup
45 # code is compiled with special flags.
46 tests =
48 # static-reloc.os is a dummy object not actually used for anything. It is
49 # linked into crt1.o nevertheless, which in turn is statically linked into
50 # applications, so that build flags matter.
51 # See <https://sourceware.org/ml/libc-alpha/2018-07/msg00101.html>.
53 # libc-start.os is safe to be built with stack protector since
54 # __libc_start_main is called after stack canary setup is done.
55 ssp-safe.os = static-reloc libc-start
57 CFLAGS-.o += $(call elide-stack-protector,.o,$(routines))
58 CFLAGS-.op += $(call elide-stack-protector,.op,$(routines))
59 CFLAGS-.oS += $(call elide-stack-protector,.oS,$(routines))
60 CFLAGS-.os += $(call elide-stack-protector,.os,$(filter-out \
61 $(ssp-safe.os),$(routines)))
63 ifeq (yes,$(build-shared))
64 extra-objs += S$(start-installed-name) gmon-start.os
65 ifneq ($(start-installed-name),$(static-start-installed-name))
66 extra-objs += gmon-start.o
67 endif
68 install-lib += S$(start-installed-name)
69 generated += start.os
70 else
71 extra-objs += gmon-start.o
72 endif
74 ifeq (yes,$(enable-static-pie))
75 extra-objs += r$(start-installed-name) gr$(start-installed-name)
76 install-lib += r$(start-installed-name) gr$(start-installed-name)
77 endif
79 ifneq ($(start-installed-name),$(static-start-installed-name))
80 extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
81 omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
82 g$(static-start-installed-name))
83 install-lib += $(static-start-installed-name) g$(static-start-installed-name)
84 ifeq (yes,$(enable-static-pie))
85 extra-objs += r$(static-start-installed-name) gr$(static-start-installed-name)
86 omit-deps += $(patsubst %.o,%,r$(static-start-installed-name) \
87 gr$(static-start-installed-name))
88 install-lib += r$(static-start-installed-name) gr$(static-start-installed-name)
89 endif
90 endif
92 before-compile += $(objpfx)abi-tag.h
93 generated += abi-tag.h
95 # Put it here to generate it earlier.
96 gen-as-const-headers += rtld-sizes.sym
98 # These are the special initializer/finalizer files. They are always the
99 # first and last file in the link. crti.o ... crtn.o define the global
100 # "functions" _init and _fini to run the .init and .fini sections.
101 crtstuff = crti crtn
103 install-lib += $(crtstuff:=.o)
104 extra-objs += $(crtstuff:=.o)
106 ifneq ($(multidir),.)
107 multilib-extra-objs = $(addprefix $(multidir)/, $(install-lib))
108 extra-objs += $(multilib-extra-objs)
109 endif
111 extra-objs += abi-note.o init.o static-reloc.o
112 ifeq (yes,$(build-shared))
113 extra-objs += static-reloc.os
114 endif
115 asm-CPPFLAGS += -I$(objpfx).
117 # Enable unwinding so backtrace unwinds to __libc_start_main
118 CFLAGS-libc-start.c += -funwind-tables
120 include ../Rules
122 # Make these in the lib pass so they're available in time to link things with.
123 subdir_lib: $(extra-objs:%=$(objpfx)%)
125 define link-relocatable
126 $(CC) -nostdlib -nostartfiles -r -o $@ $^
127 endef
129 ifndef start-installed-name-rule
130 # We link the ELF startfile along with a SHT_NOTE section indicating
131 # the kernel ABI the binaries linked with this library will require.
132 $(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
133 $(objpfx)init.o $(objpfx)static-reloc.o
134 $(link-relocatable)
135 $(objpfx)r$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
136 $(objpfx)init.o
137 $(link-relocatable)
138 $(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \
139 $(objpfx)init.o
140 $(link-relocatable)
141 endif
143 # The profiling startfile is made by linking together the normal
144 # startfile with gmon-start.o, which defines a constructor function
145 # to turn on profiling code at startup.
146 ifeq (yes,$(build-shared))
147 $(objpfx)g$(start-installed-name): \
148 $(objpfx)g%: $(objpfx)S% $(objpfx)gmon-start.os $(objpfx)static-reloc.os
149 $(link-relocatable)
150 $(objpfx)gr$(start-installed-name): \
151 $(objpfx)gr%: $(objpfx)r% $(objpfx)gmon-start.o
152 $(link-relocatable)
153 ifneq ($(start-installed-name),$(static-start-installed-name))
154 $(objpfx)g$(static-start-installed-name): \
155 $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
156 $(link-relocatable)
157 $(objpfx)gr$(static-start-installed-name): \
158 $(objpfx)gr%: $(objpfx)r% $(objpfx)gmon-start.o
159 $(link-relocatable)
160 endif
161 else
162 $(addprefix $(objpfx),$(sort g$(start-installed-name) \
163 g$(static-start-installed-name))): \
164 $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
165 $(link-relocatable)
166 endif
168 # These extra files are sometimes expected by system standard linking
169 # procedures, but we have nothing for them to do. So compile empty files.
170 $(addprefix $(objpfx),$(filter-out $(start-installed-name), $(csu-dummies))):\
171 $(before-compile)
172 $(COMPILE.c) -o $@ -x c /dev/null
174 # These headers are used by the startup code.
175 $(objpfx)abi-tag.h: $(..)abi-tags
176 $(make-target-directory)
177 rm -f $@.new
178 sed -e 's/#.*$$//' -e '/^[ ]*$$/d' $< | \
179 while read conf tagos tagver; do \
180 test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
181 : "$$conf"` != 0 || continue; \
182 ( echo "$$tagos" | \
183 sed -e 's/[^0-9xXa-fA-F ]//' \
184 -e 's/^/#define __ABI_TAG_OS /'; \
185 echo "#ifndef __ABI_TAG_VERSION"; \
186 echo "$$tagver" | \
187 sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \
188 -e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \
189 echo "#endif" ) > $@.new; \
190 done
191 if test -r $@.new; then mv -f $@.new $@; \
192 else echo >&2 'This configuration not matched in $<'; exit 1; fi
194 ifneq ($(multidir),.)
195 $(addprefix $(objpfx)$(multidir)/, $(install-lib)): $(addprefix $(objpfx), $(install-lib))
196 $(make-link-multidir)
197 endif