History log of /freebsd-current/lib/csu/amd64/Makefile
Revision Date Author Comments
# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# c969310c 29-Jun-2023 Dmitry Chagin <dchagin@FreeBSD.org>

csu: Implement _start using as to satisfy unwinders on x86_64

The right unwinding stop indicator should be CFI-undefined PC.
https://dwarfstd.org/doc/Dwarf3.pdf - page 118:
If a Return Address register is defined in the virtual unwind table,
and its rule is undefined (for example, by DW_CFA_undefined), then
there is no return address and no call address, and the virtual
unwind of stack activations is complete.

This requires the crt code be built with unwind tables, for that remove
-fno-asynchronous-unwind-tables to enable unwind tables generation.

PR: 241562, 246322, 246537
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40780


# 51015e6d 30-Oct-2022 Konstantin Belousov <kib@FreeBSD.org>

csu: move common code to libc

Why? Most trivial point, it shaves around 600 bytes from the dynamic
binaries on amd64. Less trivial, the removed code is no longer part of
the ABI, and we can ship updates to it with libc updates. Right now most
of the csu is linked into the binaries and require us to do somewhat
tricky ABI compat when it needs to change. For instance, the init_array
change would be much simpler and does not require note tagging if we
have init calling code in libc.

This could be improved more, by splitting dynamic and static
initialization. For instance, &_DYNAMIC tests can be removed then.
Such change, nonetheless, would require building libc three times.
I left this for later, after this change stabilizes, if ever.

Reviewed by: markj
Discussed with: jrtc27 (some objections, see the review), imp
Tested by: markj (aarch64)
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D37220


# b0ee263d 02-Jul-2020 John Baldwin <jhb@FreeBSD.org>

Consolidate duplicated logic in csu Makefiles to lib/csu/Makefile.inc.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25537


# 99282790 15-Jun-2020 John Baldwin <jhb@FreeBSD.org>

Remove the sed hack for ABI tag notes.

The ELF notes compiled in C were placed in a section with the wrong type
(SHT_PROGBITS instead of SHT_NOTE). Previously, sed was used on the
generated assembly to rewrite the section type. Instead, write the notes
in assembly which permits setting the correct section type directly.

While here, move inline assembly entry points out of C and into assembly
for aarch64, arm, and riscv.

Reviewed by: kib
Tested on: amd64 (cirrus-ci), riscv64
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25211


# bdafb02f 13-Oct-2018 Konstantin Belousov <kib@FreeBSD.org>

Process irelocs for statically linked binaries from crt1 on x86.

This makes statically linked binaries with ifuncs operational.

Reported and tested by: mjg
Reviewed by: emaste, markj
Sponsored by: The FreeBSD Foundation
Approved by: re (rgrimes)
Differential revision: https://reviews.freebsd.org/D17363


# 5944f899 07-Apr-2017 John Baldwin <jhb@FreeBSD.org>

Rework r234502 to include a modified CFLAGS along with ACFLAGS.

On most architectures crt objects are compiled in a multiple-step process
so that sed can be run on the generated assembly. As the final step,
the C compiler generates an object file from the modified assembly output.
Currently this last step uses $CC with only $ACFLAGS. However, for other
uses in the tree, $ACFLAGS is meant to include assembly-specific compiler
flags that are in addition to $CFLAGS (see default .S.o rules
bsd.suffixes.mk). In particular, external toolchains may require
additional flags to select a non-default target which will be present
in CFLAGS but not ACFLAGS. To support this while still mitigating the
issue with CFLAGS described in r234502, include a modified CFLAGS that
excludes "-g" when assembling the modified assembly files.

Note that normally an assembler ($AS) is used to assemble .s flags to
object files (see bsd.suffixes.mk). However, llvm-based toolchains do
not currently have a stand-alone assembler.

Reviewed by: imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085


# 23f6875a 19-Jan-2017 Enji Cooper <ngie@FreeBSD.org>

Use SRCTOP-relative paths and .CURDIR with :H instead of ".." specified paths

