head	1.15;
access;
symbols
	netbsd-11-0-RC5:1.12
	netbsd-11-0-RC4:1.12
	netbsd-11-0-RC3:1.12
	netbsd-11-0-RC2:1.12
	netbsd-11-0-RC1:1.12
	perseant-exfatfs-base-20250801:1.12
	netbsd-11:1.12.0.2
	netbsd-11-base:1.12
	netbsd-10-1-RELEASE:1.7
	perseant-exfatfs-base-20240630:1.7
	perseant-exfatfs:1.7.0.12
	perseant-exfatfs-base:1.7
	netbsd-8-3-RELEASE:1.5
	netbsd-9-4-RELEASE:1.7
	netbsd-10-0-RELEASE:1.7
	netbsd-10-0-RC6:1.7
	netbsd-10-0-RC5:1.7
	netbsd-10-0-RC4:1.7
	netbsd-10-0-RC3:1.7
	netbsd-10-0-RC2:1.7
	netbsd-10-0-RC1:1.7
	netbsd-10:1.7.0.10
	netbsd-10-base:1.7
	netbsd-9-3-RELEASE:1.7
	cjep_sun2x-base1:1.7
	cjep_sun2x:1.7.0.8
	cjep_sun2x-base:1.7
	cjep_staticlib_x-base1:1.7
	netbsd-9-2-RELEASE:1.7
	cjep_staticlib_x:1.7.0.6
	cjep_staticlib_x-base:1.7
	netbsd-9-1-RELEASE:1.7
	phil-wifi-20200421:1.7
	phil-wifi-20200411:1.7
	is-mlppp:1.7.0.4
	is-mlppp-base:1.7
	phil-wifi-20200406:1.7
	netbsd-8-2-RELEASE:1.5
	netbsd-9-0-RELEASE:1.7
	netbsd-9-0-RC2:1.7
	netbsd-9-0-RC1:1.7
	phil-wifi-20191119:1.7
	netbsd-9:1.7.0.2
	netbsd-9-base:1.7
	phil-wifi-20190609:1.7
	netbsd-8-1-RELEASE:1.5
	netbsd-8-1-RC1:1.5
	pgoyette-compat-merge-20190127:1.5.14.2
	pgoyette-compat-20190127:1.7
	pgoyette-compat-20190118:1.7
	pgoyette-compat-1226:1.6
	pgoyette-compat-1126:1.6
	pgoyette-compat-1020:1.6
	pgoyette-compat-0930:1.6
	pgoyette-compat-0906:1.6
	netbsd-7-2-RELEASE:1.4
	pgoyette-compat-0728:1.6
	netbsd-8-0-RELEASE:1.5
	phil-wifi:1.6.0.2
	phil-wifi-base:1.6
	pgoyette-compat-0625:1.6
	netbsd-8-0-RC2:1.5
	pgoyette-compat-0521:1.6
	pgoyette-compat-0502:1.6
	pgoyette-compat-0422:1.6
	netbsd-8-0-RC1:1.5
	pgoyette-compat-0415:1.6
	pgoyette-compat-0407:1.6
	pgoyette-compat-0330:1.6
	pgoyette-compat-0322:1.6
	pgoyette-compat-0315:1.6
	netbsd-7-1-2-RELEASE:1.4
	pgoyette-compat:1.5.0.14
	pgoyette-compat-base:1.5
	netbsd-7-1-1-RELEASE:1.4
	matt-nb8-mediatek:1.5.0.12
	matt-nb8-mediatek-base:1.5
	perseant-stdc-iso10646:1.5.0.10
	perseant-stdc-iso10646-base:1.5
	netbsd-8:1.5.0.8
	netbsd-8-base:1.5
	prg-localcount2-base3:1.5
	prg-localcount2-base2:1.5
	prg-localcount2-base1:1.5
	prg-localcount2:1.5.0.6
	prg-localcount2-base:1.5
	pgoyette-localcount-20170426:1.5
	bouyer-socketcan-base1:1.5
	pgoyette-localcount-20170320:1.5
	netbsd-7-1:1.4.0.30
	netbsd-7-1-RELEASE:1.4
	netbsd-7-1-RC2:1.4
	netbsd-7-nhusb-base-20170116:1.4
	bouyer-socketcan:1.5.0.4
	bouyer-socketcan-base:1.5
	pgoyette-localcount-20170107:1.5
	netbsd-7-1-RC1:1.4
	pgoyette-localcount-20161104:1.5
	netbsd-7-0-2-RELEASE:1.4
	localcount-20160914:1.5
	netbsd-7-nhusb:1.4.0.28
	netbsd-7-nhusb-base:1.4
	pgoyette-localcount-20160806:1.5
	pgoyette-localcount-20160726:1.5
	pgoyette-localcount:1.5.0.2
	pgoyette-localcount-base:1.5
	netbsd-7-0-1-RELEASE:1.4
	netbsd-7-0:1.4.0.26
	netbsd-7-0-RELEASE:1.4
	netbsd-7-0-RC3:1.4
	netbsd-7-0-RC2:1.4
	netbsd-7-0-RC1:1.4
	netbsd-6-0-6-RELEASE:1.4
	netbsd-6-1-5-RELEASE:1.4
	netbsd-7:1.4.0.24
	netbsd-7-base:1.4
	yamt-pagecache-base9:1.4
	yamt-pagecache-tag8:1.4
	netbsd-6-1-4-RELEASE:1.4
	netbsd-6-0-5-RELEASE:1.4
	tls-earlyentropy:1.4.0.22
	tls-earlyentropy-base:1.4
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.4
	riastradh-drm2-base3:1.4
	netbsd-6-1-3-RELEASE:1.4
	netbsd-6-0-4-RELEASE:1.4
	netbsd-6-1-2-RELEASE:1.4
	netbsd-6-0-3-RELEASE:1.4
	netbsd-6-1-1-RELEASE:1.4
	riastradh-drm2-base2:1.4
	riastradh-drm2-base1:1.4
	riastradh-drm2:1.4.0.16
	riastradh-drm2-base:1.4
	netbsd-6-1:1.4.0.20
	netbsd-6-0-2-RELEASE:1.4
	netbsd-6-1-RELEASE:1.4
	netbsd-6-1-RC4:1.4
	netbsd-6-1-RC3:1.4
	agc-symver:1.4.0.18
	agc-symver-base:1.4
	netbsd-6-1-RC2:1.4
	netbsd-6-1-RC1:1.4
	yamt-pagecache-base8:1.4
	netbsd-6-0-1-RELEASE:1.4
	yamt-pagecache-base7:1.4
	matt-nb6-plus-nbase:1.4
	yamt-pagecache-base6:1.4
	netbsd-6-0:1.4.0.14
	netbsd-6-0-RELEASE:1.4
	netbsd-6-0-RC2:1.4
	tls-maxphys:1.4.0.12
	tls-maxphys-base:1.4
	matt-nb6-plus:1.4.0.10
	matt-nb6-plus-base:1.4
	netbsd-6-0-RC1:1.4
	yamt-pagecache-base5:1.4
	yamt-pagecache-base4:1.4
	netbsd-6:1.4.0.8
	netbsd-6-base:1.4
	yamt-pagecache-base3:1.4
	yamt-pagecache-base2:1.4
	yamt-pagecache:1.4.0.6
	yamt-pagecache-base:1.4
	cherry-xenmp:1.4.0.4
	cherry-xenmp-base:1.4
	bouyer-quota2-nbase:1.4
	bouyer-quota2:1.4.0.2
	bouyer-quota2-base:1.4
	matt-mips64-premerge-20101231:1.4;
