Index: head/lib/csu/Makefile.inc =================================================================== --- head/lib/csu/Makefile.inc (revision 362202) +++ head/lib/csu/Makefile.inc (revision 362203) @@ -1,36 +1,36 @@ # $FreeBSD$ SSP_CFLAGS= -SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/' - NO_WMISSING_VARIABLE_DECLARATIONS= .include .if !defined(BUILDING_TESTS) OBJS+= crtbegin.o crtbeginS.o crtbeginT.o OBJS+= crtend.o crtendS.o + +ACFLAGS+= -DLOCORE CFLAGS+= -fno-asynchronous-unwind-tables CFLAGS+= -fno-omit-frame-pointer CFLAGS_CRTS= -DSHARED ${PICFLAG} crtbegin.o: crtbegin.c crtbeginS.o: crtbegin.c crtbeginT.o: crtbegin.c crtend.o: crtend.c crtendS.o: crtend.c crtbegin.o crtend.o crtbeginT.o: ${CC} ${CFLAGS} -I${.CURDIR} -c -o ${.TARGET} ${.ALLSRC:N*.h:[1]} crtbeginS.o crtendS.o: ${CC} ${CFLAGS} -I${.CURDIR} ${CFLAGS_CRTS} -c -o ${.TARGET} \ ${.ALLSRC:N*.h:[1]} .endif .include "../Makefile.inc" Index: head/lib/csu/aarch64/crt1.c =================================================================== --- head/lib/csu/aarch64/crt1.c (revision 362202) +++ head/lib/csu/aarch64/crt1.c (nonexistent) @@ -1,85 +0,0 @@ -/* LINTLIBRARY */ -/*- - * Copyright 1996-1998 John D. Polstra. - * Copyright 2014 Andrew Turner. - * Copyright 2014-2015 The FreeBSD Foundation. - * All rights reserved. - * - * Portions of this software were developed by Andrew Turner - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -extern long * _end; - -void __start(int, char **, char **, void (*)(void)); - -/* The entry function. */ -__asm(" .text \n" -" .align 0 \n" -" .globl _start \n" -" _start: \n" -" mov x3, x2 \n" /* cleanup */ -" add x1, x0, #8 \n" /* load argv */ -" ldr x0, [x0] \n" /* load argc */ -" add x2, x1, x0, lsl #3 \n" /* env is after argv */ -" add x2, x2, #8 \n" /* argv is null terminated */ -" b __start "); - - -/* The entry function. */ -void -__start(int argc, char *argv[], char *env[], void (*cleanup)(void)) -{ - - handle_argv(argc, argv, env); - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else - _init_tls(); - -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -__asm__("eprol:"); -#endif - - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} Property changes on: head/lib/csu/aarch64/crt1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/aarch64/Makefile =================================================================== --- head/lib/csu/aarch64/Makefile (revision 362202) +++ head/lib/csu/aarch64/Makefile (revision 362203) @@ -1,47 +1,37 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S +SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +crt1.o: crt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s - -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o .include Index: head/lib/csu/aarch64/crt1_c.c =================================================================== --- head/lib/csu/aarch64/crt1_c.c (nonexistent) +++ head/lib/csu/aarch64/crt1_c.c (revision 362203) @@ -0,0 +1,71 @@ +/* LINTLIBRARY */ +/*- + * Copyright 1996-1998 John D. Polstra. + * Copyright 2014 Andrew Turner. + * Copyright 2014-2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Andrew Turner + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "libc_private.h" +#include "ignore_init.c" + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +extern long * _end; + +void __start(int, char **, char **, void (*)(void)); + +/* The entry function. */ +void +__start(int argc, char *argv[], char *env[], void (*cleanup)(void)) +{ + + handle_argv(argc, argv, env); + + if (&_DYNAMIC != NULL) + atexit(cleanup); + else + _init_tls(); + +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +__asm__("eprol:"); +#endif + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} Property changes on: head/lib/csu/aarch64/crt1_c.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/aarch64/crt1_s.S =================================================================== --- head/lib/csu/aarch64/crt1_s.S (nonexistent) +++ head/lib/csu/aarch64/crt1_s.S (revision 362203) @@ -0,0 +1,47 @@ +/* LINTLIBRARY */ +/*- + * Copyright 1996-1998 John D. Polstra. + * Copyright 2014 Andrew Turner. + * Copyright 2014-2015 The FreeBSD Foundation. + * All rights reserved. + * + * Portions of this software were developed by Andrew Turner + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "crtbrand.S" +#include "ignore_init_note.S" + +ENTRY(_start) + mov x3, x2 /* cleanup */ + add x1, x0, #8 /* load argv */ + ldr x0, [x0] /* load argc */ + add x2, x1, x0, lsl #3 /* env is after argv */ + add x2, x2, #8 /* argv is null terminated */ + b __start +END(_start) + + .section .note.GNU-stack,"",@progbits Property changes on: head/lib/csu/aarch64/crt1_s.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/amd64/crt1.c =================================================================== --- head/lib/csu/amd64/crt1.c (revision 362202) +++ head/lib/csu/amd64/crt1.c (nonexistent) @@ -1,77 +0,0 @@ -/* LINTLIBRARY */ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 1996-1998 John D. Polstra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -typedef void (*fptr)(void); - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -void _start(char **, void (*)(void)); - -/* The entry function. */ -void -_start(char **ap, void (*cleanup)(void)) -{ - int argc; - char **argv; - char **env; - - argc = *(long *)(void *)ap; - argv = ap + 1; - env = ap + 2 + argc; - handle_argv(argc, argv, env); - - if (&_DYNAMIC != NULL) { - atexit(cleanup); - } else { - process_irelocs(); - _init_tls(); - } - -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -__asm__("eprol:"); -#endif - - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} Property changes on: head/lib/csu/amd64/crt1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/amd64/Makefile =================================================================== --- head/lib/csu/amd64/Makefile (revision 362202) +++ head/lib/csu/amd64/Makefile (revision 362203) @@ -1,47 +1,38 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S +SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -fno-omit-frame-pointer -DCRT_IRELOC_RELA FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o gcrt1_c.o Scrt1_c.o +CLEANFILES+= crtbrand.o ignore_init_note.o -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crtbrand.o ignore_init_note.o gcrt1_c.o -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +crt1.o: crt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o crt1.o -r crtbrand.o ignore_init_note.o crt1_c.o -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s - -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crtbrand.o ignore_init_note.o Scrt1_c.o .include Index: head/lib/csu/amd64/crt1_c.c =================================================================== --- head/lib/csu/amd64/crt1_c.c (nonexistent) +++ head/lib/csu/amd64/crt1_c.c (revision 362203) @@ -0,0 +1,76 @@ +/* LINTLIBRARY */ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "libc_private.h" +#include "ignore_init.c" + +typedef void (*fptr)(void); + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +void _start(char **, void (*)(void)); + +/* The entry function. */ +void +_start(char **ap, void (*cleanup)(void)) +{ + int argc; + char **argv; + char **env; + + argc = *(long *)(void *)ap; + argv = ap + 1; + env = ap + 2 + argc; + handle_argv(argc, argv, env); + + if (&_DYNAMIC != NULL) { + atexit(cleanup); + } else { + process_irelocs(); + _init_tls(); + } + +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +__asm__("eprol:"); +#endif + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} Property changes on: head/lib/csu/amd64/crt1_c.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/arm/crt1.c =================================================================== --- head/lib/csu/arm/crt1.c (revision 362202) +++ head/lib/csu/arm/crt1.c (nonexistent) @@ -1,134 +0,0 @@ -/* LINTLIBRARY */ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright 2001 David E. O'Brien. - * All rights reserved. - * Copyright 1996-1998 John D. Polstra. - * All rights reserved. - * Copyright (c) 1997 Jason R. Thorpe. - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * FreeBSD Project. See https://www.freebsd.org/ for - * information about FreeBSD. - * This product includes software developed for the - * NetBSD Project. See http://www.netbsd.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -struct Struct_Obj_Entry; -struct ps_strings; - -extern void _start(int, char **, char **, const struct Struct_Obj_Entry *, - void (*)(void), struct ps_strings *); - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -struct ps_strings *__ps_strings; - -void __start(int, char **, char **, struct ps_strings *, - const struct Struct_Obj_Entry *, void (*)(void)); - -/* The entry function. */ -__asm(" .text \n" -" .align 0 \n" -" .globl _start \n" -" _start: \n" -" mov r5, r2 /* cleanup */ \n" -" mov r4, r1 /* obj_main */ \n" -" mov r3, r0 /* ps_strings */ \n" -" /* Get argc, argv, and envp from stack */ \n" -" ldr r0, [sp, #0x0000] \n" -" add r1, sp, #0x0004 \n" -" add r2, r1, r0, lsl #2 \n" -" add r2, r2, #0x0004 \n" -" /* Ensure the stack is properly aligned before calling C code. */\n" -" bic sp, sp, #7 \n" -" sub sp, sp, #8 \n" -" str r5, [sp, #4] \n" -" str r4, [sp, #0] \n" -"\n" -" b __start "); -/* ARGSUSED */ -void -__start(int argc, char **argv, char **env, struct ps_strings *ps_strings, - const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void)) -{ - - handle_argv(argc, argv, env); - - if (ps_strings != (struct ps_strings *)0) - __ps_strings = ps_strings; - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else - _init_tls(); -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -#endif - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} - -static const struct { - int32_t namesz; - int32_t descsz; - int32_t type; - char name[sizeof(NOTE_FREEBSD_VENDOR)]; - char desc[sizeof(MACHINE_ARCH)]; -} archtag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = { - .namesz = sizeof(NOTE_FREEBSD_VENDOR), - .descsz = sizeof(MACHINE_ARCH), - .type = NT_FREEBSD_ARCH_TAG, - .name = NOTE_FREEBSD_VENDOR, - .desc = MACHINE_ARCH -}; - -#ifdef GCRT -__asm__(".text"); -__asm__("eprol:"); -__asm__(".previous"); -#endif Property changes on: head/lib/csu/arm/crt1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/arm/Makefile =================================================================== --- head/lib/csu/arm/Makefile (revision 362202) +++ head/lib/csu/arm/Makefile (revision 362203) @@ -1,47 +1,40 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S +SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +crt1_c.o: crt1_c.c + ${CC} ${CFLAGS} ${STATIC_CFLAGS} -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -crt1.s: crt1.c - ${CC} ${CFLAGS} ${STATIC_CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +crt1.o: crt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} ${STATIC_CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.s: crt1.c - ${CC} ${CFLAGS} ${STATIC_CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o .include Index: head/lib/csu/arm/crt1_c.c =================================================================== --- head/lib/csu/arm/crt1_c.c (nonexistent) +++ head/lib/csu/arm/crt1_c.c (revision 362203) @@ -0,0 +1,99 @@ +/* LINTLIBRARY */ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright 2001 David E. O'Brien. + * All rights reserved. + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * Copyright (c) 1997 Jason R. Thorpe. + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the + * FreeBSD Project. See https://www.freebsd.org/ for + * information about FreeBSD. + * This product includes software developed for the + * NetBSD Project. See http://www.netbsd.org/ for + * information about NetBSD. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include "libc_private.h" +#include "ignore_init.c" + +struct Struct_Obj_Entry; +struct ps_strings; + +extern void _start(int, char **, char **, const struct Struct_Obj_Entry *, + void (*)(void), struct ps_strings *); + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +struct ps_strings *__ps_strings; + +void __start(int, char **, char **, struct ps_strings *, + const struct Struct_Obj_Entry *, void (*)(void)); + +/* ARGSUSED */ +void +__start(int argc, char **argv, char **env, struct ps_strings *ps_strings, + const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void)) +{ + + handle_argv(argc, argv, env); + + if (ps_strings != (struct ps_strings *)0) + __ps_strings = ps_strings; + + if (&_DYNAMIC != NULL) + atexit(cleanup); + else + _init_tls(); +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +#endif + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif Property changes on: head/lib/csu/arm/crt1_c.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/arm/crt1_s.S =================================================================== --- head/lib/csu/arm/crt1_s.S (nonexistent) +++ head/lib/csu/arm/crt1_s.S (revision 362203) @@ -0,0 +1,78 @@ +/* LINTLIBRARY */ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright 2001 David E. O'Brien. + * All rights reserved. + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * Copyright (c) 1997 Jason R. Thorpe. + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the + * FreeBSD Project. See https://www.freebsd.org/ for + * information about FreeBSD. + * This product includes software developed for the + * NetBSD Project. See http://www.netbsd.org/ for + * information about NetBSD. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "crtbrand.S" +#include "ignore_init_note.S" + +ENTRY(_start) + mov r5, r2 /* cleanup */ + mov r4, r1 /* obj_main */ + mov r3, r0 /* ps_strings */ + /* Get argc, argv, and envp from stack */ + ldr r0, [sp, #0x0000] + add r1, sp, #0x0004 + add r2, r1, r0, lsl #2 + add r2, r2, #0x0004 + /* Ensure the stack is properly aligned before calling C code. */ + bic sp, sp, #7 + sub sp, sp, #8 + str r5, [sp, #4] + str r4, [sp, #0] + + b __start +END(_start) + + .section .note.tag,"a",%note + .p2align 2 + .4byte 2f-1f + .4byte 4f-3f + .4byte NT_FREEBSD_ARCH_TAG +1: .asciz NOTE_FREEBSD_VENDOR +2: .p2align 2 +3: .asciz MACHINE_ARCH +4: + + .section .note.GNU-stack,"",%progbits Property changes on: head/lib/csu/arm/crt1_s.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/common/crtbrand.c =================================================================== --- head/lib/csu/common/crtbrand.c (revision 362202) +++ head/lib/csu/common/crtbrand.c (nonexistent) @@ -1,84 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2000 David E. O'Brien, John D. Polstra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include "notes.h" - -/* - * Special ".note" entry specifying the ABI version. See - * http://www.netbsd.org/Documentation/kernel/elf-notes.html - * for more information. - * - * For all arches except sparc, gcc emits the section directive for the - * following struct 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 this C file (or the C file that includes 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. - */ -static const struct { - int32_t namesz; - int32_t descsz; - int32_t type; - char name[sizeof(NOTE_FREEBSD_VENDOR)]; - int32_t desc; -} abitag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = { - .namesz = sizeof(NOTE_FREEBSD_VENDOR), - .descsz = sizeof(int32_t), - .type = NT_FREEBSD_ABI_TAG, - .name = NOTE_FREEBSD_VENDOR, - .desc = __FreeBSD_version -}; - -static const struct { - int32_t namesz; - int32_t descsz; - int32_t type; - char name[sizeof(NOTE_FREEBSD_VENDOR)]; - uint32_t desc[1]; -} crt_feature_ctl __attribute__ ((section (NOTE_SECTION), - aligned(4))) __used = { - .namesz = sizeof(NOTE_FREEBSD_VENDOR), - .descsz = sizeof(uint32_t), - .type = NT_FREEBSD_FEATURE_CTL, - .name = NOTE_FREEBSD_VENDOR, - .desc = { 0 } -}; Property changes on: head/lib/csu/common/crtbrand.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/common/crtbrand.S =================================================================== --- head/lib/csu/common/crtbrand.S (nonexistent) +++ head/lib/csu/common/crtbrand.S (revision 362203) @@ -0,0 +1,59 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright 2000 David E. O'Brien, John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "notes.h" + +/* + * Special ".note.tag" entry specifying the ABI version. See + * http://www.netbsd.org/Documentation/kernel/elf-notes.html + * for more information. + */ + + .section .note.tag,"a",%note + .p2align 2 + .4byte 2f-1f + .4byte 4f-3f + .4byte NT_FREEBSD_ABI_TAG +1: .asciz NOTE_FREEBSD_VENDOR +2: .p2align 2 +3: .4byte __FreeBSD_version +4: + + .section .note.tag,"a",%note + .p2align 2 + .4byte 2f-1f + .4byte 4f-3f + .4byte NT_FREEBSD_FEATURE_CTL +1: .asciz NOTE_FREEBSD_VENDOR +2: .p2align 2 +3: .4byte 0 +4: Property changes on: head/lib/csu/common/crtbrand.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/common/ignore_init.c =================================================================== --- head/lib/csu/common/ignore_init.c (revision 362202) +++ head/lib/csu/common/ignore_init.c (revision 362203) @@ -1,157 +1,140 @@ /*- * SPDX-License-Identifier: BSD-1-Clause * * Copyright 2012 Konstantin Belousov * Copyright (c) 2018 The FreeBSD Foundation * * Parts of this software was developed by Konstantin Belousov * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include -#include "notes.h" - extern int main(int, char **, char **); extern void (*__preinit_array_start[])(int, char **, char **) __hidden; extern void (*__preinit_array_end[])(int, char **, char **) __hidden; extern void (*__init_array_start[])(int, char **, char **) __hidden; extern void (*__init_array_end[])(int, char **, char **) __hidden; extern void (*__fini_array_start[])(void) __hidden; extern void (*__fini_array_end[])(void) __hidden; extern void _fini(void) __hidden; extern void _init(void) __hidden; extern int _DYNAMIC; #pragma weak _DYNAMIC #if defined(CRT_IRELOC_RELA) extern const Elf_Rela __rela_iplt_start[] __weak_symbol __hidden; extern const Elf_Rela __rela_iplt_end[] __weak_symbol __hidden; #include "reloc.c" static void process_irelocs(void) { const Elf_Rela *r; for (r = &__rela_iplt_start[0]; r < &__rela_iplt_end[0]; r++) crt1_handle_rela(r); } #elif defined(CRT_IRELOC_REL) extern const Elf_Rel __rel_iplt_start[] __weak_symbol __hidden; extern const Elf_Rel __rel_iplt_end[] __weak_symbol __hidden; #include "reloc.c" static void process_irelocs(void) { const Elf_Rel *r; for (r = &__rel_iplt_start[0]; r < &__rel_iplt_end[0]; r++) crt1_handle_rel(r); } #elif defined(CRT_IRELOC_SUPPRESS) #else #error "Define platform reloc type" #endif char **environ; const char *__progname = ""; static void finalizer(void) { void (*fn)(void); size_t array_size, n; array_size = __fini_array_end - __fini_array_start; for (n = array_size; n > 0; n--) { fn = __fini_array_start[n - 1]; if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1) (fn)(); } _fini(); } static inline void handle_static_init(int argc, char **argv, char **env) { void (*fn)(int, char **, char **); size_t array_size, n; if (&_DYNAMIC != NULL) return; atexit(finalizer); array_size = __preinit_array_end - __preinit_array_start; for (n = 0; n < array_size; n++) { fn = __preinit_array_start[n]; if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1) fn(argc, argv, env); } _init(); array_size = __init_array_end - __init_array_start; for (n = 0; n < array_size; n++) { fn = __init_array_start[n]; if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1) fn(argc, argv, env); } } static inline void handle_argv(int argc, char *argv[], char **env) { const char *s; if (environ == NULL) environ = env; if (argc > 0 && argv[0] != NULL) { __progname = argv[0]; for (s = __progname; *s != '\0'; s++) { if (*s == '/') __progname = s + 1; } } } - -static const struct { - int32_t namesz; - int32_t descsz; - int32_t type; - char name[sizeof(NOTE_FREEBSD_VENDOR)]; - uint32_t desc; -} crt_noinit_tag __attribute__ ((section (NOTE_SECTION), - aligned(4))) __used = { - .namesz = sizeof(NOTE_FREEBSD_VENDOR), - .descsz = sizeof(uint32_t), - .type = NT_FREEBSD_NOINIT_TAG, - .name = NOTE_FREEBSD_VENDOR, - .desc = 0 -}; Index: head/lib/csu/common/ignore_init_note.S =================================================================== --- head/lib/csu/common/ignore_init_note.S (nonexistent) +++ head/lib/csu/common/ignore_init_note.S (revision 362203) @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-1-Clause + * + * Copyright 2012 Konstantin Belousov + * Copyright (c) 2018 The FreeBSD Foundation + * + * Parts of this software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "notes.h" + + .section .note.tag,"a",%note + .p2align 2 + .4byte 2f-1f + .4byte 4f-3f + .4byte NT_FREEBSD_NOINIT_TAG +1: .asciz NOTE_FREEBSD_VENDOR +2: .p2align 2 +3: .4byte 0 +4: Property changes on: head/lib/csu/common/ignore_init_note.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/i386/Makefile =================================================================== --- head/lib/csu/i386/Makefile (revision 362202) +++ head/lib/csu/i386/Makefile (revision 362203) @@ -1,58 +1,39 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= gcrt1.o crt1.o Scrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -DCRT_IRELOC_REL FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o -CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1_c.c is not -# directly compiled to .o files. +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1_c.s: crt1_c.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1_c.c - sed ${SED_FIX_NOTE} ${.TARGET} - -gcrt1_c.o: gcrt1_c.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1_c.s - gcrt1.o: gcrt1_c.o crt1_s.o ${LD} ${_LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o -crt1_c.s: crt1_c.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1_c.c - sed ${SED_FIX_NOTE} ${.TARGET} - -crt1_c.o: crt1_c.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1_c.s - crt1.o: crt1_c.o crt1_s.o ${LD} ${_LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o ${OBJCOPY} --localize-symbol _start1 crt1.o -Scrt1_c.s: crt1_c.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1_c.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1_c.o: Scrt1_c.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1_c.s +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c Scrt1.o: Scrt1_c.o crt1_s.o ${LD} ${_LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o ${OBJCOPY} --localize-symbol _start1 Scrt1.o .include Index: head/lib/csu/i386/crt1_c.c =================================================================== --- head/lib/csu/i386/crt1_c.c (revision 362202) +++ head/lib/csu/i386/crt1_c.c (revision 362203) @@ -1,76 +1,75 @@ /* LINTLIBRARY */ /*- * Copyright 1996-1998 John D. Polstra. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #include __FBSDID("$FreeBSD$"); #include #include "libc_private.h" -#include "crtbrand.c" #include "ignore_init.c" typedef void (*fptr)(void); extern void _start(char *, ...); #ifdef GCRT extern void _mcleanup(void); extern void monstartup(void *, void *); extern int eprol; extern int etext; #endif void _start1(fptr, int, char *[]) __dead2; /* The entry function, C part. */ void _start1(fptr cleanup, int argc, char *argv[]) { char **env; env = argv + argc + 1; handle_argv(argc, argv, env); if (&_DYNAMIC != NULL) { atexit(cleanup); } else { process_irelocs(); _init_tls(); } #ifdef GCRT atexit(_mcleanup); monstartup(&eprol, &etext); __asm__("eprol:"); #endif handle_static_init(argc, argv, env); exit(main(argc, argv, env)); } __asm(".hidden _start1"); Index: head/lib/csu/i386/crt1_s.S =================================================================== --- head/lib/csu/i386/crt1_s.S (revision 362202) +++ head/lib/csu/i386/crt1_s.S (revision 362203) @@ -1,51 +1,54 @@ /*- * Copyright 2009 Konstantin Belousov. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #include __FBSDID("$FreeBSD$"); +#include "crtbrand.S" +#include "ignore_init_note.S" + .text .align 4 .globl _start .type _start, @function _start: .cfi_startproc xorl %ebp,%ebp pushl %ebp .cfi_def_cfa_offset 4 movl %esp,%ebp .cfi_offset %ebp,-8 .cfi_def_cfa_register %ebp andl $0xfffffff0,%esp # align stack leal 8(%ebp),%eax subl $4,%esp pushl %eax # argv pushl 4(%ebp) # argc pushl %edx # rtld cleanup call _start1 int3 .cfi_endproc .size _start, . - _start .section .note.GNU-stack,"",%progbits Index: head/lib/csu/mips/crt1.c =================================================================== --- head/lib/csu/mips/crt1.c (revision 362202) +++ head/lib/csu/mips/crt1.c (nonexistent) @@ -1,92 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright 1996-1998 John D. Polstra. - * All rights reserved. - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -struct Struct_Obj_Entry; -struct ps_strings; - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -void __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *); - -/* The entry function. */ -void -__start(char **ap, - void (*cleanup)(void), /* from shared loader */ - struct Struct_Obj_Entry *obj __unused, /* from shared loader */ - struct ps_strings *ps_strings __unused) -{ - int argc; - char **argv; - char **env; - - argc = * (long *) ap; - argv = ap + 1; - env = ap + 2 + argc; - handle_argv(argc, argv, env); - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else - _init_tls(); - -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -#endif - - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} - -#ifdef GCRT -__asm__(".text"); -__asm__("eprol:"); -__asm__(".previous"); -#endif Property changes on: head/lib/csu/mips/crt1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/mips/Makefile =================================================================== --- head/lib/csu/mips/Makefile (revision 362202) +++ head/lib/csu/mips/Makefile (revision 362203) @@ -1,47 +1,38 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S +SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o gcrt1_c.o Scrt1_c.o +CLEANFILES+= crtbrand.o ignore_init_note.o -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crtbrand.o ignore_init_note.o gcrt1_c.o -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +crt1.o: crt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o crt1.o -r crtbrand.o ignore_init_note.o crt1_c.o -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s - -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crtbrand.o ignore_init_note.o Scrt1_c.o .include Index: head/lib/csu/mips/crt1_c.c =================================================================== --- head/lib/csu/mips/crt1_c.c (nonexistent) +++ head/lib/csu/mips/crt1_c.c (revision 362203) @@ -0,0 +1,91 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include "libc_private.h" +#include "ignore_init.c" + +struct Struct_Obj_Entry; +struct ps_strings; + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +void __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *); + +/* The entry function. */ +void +__start(char **ap, + void (*cleanup)(void), /* from shared loader */ + struct Struct_Obj_Entry *obj __unused, /* from shared loader */ + struct ps_strings *ps_strings __unused) +{ + int argc; + char **argv; + char **env; + + argc = * (long *) ap; + argv = ap + 1; + env = ap + 2 + argc; + handle_argv(argc, argv, env); + + if (&_DYNAMIC != NULL) + atexit(cleanup); + else + _init_tls(); + +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +#endif + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif Property changes on: head/lib/csu/mips/crt1_c.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/powerpc/crt1.c =================================================================== --- head/lib/csu/powerpc/crt1.c (revision 362202) +++ head/lib/csu/powerpc/crt1.c (nonexistent) @@ -1,110 +0,0 @@ -/* LINTLIBRARY */ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright 2001 David E. O'Brien. - * All rights reserved. - * Copyright 1996-1998 John D. Polstra. - * All rights reserved. - * Copyright (c) 1997 Jason R. Thorpe. - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * FreeBSD Project. See https://www.freebsd.org/ for - * information about FreeBSD. - * This product includes software developed for the - * NetBSD Project. See http://www.netbsd.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -struct Struct_Obj_Entry; -struct ps_strings; - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -struct ps_strings *__ps_strings; - -void _start(int, char **, char **, const struct Struct_Obj_Entry *, - void (*)(void), struct ps_strings *); - -/* The entry function. */ -/* - * First 5 arguments are specified by the PowerPC SVR4 ABI. - * The last argument, ps_strings, is a BSD extension. - */ -/* ARGSUSED */ -void -_start(int argc, char **argv, char **env, - const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), - struct ps_strings *ps_strings) -{ - - - handle_argv(argc, argv, env); - - if (ps_strings != (struct ps_strings *)0) - __ps_strings = ps_strings; - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else - _init_tls(); - -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -#endif - - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} - -#ifdef GCRT -__asm__(".text"); -__asm__("eprol:"); -__asm__(".previous"); -#endif - -#ifndef PIC -__asm__(".text\n" - "\t.global _GLOBAL_OFFSET_TABLE_\n" - "\t.reloc 0, R_PPC_NONE, _GLOBAL_OFFSET_TABLE_"); -#endif Property changes on: head/lib/csu/powerpc/crt1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/powerpc/Makefile =================================================================== --- head/lib/csu/powerpc/Makefile (revision 362202) +++ head/lib/csu/powerpc/Makefile (revision 362203) @@ -1,47 +1,38 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S crtsavres.S +SRCS= crti.S crtn.S crtsavres.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o gcrt1_c.o Scrt1_c.o +CLEANFILES+= crtbrand.o ignore_init_note.o -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crtbrand.o ignore_init_note.o gcrt1_c.o -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +crt1.o: crt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o crt1.o -r crtbrand.o ignore_init_note.o crt1_c.o -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s - -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crtbrand.o ignore_init_note.o Scrt1_c.o .include Index: head/lib/csu/powerpc/crt1_c.c =================================================================== --- head/lib/csu/powerpc/crt1_c.c (nonexistent) +++ head/lib/csu/powerpc/crt1_c.c (revision 362203) @@ -0,0 +1,109 @@ +/* LINTLIBRARY */ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright 2001 David E. O'Brien. + * All rights reserved. + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * Copyright (c) 1997 Jason R. Thorpe. + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the + * FreeBSD Project. See https://www.freebsd.org/ for + * information about FreeBSD. + * This product includes software developed for the + * NetBSD Project. See http://www.netbsd.org/ for + * information about NetBSD. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "libc_private.h" +#include "ignore_init.c" + +struct Struct_Obj_Entry; +struct ps_strings; + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +struct ps_strings *__ps_strings; + +void _start(int, char **, char **, const struct Struct_Obj_Entry *, + void (*)(void), struct ps_strings *); + +/* The entry function. */ +/* + * First 5 arguments are specified by the PowerPC SVR4 ABI. + * The last argument, ps_strings, is a BSD extension. + */ +/* ARGSUSED */ +void +_start(int argc, char **argv, char **env, + const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), + struct ps_strings *ps_strings) +{ + + + handle_argv(argc, argv, env); + + if (ps_strings != (struct ps_strings *)0) + __ps_strings = ps_strings; + + if (&_DYNAMIC != NULL) + atexit(cleanup); + else + _init_tls(); + +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +#endif + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif + +#ifndef PIC +__asm__(".text\n" + "\t.global _GLOBAL_OFFSET_TABLE_\n" + "\t.reloc 0, R_PPC_NONE, _GLOBAL_OFFSET_TABLE_"); +#endif Property changes on: head/lib/csu/powerpc/crt1_c.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/powerpc64/crt1.c =================================================================== --- head/lib/csu/powerpc64/crt1.c (revision 362202) +++ head/lib/csu/powerpc64/crt1.c (nonexistent) @@ -1,135 +0,0 @@ -/* LINTLIBRARY */ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright 2001 David E. O'Brien. - * All rights reserved. - * Copyright 1996-1998 John D. Polstra. - * All rights reserved. - * Copyright (c) 1997 Jason R. Thorpe. - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * FreeBSD Project. See https://www.freebsd.org/ for - * information about FreeBSD. - * This product includes software developed for the - * NetBSD Project. See http://www.netbsd.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -static uint32_t cpu_features; -static uint32_t cpu_features2; - -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -struct Struct_Obj_Entry; -struct ps_strings; - -extern void _start(int, char **, char **, const struct Struct_Obj_Entry *, - void (*)(void), struct ps_strings *); - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -struct ps_strings *__ps_strings; - -static void -init_cpu_features(char **env) -{ - const Elf_Auxinfo *aux; - - /* Find the auxiliary vector on the stack. */ - while (*env++ != 0) /* Skip over environment, and NULL terminator */ - ; - aux = (const Elf_Auxinfo *)env; - - /* Digest the auxiliary vector. */ - for (; aux->a_type != AT_NULL; aux++) { - switch (aux->a_type) { - case AT_HWCAP: - cpu_features = (uint32_t)aux->a_un.a_val; - break; - case AT_HWCAP2: - cpu_features2 = (uint32_t)aux->a_un.a_val; - break; - } - } -} - - -/* The entry function. */ -/* - * First 5 arguments are specified by the PowerPC SVR4 ABI. - * The last argument, ps_strings, is a BSD extension. - */ -/* ARGSUSED */ -void -_start(int argc, char **argv, char **env, - const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), - struct ps_strings *ps_strings) -{ - - handle_argv(argc, argv, env); - - if (ps_strings != (struct ps_strings *)0) - __ps_strings = ps_strings; - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else { - init_cpu_features(env); - process_irelocs(); - _init_tls(); - } - -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -#endif - - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} - -#ifdef GCRT -__asm__(".text"); -__asm__("eprol:"); -__asm__(".previous"); -#endif Property changes on: head/lib/csu/powerpc64/crt1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/lib/csu/powerpc64/Makefile =================================================================== --- head/lib/csu/powerpc64/Makefile (revision 362202) +++ head/lib/csu/powerpc64/Makefile (revision 362203) @@ -1,51 +1,43 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S +SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= crtsavres.o Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o crtsavres.o gcrt1.o CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include \ -mlongcall -DCRT_IRELOC_RELA FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s crtsavres.S gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o gcrt1_c.o Scrt1_c.o +CLEANFILES+= crtbrand.o ignore_init_note.o +CLEANFILES+= crtsavres.S -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. - -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - # On powerpc64 crtsavres is an empty file crtsavres.S: touch ${.TARGET} -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crtbrand.o ignore_init_note.o gcrt1_c.o -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s +crt1.o: crt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o crt1.o -r crtbrand.o ignore_init_note.o crt1_c.o -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crtbrand.o ignore_init_note.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crtbrand.o ignore_init_note.o Scrt1_c.o .include Index: head/lib/csu/powerpc64/crt1_c.c =================================================================== --- head/lib/csu/powerpc64/crt1_c.c (nonexistent) +++ head/lib/csu/powerpc64/crt1_c.c (revision 362203) @@ -0,0 +1,134 @@ +/* LINTLIBRARY */ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright 2001 David E. O'Brien. + * All rights reserved. + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * Copyright (c) 1997 Jason R. Thorpe. + * Copyright (c) 1995 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the + * FreeBSD Project. See https://www.freebsd.org/ for + * information about FreeBSD. + * This product includes software developed for the + * NetBSD Project. See http://www.netbsd.org/ for + * information about NetBSD. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +static uint32_t cpu_features; +static uint32_t cpu_features2; + +#include "libc_private.h" +#include "ignore_init.c" + +struct Struct_Obj_Entry; +struct ps_strings; + +extern void _start(int, char **, char **, const struct Struct_Obj_Entry *, + void (*)(void), struct ps_strings *); + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +struct ps_strings *__ps_strings; + +static void +init_cpu_features(char **env) +{ + const Elf_Auxinfo *aux; + + /* Find the auxiliary vector on the stack. */ + while (*env++ != 0) /* Skip over environment, and NULL terminator */ + ; + aux = (const Elf_Auxinfo *)env; + + /* Digest the auxiliary vector. */ + for (; aux->a_type != AT_NULL; aux++) { + switch (aux->a_type) { + case AT_HWCAP: + cpu_features = (uint32_t)aux->a_un.a_val; + break; + case AT_HWCAP2: + cpu_features2 = (uint32_t)aux->a_un.a_val; + break; + } + } +} + + +/* The entry function. */ +/* + * First 5 arguments are specified by the PowerPC SVR4 ABI. + * The last argument, ps_strings, is a BSD extension. + */ +/* ARGSUSED */ +void +_start(int argc, char **argv, char **env, + const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), + struct ps_strings *ps_strings) +{ + + handle_argv(argc, argv, env); + + if (ps_strings != (struct ps_strings *)0) + __ps_strings = ps_strings; + + if (&_DYNAMIC != NULL) + atexit(cleanup); + else { + init_cpu_features(env); + process_irelocs(); + _init_tls(); + } + +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +#endif + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif Property changes on: head/lib/csu/powerpc64/crt1_c.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/lib/csu/riscv/crt1.c =================================================================== --- head/lib/csu/riscv/crt1.c (revision 362202) +++ head/lib/csu/riscv/crt1.c (nonexistent) @@ -1,92 +0,0 @@ -/* LINTLIBRARY */ -/*- - * Copyright 1996-1998 John D. Polstra. - * Copyright (c) 2015-2017 Ruslan Bukin - * All rights reserved. - * - * Portions of this software were developed by SRI International and the - * University of Cambridge Computer Laboratory under DARPA/AFRL contract - * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Portions of this software were developed by the University of Cambridge - * Computer Laboratory as part of the CTSRD Project, with support from the - * UK Higher Education Innovation Fund (HEIF). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include "libc_private.h" -#include "crtbrand.c" -#include "ignore_init.c" - -typedef void (*fptr)(void); - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -void __start(int argc, char **argv, char **env, void (*cleanup)(void)); - -/* The entry function. */ -__asm(" .text \n" -" .align 0 \n" -" .globl _start \n" -" _start: \n" -" mv a3, a2 \n" /* cleanup */ -" addi a1, a0, 8 \n" /* get argv */ -" ld a0, 0(a0) \n" /* load argc */ -" slli t0, a0, 3 \n" /* mult by arg size */ -" add a2, a1, t0 \n" /* env is after argv */ -" addi a2, a2, 8 \n" /* argv is null terminated */ -" .option push \n" -" .option norelax \n" -" lla gp, __global_pointer$\n" -" .option pop \n" -" call __start"); - -void -__start(int argc, char **argv, char **env, void (*cleanup)(void)) -{ - - handle_argv(argc, argv, env); - - if (&_DYNAMIC != NULL) - atexit(cleanup); - else - _init_tls(); - -#ifdef GCRT - atexit(_mcleanup); - monstartup(&eprol, &etext); -__asm__("eprol:"); -#endif - - handle_static_init(argc, argv, env); - exit(main(argc, argv, env)); -} Property changes on: head/lib/csu/riscv/crt1.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/lib/csu/riscv/Makefile =================================================================== --- head/lib/csu/riscv/Makefile (revision 362202) +++ head/lib/csu/riscv/Makefile (revision 362203) @@ -1,47 +1,37 @@ # $FreeBSD$ .PATH: ${.CURDIR:H}/common -SRCS= crt1.c crti.S crtn.S +SRCS= crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= Scrt1.o gcrt1.o +OBJS+= Scrt1.o crt1.o gcrt1.o CFLAGS+= -I${.CURDIR:H}/common \ -I${SRCTOP}/lib/libc/include CFLAGS+= -DCRT_IRELOC_SUPPRESS FILES= ${OBJS} FILESMODE= ${LIBMODE} FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESDIR= ${LIBDIR} # These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. .undef LIBRARIES_ONLY -CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s +CLEANFILES= ${OBJS} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: gcrt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s +crt1.o: crt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +Scrt1_c.o: crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1_c.c -gcrt1.o: gcrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s - -Scrt1.s: crt1.c - ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -Scrt1.o: Scrt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s +Scrt1.o: Scrt1_c.o crt1_s.o + ${LD} ${_LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o .include Index: head/lib/csu/riscv/crt1_c.c =================================================================== --- head/lib/csu/riscv/crt1_c.c (nonexistent) +++ head/lib/csu/riscv/crt1_c.c (revision 362203) @@ -0,0 +1,74 @@ +/* LINTLIBRARY */ +/*- + * Copyright 1996-1998 John D. Polstra. + * Copyright (c) 2015-2017 Ruslan Bukin + * All rights reserved. + * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "libc_private.h" +#include "ignore_init.c" + +typedef void (*fptr)(void); + +#ifdef GCRT +extern void _mcleanup(void); +extern void monstartup(void *, void *); +extern int eprol; +extern int etext; +#endif + +void __start(int argc, char **argv, char **env, void (*cleanup)(void)); + +void +__start(int argc, char **argv, char **env, void (*cleanup)(void)) +{ + + handle_argv(argc, argv, env); + + if (&_DYNAMIC != NULL) + atexit(cleanup); + else + _init_tls(); + +#ifdef GCRT + atexit(_mcleanup); + monstartup(&eprol, &etext); +__asm__("eprol:"); +#endif + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); +} Property changes on: head/lib/csu/riscv/crt1_c.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/lib/csu/riscv/crt1_s.S =================================================================== --- head/lib/csu/riscv/crt1_s.S (nonexistent) +++ head/lib/csu/riscv/crt1_s.S (revision 362203) @@ -0,0 +1,56 @@ +/* LINTLIBRARY */ +/*- + * Copyright 1996-1998 John D. Polstra. + * Copyright (c) 2015-2017 Ruslan Bukin + * All rights reserved. + * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "crtbrand.S" +#include "ignore_init_note.S" + +ENTRY(_start) + mv a3, a2 # cleanup + addi a1, a0, 8 # get argv + ld a0, 0(a0) # load argc + slli t0, a0, 3 # mult by arg size + add a2, a1, t0 # env is after argv + addi a2, a2, 8 # argv is null terminated + .option push + .option norelax + lla gp, __global_pointer$ + .option pop + call __start +END(_start) + + .section .note.GNU-stack,"",%progbits Property changes on: head/lib/csu/riscv/crt1_s.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property