This implifies pathing in make/displayed output

MFC after: 3 weeks
Sponsored by: Dell EMC Isilon


# 7c6cc9de 21-Sep-2015 Bryan Drewery <bdrewery@FreeBSD.org>

Fix installation of 32bit libraries after r288074.

FILES is not used when LIBRARIES_ONLY is set, which is used to build and
install the lib32 sysroot. All of the csu files do quality as "libraries"
for this case so just undefine LIBRARIES_ONLY.

This is still better than the previous realinstall handling as it does
not hook into META_MODE properly.

Sponsored by: EMC / Isilon Storage Division


# 5ca34122 21-Sep-2015 Bryan Drewery <bdrewery@FreeBSD.org>

Replace realinstall: and META_MODE staging hacks with FILES mechanism.

This partially reverts r270170 for lib/csu/i386 while retaining the
change for using bsd.lib.mk.

These FILES groups could go into lib/csu/Makefile.inc but I've kept them
in the Makefiles for clarity.

Sponsored by: EMC / Isilon Storage Division


# 6e7d005c 30-Nov-2014 Simon J. Gerraty <sjg@FreeBSD.org>

Put lib/csu/amd64/Makefile back the way it is in head
and handle staging via ../Makefile.inc


# 5608fd23 19-Aug-2014 Bryan Drewery <bdrewery@FreeBSD.org>

Revert r267233 for now. PIE support needs to be reworked.

1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other
build-only utility libraries.
2. Another 40% is fixed by generating _pic.a variants of various libraries.
3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR)
where it never would work anyhow, such as csu or loader. This suggests
there may be better ways of adding support to the tree. Many of these
cases can be fixed such that -fPIE will work but there is really no
reason to have it in those cases.
4. Some of the uses are working around hacks done to some Makefiles that are
really building libraries but have been using bsd.prog.mk because the code
is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have
been needed.

We likely do want to enable PIE by default (opt-out) for non-tree consumers
(such as ports). For in-tree though we probably want to only enable PIE
(opt-in) for common attack targets such as remote service daemons and setuid
utilities. This is also a great performance compromise since ASLR is expected
to reduce performance. As such it does not make sense to enable it in all
utilities such as ls(1) that have little benefit to having it enabled.

Reported by: kib


# 864c53ea 08-Jun-2014 Bryan Drewery <bdrewery@FreeBSD.org>

In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.

This is currently an opt-in build flag. Once ASLR support is ready and stable
it should changed to opt-out and be enabled by default along with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will be enabled by
default in new directories when the system is compiled with PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

The only known runtime failure was rtld.

[1] http://www.bsdcan.org/2014/schedule/events/452.en.html
Submitted by: Shawn Webb <lattera@gmail.com>
Discussed between: des@ and Shawn Webb [2]


# d2cc835c 20-Apr-2012 Dimitry Andric <dim@FreeBSD.org>

After r217375, some startup objects under lib/csu are built in a special
way: first they are compiled to assembly, then some sed'ing is done on
the assembly, and lastly the assembly is compiled to an object file.

This last step is done using ${CC}, and not ${AS}, because when the
compiler is clang, it outputs directives that are too advanced for our
old gas. So we use clang's integrated assembler instead. (When the
compiler is gcc, it just calls gas, and nothing is different, except one
extra fork.)

However, in the .s to .o rules in lib/csu/$ARCH/Makefile, I still passed
CFLAGS to the compiler, instead of ACFLAGS, which are specifically for
compiling .s files.

In case you are using '-g' for debug info anywhere in your CFLAGS, it
causes the .s files to already contain debug information in the assembly
itself. In the next step, the .s files are also compiled using '-g',
and if the compiler is clang, it complains: "error: input can't have
.file dwarf directives when -g is used to generate dwarf debug info for
assembly code".

Fix this by using ${ACFLAGS} for compiling the .s files instead.

Reported by: jasone
MFC after: 1 week


# a22748db 11-Mar-2012 Konstantin Belousov <kib@FreeBSD.org>