locks; strict;
comment	@# @;


1.15
date	2026.02.10.07.28.24;	author skrll;	state Exp;
branches;
next	1.14;
commitid	GVekIEnLauEhJNtG;

1.14
date	2025.12.17.23.43.52;	author riastradh;	state Exp;
branches;
next	1.13;
commitid	vjEDN8j7We0ATOmG;

1.13
date	2025.12.17.20.05.43;	author riastradh;	state Exp;
branches;
next	1.12;
commitid	IFCbVzSWFueKGNmG;

1.12
date	2025.06.10.14.30.44;	author christos;	state Exp;
branches;
next	1.11;
commitid	12SLgEyiK1KpWlYF;

1.11
date	2025.06.08.16.55.04;	author christos;	state Exp;
branches;
next	1.10;
commitid	NjYjvw68up2ON6YF;

1.10
date	2025.05.02.22.30.29;	author riastradh;	state Exp;
branches;
next	1.9;
commitid	kUY3BnQgZpLLQnTF;

1.9
date	2025.04.27.14.04.19;	author riastradh;	state Exp;
branches;
next	1.8;
commitid	ODA1FY6Hi1q6dHSF;

1.8
date	2025.04.27.04.09.35;	author riastradh;	state Exp;
branches;
next	1.7;
commitid	3m7Siprbfy3ZUDSF;

