|
Packit |
6c4009 |
# Makefile for csu code for GNU C library.
|
|
Packit |
6c4009 |
# Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
# This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
# Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
# <http://www.gnu.org/licenses/>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# This directory contains the C startup code (that which calls main). This
|
|
Packit |
6c4009 |
# consists of the startfile, built from start.c and installed as crt0.o
|
|
Packit |
6c4009 |
# (traditionally) or crt1.o (for ELF). In ELF we also install crti.o and
|
|
Packit |
6c4009 |
# crtn.o, special "initializer" and "finalizer" files used in the link
|
|
Packit |
6c4009 |
# to make the .init and .fini sections work right.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
subdir := csu
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
include ../Makeconfig
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
routines = init-first libc-start $(libc-init) sysdep version check_fds \
|
|
Packit |
6c4009 |
libc-tls elf-init dso_handle
|
|
Packit |
6c4009 |
aux = errno
|
|
Packit |
6c4009 |
elide-routines.os = libc-tls
|
|
Packit |
6c4009 |
static-only-routines = elf-init
|
|
Packit |
6c4009 |
csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
|
|
Packit |
6c4009 |
extra-objs = start.o \
|
|
Packit |
6c4009 |
$(start-installed-name) g$(start-installed-name) $(csu-dummies) \
|
|
Packit |
6c4009 |
S$(start-installed-name)
|
|
Packit |
6c4009 |
omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
|
|
Packit |
6c4009 |
b$(start-installed-name) $(csu-dummies) \
|
|
Packit |
6c4009 |
S$(start-installed-name) \
|
|
Packit |
6c4009 |
r$(start-installed-name) \
|
|
Packit |
6c4009 |
gr$(start-installed-name))
|
|
Packit |
6c4009 |
install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# No tests are allowed in the csu/ subdirectory because the startup
|
|
Packit |
6c4009 |
# code is compiled with special flags.
|
|
Packit |
6c4009 |
tests =
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
CFLAGS-.o += $(no-stack-protector)
|
|
Packit |
6c4009 |
CFLAGS-.op += $(no-stack-protector)
|
|
Packit |
6c4009 |
CFLAGS-.os += $(no-stack-protector)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Dummy object not actually used for anything. It is linked into
|
|
Packit |
6c4009 |
# crt1.o nevertheless, which in turn is statically linked into
|
|
Packit |
6c4009 |
# applications, so that build flags matter.
|
|
Packit |
6c4009 |
# See <https://sourceware.org/ml/libc-alpha/2018-07/msg00101.html>.
|
|
Packit |
6c4009 |
# NB: Using $(stack-protector) in this way causes a wrong definition
|
|
Packit |
6c4009 |
# STACK_PROTECTOR_LEVEL due to the preceding $(no-stack-protector),
|
|
Packit |
6c4009 |
# but it does not matter for this source file.
|
|
Packit |
6c4009 |
CFLAGS-static-reloc.os += $(stack-protector)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# This file is not actually part of the startup code in the nonshared
|
|
Packit |
6c4009 |
# case and statically linked into applications. See
|
|
Packit |
6c4009 |
# <https://sourceware.org/bugzilla/show_bug.cgi?id=23323>,
|
|
Packit |
6c4009 |
# <https://sourceware.org/ml/libc-alpha/2018-06/msg00717.html>.
|
|
Packit |
6c4009 |
# Also see the note above regarding STACK_PROTECTOR_LEVEL.
|
|
Packit |
6c4009 |
CFLAGS-elf-init.oS += $(stack-protector)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq (yes,$(build-shared))
|
|
Packit |
6c4009 |
extra-objs += S$(start-installed-name) gmon-start.os
|
|
Packit |
6c4009 |
ifneq ($(start-installed-name),$(static-start-installed-name))
|
|
Packit |
6c4009 |
extra-objs += gmon-start.o
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
install-lib += S$(start-installed-name)
|
|
Packit |
6c4009 |
generated += start.os
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
extra-objs += gmon-start.o
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq ($(start-installed-name),$(static-start-installed-name))
|
|
Packit |
6c4009 |
# FIXME: Only Hurd defines static-start-installed-name. Hurd needs to
|
|
Packit |
6c4009 |
# provide special rules to support static PIE.
|
|
Packit |
6c4009 |
extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
|
|
Packit |
6c4009 |
omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
|
|
Packit |
6c4009 |
g$(static-start-installed-name))
|
|
Packit |
6c4009 |
install-lib += $(static-start-installed-name) g$(static-start-installed-name)
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
ifeq (yes,$(enable-static-pie))
|
|
Packit |
6c4009 |
extra-objs += r$(start-installed-name) gr$(start-installed-name)
|
|
Packit |
6c4009 |
install-lib += r$(start-installed-name) gr$(start-installed-name)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
before-compile += $(objpfx)abi-tag.h
|
|
Packit |
6c4009 |
generated += abi-tag.h
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# These are the special initializer/finalizer files. They are always the
|
|
Packit |
6c4009 |
# first and last file in the link. crti.o ... crtn.o define the global
|
|
Packit |
6c4009 |
# "functions" _init and _fini to run the .init and .fini sections.
|
|
Packit |
6c4009 |
crtstuff = crti crtn
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
install-lib += $(crtstuff:=.o)
|
|
Packit |
6c4009 |
extra-objs += $(crtstuff:=.o)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq ($(multidir),.)
|
|
Packit |
6c4009 |
multilib-extra-objs = $(addprefix $(multidir)/, $(install-lib))
|
|
Packit |
6c4009 |
extra-objs += $(multilib-extra-objs)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
extra-objs += abi-note.o init.o static-reloc.o
|
|
Packit |
6c4009 |
ifeq (yes,$(build-shared))
|
|
Packit |
6c4009 |
extra-objs += static-reloc.os
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
asm-CPPFLAGS += -I$(objpfx).
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Enable unwinding so backtrace unwinds to __libc_start_main
|
|
Packit |
6c4009 |
CFLAGS-libc-start.c += -funwind-tables
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
include ../Rules
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Make these in the lib pass so they're available in time to link things with.
|
|
Packit |
6c4009 |
subdir_lib: $(extra-objs:%=$(objpfx)%)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
define link-relocatable
|
|
Packit |
6c4009 |
$(CC) -nostdlib -nostartfiles -r -o $@ $^
|
|
Packit |
6c4009 |
endef
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifndef start-installed-name-rule
|
|
Packit |
6c4009 |
# We link the ELF startfile along with a SHT_NOTE section indicating
|
|
Packit |
6c4009 |
# the kernel ABI the binaries linked with this library will require.
|
|
Packit |
6c4009 |
$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
|
|
Packit |
6c4009 |
$(objpfx)init.o $(objpfx)static-reloc.o
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
$(objpfx)r$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
|
|
Packit |
6c4009 |
$(objpfx)init.o
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
$(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \
|
|
Packit |
6c4009 |
$(objpfx)init.o
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The profiling startfile is made by linking together the normal
|
|
Packit |
6c4009 |
# startfile with gmon-start.o, which defines a constructor function
|
|
Packit |
6c4009 |
# to turn on profiling code at startup.
|
|
Packit |
6c4009 |
ifeq (yes,$(build-shared))
|
|
Packit |
6c4009 |
$(objpfx)g$(start-installed-name): \
|
|
Packit |
6c4009 |
$(objpfx)g%: $(objpfx)S% $(objpfx)gmon-start.os $(objpfx)static-reloc.os
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
$(objpfx)gr$(start-installed-name): \
|
|
Packit |
6c4009 |
$(objpfx)gr%: $(objpfx)r% $(objpfx)gmon-start.o
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
ifneq ($(start-installed-name),$(static-start-installed-name))
|
|
Packit |
6c4009 |
$(objpfx)g$(static-start-installed-name): \
|
|
Packit |
6c4009 |
$(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(sort g$(start-installed-name) \
|
|
Packit |
6c4009 |
g$(static-start-installed-name))): \
|
|
Packit |
6c4009 |
$(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
|
|
Packit |
6c4009 |
$(link-relocatable)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# These extra files are sometimes expected by system standard linking
|
|
Packit |
6c4009 |
# procedures, but we have nothing for them to do. So compile empty files.
|
|
Packit |
6c4009 |
$(addprefix $(objpfx),$(filter-out $(start-installed-name), $(csu-dummies))):\
|
|
Packit |
6c4009 |
$(before-compile)
|
|
Packit |
6c4009 |
$(COMPILE.c) -o $@ -x c /dev/null
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# These headers are used by the startup code.
|
|
Packit |
6c4009 |
$(objpfx)abi-tag.h: $(..)abi-tags
|
|
Packit |
6c4009 |
$(make-target-directory)
|
|
Packit |
6c4009 |
rm -f $@.new
|
|
Packit |
6c4009 |
sed -e 's/#.*$$//' -e '/^[ ]*$$/d' $< | \
|
|
Packit |
6c4009 |
while read conf tagos tagver; do \
|
|
Packit |
6c4009 |
test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
|
|
Packit |
6c4009 |
: "$$conf"` != 0 || continue; \
|
|
Packit |
6c4009 |
( echo "$$tagos" | \
|
|
Packit |
6c4009 |
sed -e 's/[^0-9xXa-fA-F ]//' \
|
|
Packit |
6c4009 |
-e 's/^/#define __ABI_TAG_OS /'; \
|
|
Packit |
6c4009 |
echo "#ifndef __ABI_TAG_VERSION"; \
|
|
Packit |
6c4009 |
echo "$$tagver" | \
|
|
Packit |
6c4009 |
sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \
|
|
Packit |
6c4009 |
-e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \
|
|
Packit |
6c4009 |
echo "#endif" ) > $@.new; \
|
|
Packit |
6c4009 |
done
|
|
Packit |
6c4009 |
if test -r $@.new; then mv -f $@.new $@; \
|
|
Packit |
6c4009 |
else echo >&2 'This configuration not matched in $<'; exit 1; fi
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq ($(multidir),.)
|
|
Packit |
6c4009 |
$(addprefix $(objpfx)$(multidir)/, $(install-lib)): $(addprefix $(objpfx), $(install-lib))
|
|
Packit |
6c4009 |
$(make-link-multidir)
|
|
Packit |
6c4009 |
endif
|