Stop calling _init/_fini methods from crt1 for dynamic binaries. Do
call preinit, init and fini arrays methods from crt1 for static binaries.

Mark new crt1 with FreeBSD-specific ELF note.

Move some common crt1 code into new MI file ignore_init.c, to reduce
duplication. Also, conservatively adjust nearby sources for style.

Reviewed by: kan
Tested by: andrew (arm), flo (sparc64)
MFC after: 3 weeks


# 9ef4e3af 13-Jan-2011 Dimitry Andric <dim@FreeBSD.org>

Apply a workaround for a binutils issue with the .note.ABI-tag section
generated from lib/csu/common/crtbrand.c (which ultimately ends up in
executables and shared libraries, via crt1.o, gcrt1.o or Scrt1.o).

For all arches except sparc, gcc emits the section directive for the
abitag struct in crtbrand.c with a PROGBITS type. However, newer
versions of binutils (after 2.16.90) require the section to be of NOTE
type, to guarantee that the .note.ABI-tag section correctly ends up in
the first page of the final executable.

Unfortunately, there is no clean way to tell gcc to use another section
type, so crtbrand.c (or the C files that include it) must be compiled in
multiple steps:

- Compile the .c file to a .s file.
- Edit the .s file to change the 'progbits' type to 'note', for the section
directive that defines the .note.ABI-tag section.
- Compile the .s file to an object file.

These steps are done in the invididual Makefiles for each applicable arch.

Reviewed by: kib


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 5300f787 27-Dec-2009 Konstantin Belousov <kib@FreeBSD.org>

MFC r200038:
Properly support -fPIE by linking PIE binaries with specially-built
Scrt1.o instead of crt1.o, since the later is built as non-PIC.

Separate i386-elf crt1.c into the pure assembler part and C code,
supplying all data extracted by assembler stub as explicit parameters.
Hide and localize _start1 symbol used as an interface between asm and
C code.


# c09ba327 02-Dec-2009 Konstantin Belousov <kib@FreeBSD.org>

Properly support -fPIE by linking PIE binaries with specially-built
Scrt1.o instead of crt1.o, since the later is built as non-PIC.

Separate i386-elf crt1.c into the pure assembler part and C code,
supplying all data extracted by assembler stub as explicit parameters [1].
Hide and localize _start1 symbol used as an interface between asm and
C code.

In collaboration with: kan
Inspired by: PR i386/127387 [1]
Prodded and tested by: rdivacky [1]
MFC after: 3 weeks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# af8d325c 22-Aug-2008 Konstantin Belousov <kib@FreeBSD.org>

Add -fno-omit-frame-pointer to CFLAGS used to compile crt1.c on amd64.

For gcc' __builtin_frame_address() to work, all call frames need to save
frame pointer. In particular, this is important for the upper frame that
should terminate the chain.

No objections from: jhb
PR: amd64/126543
MFC after: 1 week


# 6de4623b 29-Jun-2003 Ruslan Ermilov <ru@FreeBSD.org>

MFi386: revision 1.19.


# d2893b16 29-Jul-2002 Ruslan Ermilov <ru@FreeBSD.org>

Drop support for COPY, -c has been the default mode of install(1)
for a long time now.

Approved by: bde


# 20200638 13-May-2002 Ruslan Ermilov <ru@FreeBSD.org>

Fixed CLEANFILES after bsd.lib.mk sweep.


# 7893b524 13-May-2002 Ruslan Ermilov <ru@FreeBSD.org>