1.7
date	2018.12.27.19.33.52;	author christos;	state Exp;
branches
	1.7.12.1;
next	1.6;
commitid	8oRS970YLNzxnt5B;

1.6
date	2018.03.09.20.20.47;	author joerg;	state Exp;
branches
	1.6.2.1;
next	1.5;
commitid	RJAYMWcKMqoD3PtA;

1.5
date	2016.04.04.09.52.02;	author joerg;	state Exp;
branches
	1.5.14.1;
next	1.4;
commitid	CfaRTPAoqZI1di1z;

1.4
date	2011.01.02.09.33.45;	author skrll;	state Exp;
branches;
next	1.3;

1.3
date	2010.11.30.18.38.53;	author joerg;	state Exp;
branches;
next	1.2;

1.2
date	2010.07.28.13.51.38;	author joerg;	state Exp;
branches;
next	1.1;

1.1
date	2010.07.17.19.25.27;	author jmmv;	state Exp;
branches;
next	;

1.7.12.1
date	2025.08.02.05.58.03;	author perseant;	state Exp;
branches;
next	;
commitid	23j6GFaDws3O875G;

1.6.2.1
date	2019.06.10.22.10.02;	author christos;	state Exp;
branches;
next	;
commitid	jtc8rnCzWiEEHGqB;

1.5.14.1
date	2018.03.15.09.12.07;	author pgoyette;	state Exp;
branches;
next	1.5.14.2;
commitid	lb7w3QtkrVH4axuA;

1.5.14.2
date	2019.01.18.08.51.00;	author pgoyette;	state Exp;
branches;
next	;
commitid	Lmlzg3OVT2cd6f8B;


desc
@@


1.15
log
@Add a preinit_array test
@
text
@# $NetBSD: Makefile,v 1.14 2025/12/17 23:43:52 riastradh Exp $

NOMAN=			# defined

.include <bsd.own.mk>

TESTSDIR=		${TESTSBASE}/lib/csu
TESTS_SH=		t_crt0 t_ifunc_static
TESTS_SUBDIRS=
SUBDIR+=		dso

.include "Makefile.check_stack"

CPPFLAGS+=		${CPPFLAGS_CHECK_STACK}

BINDIR=			${TESTSDIR}
PROGS_CXX=		h_initfini1 h_initfini2 h_initfini3
SRCS.h_initfini1=	h_initfini1.cxx h_initfini_common.cxx \
			${SRCS_CHECK_STACK}
SRCS.h_initfini2=	h_initfini1.cxx h_initfini_common.cxx \
			${SRCS_CHECK_STACK}
LDSTATIC.h_initfini2+=	-static
SRCS.h_initfini3=	h_initfini3.cxx h_initfini_common.cxx \
			${SRCS_CHECK_STACK}
LDADD.h_initfini3+=	-Wl,-rpath,${TESTSDIR}

PROGS+=			h_ifunc_static h_initfini_array h_preinit_array
SRCS.h_ifunc_static=	h_ifunc_static.c
SRCS.h_initfini_array=	h_initfini_array.c
SRCS.h_preinit_array=	h_preinit_array.c
LDSTATIC.h_ifunc_static=-static

TESTS_SH+=		t_hello

PROGS+=		${"${MKPIC}" != no:?h_hello_dyn:}
PROGS+=		${"${MKPIE}" != no:?h_hello_dynpie:}
PROGS+=		${"${MKPIE}" != no:?h_hello_relr:}
PROGS+=		h_hello_sta
PROGS+=		${"${MKPIE}" != no:?h_hello_stapie:}

h_hello_relr: CTFMERGE=:	# PR toolchain/59364: ctf tools needs update
h_hello_relr.link: CTFMERGE=:	# PR toolchain/59364: ctf tools needs update

SRCS.h_hello_dyn+=		h_hello.c
SRCS.h_hello_dynpie+=		h_hello.c
SRCS.h_hello_relr+=		h_hello.c
SRCS.h_hello_sta+=		h_hello.c
SRCS.h_hello_stapie+=		h_hello.c
COPTS.h_hello.c+=		${"${MKPIE}" != no:?-fPIE:}
LDFLAGS.h_hello_dyn=		-no-pie
LDFLAGS.h_hello_dynpie=		-pie
LDFLAGS.h_hello_relr=		-pie ${LD_PACK_RELATIVE_RELOCS}
LDFLAGS.h_hello_sta=		-no-pie
LDFLAGS.h_hello_stapie=		-pie ${LD_NOPACK_RELATIVE_RELOCS}
LDSTATIC.h_hello_relr=		-static
LDSTATIC.h_hello_sta=		-static
LDSTATIC.h_hello_stapie=	-static

