]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | # Makefile for csu code for GNU C library. |
bfff8b1b | 2 | # Copyright (C) 1995-2017 Free Software Foundation, Inc. |
28f540f4 RM |
3 | # This file is part of the GNU C Library. |
4 | ||
5 | # The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
28f540f4 RM |
9 | |
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 | |
41bdb6e2 AJ |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | # Lesser General Public License for more details. | |
28f540f4 | 14 | |
41bdb6e2 | 15 | # You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | # License along with the GNU C Library; if not, see |
17 | # <http://www.gnu.org/licenses/>. | |
28f540f4 RM |
18 | |
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 | |
0f9cc699 | 21 | # (traditionally) or crt1.o (for ELF). In ELF we also install crti.o and |
b5ca0fb0 | 22 | # crtn.o, special "initializer" and "finalizer" files used in the link |
0e7dfaef | 23 | # to make the .init and .fini sections work right. |
28f540f4 RM |
24 | |
25 | subdir := csu | |
26 | ||
a5f891ac JM |
27 | include ../Makeconfig |
28 | ||
8a30f00f | 29 | routines = init-first libc-start $(libc-init) sysdep version check_fds \ |
ee2a5ae8 | 30 | libc-tls elf-init dso_handle |
ce460d04 | 31 | aux = errno |
2a76f7ef | 32 | elide-routines.os = libc-tls |
06b31ad3 | 33 | static-only-routines = elf-init |
b6da933b | 34 | csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o) |
d49499c1 | 35 | extra-objs = start.o \ |
b6da933b UD |
36 | $(start-installed-name) g$(start-installed-name) $(csu-dummies) \ |
37 | S$(start-installed-name) | |
11c981a9 | 38 | omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \ |
bc4647a1 UD |
39 | b$(start-installed-name) $(csu-dummies) \ |
40 | S$(start-installed-name)) | |
98186375 | 41 | install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies) |
f08e9a26 RM |
42 | generated += version-info.h |
43 | before-compile += $(objpfx)version-info.h | |
28f540f4 | 44 | |
2908885c NA |
45 | # No tests are allowed in the csu/ subdirectory because the startup |
46 | # code is compiled with special flags. | |
47 | tests = | |
d15851ec | 48 | |
10c85e76 NA |
49 | CFLAGS-.o += $(no-stack-protector) |
50 | CFLAGS-.op += $(no-stack-protector) | |
51 | CFLAGS-.os += $(no-stack-protector) | |
52 | ||
bc4647a1 | 53 | ifeq (yes,$(build-shared)) |
d49499c1 | 54 | extra-objs += S$(start-installed-name) gmon-start.os |
edd4cbcf ST |
55 | ifneq ($(start-installed-name),$(static-start-installed-name)) |
56 | extra-objs += gmon-start.o | |
57 | endif | |
bc4647a1 | 58 | install-lib += S$(start-installed-name) |
95fa8590 | 59 | generated += start.os |
d49499c1 L |
60 | else |
61 | extra-objs += gmon-start.o | |
bc4647a1 UD |
62 | endif |
63 | ||
083973f3 RM |
64 | ifneq ($(start-installed-name),$(static-start-installed-name)) |
65 | extra-objs += $(static-start-installed-name) g$(static-start-installed-name) | |
66 | omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \ | |
67 | g$(static-start-installed-name)) | |
68 | install-lib += $(static-start-installed-name) g$(static-start-installed-name) | |
69 | endif | |
70 | ||
c7562c74 | 71 | before-compile += $(objpfx)abi-tag.h |
da2d1bc5 | 72 | generated += abi-tag.h |
b8dc6a10 | 73 | |
37f91d33 | 74 | # These are the special initializer/finalizer files. They are always the |
4e1bac76 RM |
75 | # first and last file in the link. crti.o ... crtn.o define the global |
76 | # "functions" _init and _fini to run the .init and .fini sections. | |
77 | crtstuff = crti crtn | |
37f91d33 RM |
78 | |
79 | install-lib += $(crtstuff:=.o) | |
80 | extra-objs += $(crtstuff:=.o) | |
3add8e13 | 81 | |
6973fc01 | 82 | extra-objs += abi-note.o init.o |
92f1da4d | 83 | asm-CPPFLAGS += -I$(objpfx). |
51702635 | 84 | |
ca3a382e WD |
85 | # Enable unwinding so backtrace unwinds to __libc_start_main |
86 | CFLAGS-libc-start.c += -funwind-tables | |
87 | ||
28f540f4 RM |
88 | include ../Rules |
89 | ||
71cf0361 UD |
90 | # Make these in the lib pass so they're available in time to link things with. |
91 | subdir_lib: $(extra-objs:%=$(objpfx)%) | |
92 | ||
779ae82e UD |
93 | define link-relocatable |
94 | $(CC) -nostdlib -nostartfiles -r -o $@ $^ | |
95 | endef | |
96 | ||
b8dc6a10 | 97 | ifndef start-installed-name-rule |
779ae82e | 98 | # We link the ELF startfile along with a SHT_NOTE section indicating |
3081378b | 99 | # the kernel ABI the binaries linked with this library will require. |
6973fc01 UD |
100 | $(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \ |
101 | $(objpfx)init.o | |
779ae82e | 102 | $(link-relocatable) |
bc4647a1 UD |
103 | $(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \ |
104 | $(objpfx)init.o | |
105 | $(link-relocatable) | |
779ae82e | 106 | endif |
28f540f4 | 107 | |
11c981a9 RM |
108 | # The profiling startfile is made by linking together the normal |
109 | # startfile with gmon-start.o, which defines a constructor function | |
110 | # to turn on profiling code at startup. | |
d49499c1 | 111 | ifeq (yes,$(build-shared)) |
edd4cbcf | 112 | $(objpfx)g$(start-installed-name): \ |
d49499c1 L |
113 | $(objpfx)g%: $(objpfx)S% $(objpfx)gmon-start.os |
114 | $(link-relocatable) | |
edd4cbcf ST |
115 | ifneq ($(start-installed-name),$(static-start-installed-name)) |
116 | $(objpfx)g$(static-start-installed-name): \ | |
117 | $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o | |
118 | $(link-relocatable) | |
119 | endif | |
d49499c1 | 120 | else |
083973f3 RM |
121 | $(addprefix $(objpfx),$(sort g$(start-installed-name) \ |
122 | g$(static-start-installed-name))): \ | |
123 | $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o | |
779ae82e | 124 | $(link-relocatable) |
d49499c1 | 125 | endif |
11c981a9 | 126 | |
28f540f4 RM |
127 | # These extra files are sometimes expected by system standard linking |
128 | # procedures, but we have nothing for them to do. So compile empty files. | |
b6da933b | 129 | $(addprefix $(objpfx),$(filter-out $(start-installed-name), $(csu-dummies))):\ |
c6696b79 RM |
130 | $(before-compile) |
131 | $(COMPILE.c) -o $@ -x c /dev/null | |
92f1da4d | 132 | |
c7562c74 | 133 | # These headers are used by the startup code. |
92f1da4d | 134 | $(objpfx)abi-tag.h: $(..)abi-tags |
39e16978 | 135 | $(make-target-directory) |
92f1da4d | 136 | rm -f $@.new |
0f9cc699 | 137 | sed -e 's/#.*$$//' -e '/^[ ]*$$/d' $< | \ |
a986484f | 138 | while read conf tagos tagver; do \ |
92f1da4d UD |
139 | test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \ |
140 | : "$$conf"` != 0 || continue; \ | |
a986484f UD |
141 | ( echo "$$tagos" | \ |
142 | sed -e 's/[^0-9xXa-fA-F ]//' \ | |
143 | -e 's/^/#define __ABI_TAG_OS /'; \ | |
144 | echo "#ifndef __ABI_TAG_VERSION"; \ | |
145 | echo "$$tagver" | \ | |
146 | sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \ | |
147 | -e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \ | |
148 | echo "#endif" ) > $@.new; \ | |
92f1da4d UD |
149 | done |
150 | if test -r $@.new; then mv -f $@.new $@; \ | |
151 | else echo >&2 'This configuration not matched in $<'; exit 1; fi | |
c7562c74 | 152 | |
04dca8d3 RM |
153 | all-Banner-files = $(wildcard $(addsuffix /Banner,\ |
154 | $(sort $(subdir-srcdirs) \ | |
155 | $(sysdeps-srcdirs)))) | |
c7562c74 UD |
156 | $(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files) |
157 | $(make-target-directory) | |
5006148e | 158 | (files="$(all-Banner-files)"; \ |
c7562c74 | 159 | if test -n "$$files"; then \ |
9db670f0 | 160 | printf '"Available extensions:\\n"\n'; \ |
0f9cc699 | 161 | sed -e '/^#/d' -e 's/^[[:space:]]*/ /' \ |
63461e75 | 162 | -e 's/^\(.*\)$$/\"\1\\n\"/' $$files; \ |
c7562c74 UD |
163 | fi) > $@T |
164 | mv -f $@T $@ |