SOBJS are not used here for a long time, and were just
pessimising the `install'.


# 2a53f3fb 13-May-2002 Ruslan Ermilov <ru@FreeBSD.org>

Major cleanup of bsd.lib.mk.

Get rid of the INTERNALSTATICLIB knob and just use plain INTERNALLIB.
INTERNALLIB now means to build static library only and don't install
anything. Added a NOINSTALLLIB knob for libpam/modules. To not
build any library at all, just do not set LIB.


# 5b8f41af 12-May-2002 Ruslan Ermilov <ru@FreeBSD.org>

Revert the last change. The corresponding bsd.lib.mk changes were
already backed out.


# 785b36d4 11-May-2002 David E. O'Brien <obrien@FreeBSD.org>

Use the simpler NOMAN rather than NOMAN, NOPIC, NOPROFILE, INTERNALLIB.


# ccc4300e 29-Apr-2002 Bruce Evans <bde@FreeBSD.org>

Removed "-fkeep-inline-functions" from CFLAGS, since it now has no effect
except to generate spurious warnings about a system header <sys/param.h>
having some inline functions (the bswap family). This backs out the main
part of rev.1.5 (which was the only part left). The problem fixed by
rev.1.5 of the Makefile went away in rev.1.5 of ../common/crtbegin.c
when the references to do_ctors() and do_dtors() in the latter were moved
from inline asm to C code.

This leaves the problem that implementation details cause warnings.

Discussed with: jdp


# 4cd01193 29-Mar-2002 Mark Murray <markm@FreeBSD.org>

Do not use __progname directly (except in [gs]etprogname(3)).
Also, make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.


# 41513796 27-Oct-2001 David E. O'Brien <obrien@FreeBSD.org>

minor style updating


# ae7c8a2b 28-Oct-2000 David E. O'Brien <obrien@FreeBSD.org>

* Bring back the guts of crt{i,n}.S. This allows C++ exceptions to work
when using the egcs and gcc-devel ports, along with GCC built from stock
public FSF sources. With out this change, FreeBSD will be removed from
the list of systems GCC 3.0 must be evaluated on before release. With
the effort some of us put into getting FreeBSD on this list, we should
not turn this effort into a waste, else we might not be worth fighting
for in the future. (note that Alpha and IA-64 versions of crt{i,n}.S
are needed)

* Switch from our own crt{begin,in} to those created from GCC's crtstuff.c.
This will allow us to switch to DWARF2 exceptions in the future, along with
staying in sync with any future GCC requirements.

* Break out our ELF branding bits into a seperate file. Currently this
is now included by our crt1.c files (since this functionality was part of
our native crtbegin.c). Later crtbrand.o will be merged in the creation
of crti.o.


# bb63c9d3 20-May-2000 John Polstra <jdp@FreeBSD.org>

Take crtbegin.c and crtend.c from the new machine-independent
"common" sister directory.


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# c30965b3 15-Mar-1999 John Polstra <jdp@FreeBSD.org>

Add "-fkeep-inline-functions" to CFLAGS so that higher optimization
levels (-O3 and above) won't remove essential code. Many thanks
to Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru> for pointing out
that it was the optimizer's removal of this code that caused make
world with -O3 to break. With this change, make buildworld now
completes.


# bb2b8691 12-Mar-1999 John Polstra <jdp@FreeBSD.org>

Move the code for the ".init" and ".fini" sections outside of a
C function so the compiler won't try to emit line numbers for it
with "-g", breaking the build. This has the nice side-effect of
making crtbegin.o and crtbeginS.o a little bit smaller.

Remove "-Wno-unused" from the Makefile. Replace it with "__unused"
on particular function and variable declarations.


# f92bdbd0 09-Jan-1999 John Polstra <jdp@FreeBSD.org>

Switch to using ".So" as the extension for PIC object files rather
than ".so". The old extension conflicted with well-established
naming conventions for dynamically loadable modules.

The "clean" targets continue to remove ".so" files too, to deal with
old systems.


# 5584f22b 07-Sep-1998 John Polstra <jdp@FreeBSD.org>

Make profiling work for ELF. gprof now autodetects the format of
the executable file, so it will work for both a.out and ELF format
files. I have split the object format specific code into separate
source files. It's cleaner than it was before, but it's still
pretty crufty.

Don't cheat on your make world for this update. A lot of things
have to be rebuilt for it to work, including the compiler and all
of the profiled libraries.


# 966a88d9 07-Mar-1998 John Polstra <jdp@FreeBSD.org>

Import C startup files for ELF support.

Submitted by: John Polstra <jdp@polstra.com>