.include <bsd.test.mk>
@


1.14
log
@tests/lib/csu, tests/libexec/ld.elf_so: Apply CTFMERGE=: workaround.

The workaround for

PR toolchain/59364: ctf tools needs update

required an update after fixing

PR toolchain/57241: mips64el--netbsd-install core dumps randomly

by splitting the recipes for ${PROG} and ${PROG}.debug into an
intermediate ${PROG}.link to avoid overwriting ${PROG} inside the
recipe for ${PROG}.debug.

This is kludgey (writing the `.link' suffix into a Makefile isn't
great) but I see only two cases of it so this'll do for now.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.13 2025/12/17 20:05:43 riastradh Exp $
d27 1
a27 1
PROGS+=			h_ifunc_static h_initfini_array
d30 1
@


1.13
log
@tests/lib/csu/Makefile: Use PROGS_CXX, not PROG_CXX.

There are multiple programs here.

Should fix:

nbmake: /home/riastradh/netbsd/current/src/share/mk/bsd.prog.mk:624: warning: Invalid character " " in variable name "OBJS.h_initfini1 h_initfini2 h_initfini3"
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.12 2025/06/10 14:30:44 christos Exp $
d41 1
@


1.12
log
@centralize pack-relative-relocs handling
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.11 2025/06/08 16:55:04 christos Exp $
d17 1
a17 1
PROG_CXX=		h_initfini1 h_initfini2 h_initfini3
@


1.11
log
@Fix the clang build which complains about pack-relative-relocs ignored.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.10 2025/05/02 22:30:29 riastradh Exp $
a41 9
# relative relocs are only supported in gnu ld for ppc64 and x86
.if ${MACHINE_ARCH} == "x86_64" || \
    ${MACHINE_ARCH} == "i386"  || \
    ${MACHINE_ARCH} == "powerpc64"
PACK_RELATIVE_RELOCS=-Wl,-z,pack-relative-relocs
NOPACK_RELATIVE_RELOCS=-Wl,-z,nopack-relative-relocs
.endif


d50 1
a50 1
LDFLAGS.h_hello_relr=		-pie ${PACK_RELATIVE_RELOCS}
d52 1
a52 1
LDFLAGS.h_hello_stapie=		-pie ${NOPACK_RELATIVE_RELOCS}
@


1.10
log
@lib/csu: Test a static PIE with RELR relocations.

PR bin/59360: ld.elf_so(8): missing RELR support
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.9 2025/04/27 14:04:19 riastradh Exp $
d42 9
d59 1
a59 1
LDFLAGS.h_hello_relr=		-pie -Wl,-z,pack-relative-relocs
d61 1
a61 1
LDFLAGS.h_hello_stapie=		-pie -Wl,-z,nopack-relative-relocs
@


1.9
log
@tests/lib/csu: Build h_hello.o with -fPIE, not -fpie.

Static libraries like libc may overflow the bounds assumed by -fpie.
Resolves:

h_hello.o: in function `main':
h_hello.c:(.text.startup+0x30): relocation truncated to fit: R_SPARC_GOT13 against symbol `__sF' defined in .data.rel section in /tmp/build/2025.04.27.10.22.23-sparc64/destdir/usr/lib/libc.a(findfp.o)

PR lib/59359: static pies are broken
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.8 2025/04/27 04:09:35 riastradh Exp $
d36 1
d40 2
d44 1
d50 1
d52 2
a53 1
LDFLAGS.h_hello_stapie=		-pie
@


1.8
log
@lib/csu: Add tests of {static, dynamic} x {pie, non-pie}.

Main goal here is to test static pies, but let's take advantage of
this to test the same code several ways, since the csu logic has some
differences for static vs dynamic builds too like the ordering of
_libc_init calls.

PR lib/59359: static pies are broken
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.7 2018/12/27 19:33:52 christos Exp $
d43 1
a43 1
COPTS.h_hello.c+=		${"${MKPIE}" != no:?-fpie:}
@


1.7
log
@Add an initfini_array test that does not depend on the linker putting it
there automatically.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.6 2018/03/09 20:20:47 joerg Exp $
d32 19
@


1.7.12.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.12 2025/06/10 14:30:44 christos Exp $
a31 25
TESTS_SH+=		t_hello

PROGS+=		${"${MKPIC}" != no:?h_hello_dyn:}
PROGS+=		${"${MKPIE}" != no:?h_hello_dynpie:}
PROGS+=		${"${MKPIE}" != no:?h_hello_relr:}
PROGS+=		h_hello_sta
PROGS+=		${"${MKPIE}" != no:?h_hello_stapie:}

h_hello_relr: CTFMERGE=:	# PR toolchain/59364: ctf tools needs update

SRCS.h_hello_dyn+=		h_hello.c
SRCS.h_hello_dynpie+=		h_hello.c
SRCS.h_hello_relr+=		h_hello.c
SRCS.h_hello_sta+=		h_hello.c
SRCS.h_hello_stapie+=		h_hello.c
COPTS.h_hello.c+=		${"${MKPIE}" != no:?-fPIE:}
LDFLAGS.h_hello_dyn=		-no-pie
LDFLAGS.h_hello_dynpie=		-pie
LDFLAGS.h_hello_relr=		-pie ${LD_PACK_RELATIVE_RELOCS}
LDFLAGS.h_hello_sta=		-no-pie
LDFLAGS.h_hello_stapie=		-pie ${LD_NOPACK_RELATIVE_RELOCS}
LDSTATIC.h_hello_relr=		-static
LDSTATIC.h_hello_sta=		-static
LDSTATIC.h_hello_stapie=	-static

@


1.6
log
@Add ifunc support for statically linked applications on x86, ppc, sparc
and ARM.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.5 2016/04/04 09:52:02 joerg Exp $
d27 1
a27 1
PROGS+=			h_ifunc_static
d29 1
@


1.6.2.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.7 2018/12/27 19:33:52 christos Exp $
d27 1
a27 1
PROGS+=			h_ifunc_static h_initfini_array
a28 1
SRCS.h_initfini_array=	h_initfini_array.c
@


1.5
log
@Replace LDADD with LDSTATIC.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.4 2011/01/02 09:33:45 skrll Exp $
d8 1
a8 1
TESTS_SH=		t_crt0
d27 4
@


1.5.14.1
log
@Synch with HEAD
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.6 2018/03/09 20:20:47 joerg Exp $
d8 1
a8 1
TESTS_SH=		t_crt0 t_ifunc_static
a26 4
PROGS+=			h_ifunc_static
SRCS.h_ifunc_static=	h_ifunc_static.c
LDSTATIC.h_ifunc_static=-static

@


1.5.14.2
log
@Synch with HEAD
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.5.14.1 2018/03/15 09:12:07 pgoyette Exp $
d27 1
a27 1
PROGS+=			h_ifunc_static h_initfini_array
a28 1
SRCS.h_initfini_array=	h_initfini_array.c
@


1.4
log
@Whitespace.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.3 2010/11/30 18:38:53 joerg Exp $
d22 1
a22 1
LDADD.h_initfini2+=	-static
@


1.3
log
@Test alignment of constructor / destructor calls as well as the stack
of new threads. Currently implement for i386 and AMD64.
@
text
@d1 1
a1 1
# $NetBSD: src/tests/lib/csu/Makefile,v 1.2 2010-07-28 13:51:38 joerg Exp $
d14 1
a14 1
CPPFLAGS+=	${CPPFLAGS_CHECK_STACK}
@


1.2
log
@Replace csu test case with a C++ based version. This makes the various
assembler routines obsolete. Be more exhaustive by testing dynamically
linked, statically linked and dynamically loaded.

XXX currently hard-codes /usr/tests due to limitations of bsd.test.mk
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.1 2010/07/17 19:25:27 jmmv Exp $
d12 4
d18 4
a21 2
SRCS.h_initfini1=	h_initfini1.cxx h_initfini_common.cxx
SRCS.h_initfini2=	h_initfini1.cxx h_initfini_common.cxx
d23 2
a24 1
SRCS.h_initfini3=	h_initfini3.cxx h_initfini_common.cxx
@


1.1
log
@Convert the csu tests to atf.
Initial work from the GSoC 2008 project by Lukasz Strzygowski.
@
text
@d1 1
a1 1
# $NetBSD$
d3 1
a3 1
NOMAN=		# defined
d7 12
a18 11
TESTSDIR=	${TESTSBASE}/lib/csu

.if exists(arch/${MACHINE_CPU}/initfini_asm.S)
TESTS_SH=	t_crt0

BINDIR=		${TESTSDIR}
PROG=		h_initfini
SRCS=		h_initfini.c initfini_asm.S
WARNS?=		1
.PATH:		${.CURDIR}/arch/${MACHINE_CPU}
.endif
@

