Index: lib/csu/Makefile.inc =================================================================== --- lib/csu/Makefile.inc +++ lib/csu/Makefile.inc @@ -2,8 +2,6 @@ SSP_CFLAGS= -SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/' - NO_WMISSING_VARIABLE_DECLARATIONS= .include Index: lib/csu/aarch64/Makefile =================================================================== --- lib/csu/aarch64/Makefile +++ lib/csu/aarch64/Makefile @@ -18,30 +18,11 @@ .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s - -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include Index: lib/csu/amd64/Makefile =================================================================== --- lib/csu/amd64/Makefile +++ lib/csu/amd64/Makefile @@ -18,30 +18,11 @@ .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s - -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include Index: lib/csu/arm/Makefile =================================================================== --- lib/csu/arm/Makefile +++ lib/csu/arm/Makefile @@ -18,30 +18,14 @@ .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +crt1.o: crt1.c + ${CC} ${CFLAGS} ${STATIC_CFLAGS} -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.s: crt1.c - ${CC} ${CFLAGS} ${STATIC_CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} +gcrt1.o: crt1.c + ${CC} ${CFLAGS} ${STATIC_CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s - -gcrt1.s: crt1.c - ${CC} ${CFLAGS} ${STATIC_CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include Index: lib/csu/common/crtbrand.c =================================================================== --- lib/csu/common/crtbrand.c +++ lib/csu/common/crtbrand.c @@ -30,55 +30,28 @@ #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 -}; +__asm( +" .section .note.tag,\"a\",@note\n" +" .p2align 2\n" +" .word 8\n" +" .word 4\n" +" .word " __XSTRING(NT_FREEBSD_ABI_TAG) "\n" +" .asciz \"FreeBSD\"\n" +" .p2align 2\n" +" .word " __XSTRING(__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 } -}; +__asm( +" .section .note.tag,\"a\",@note\n" +" .p2align 2\n" +" .word 8\n" +" .word 4\n" +" .word " __XSTRING(NT_FREEBSD_FEATURE_CTL) "\n" +" .asciz \"FreeBSD\"\n" +" .p2align 2\n" +" .word 0"); Index: lib/csu/common/ignore_init.c =================================================================== --- lib/csu/common/ignore_init.c +++ lib/csu/common/ignore_init.c @@ -32,8 +32,6 @@ #include #include -#include "notes.h" - extern int main(int, char **, char **); extern void (*__preinit_array_start[])(int, char **, char **) __hidden; @@ -141,17 +139,12 @@ } } -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 -}; +__asm( +" .section .note.tag,\"a\",@note\n" +" .p2align 2\n" +" .word 8\n" +" .word 4\n" +" .word " __XSTRING(NT_FREEBSD_NOINIT_TAG) "\n" +" .asciz \"FreeBSD\"\n" +" .p2align 2\n" +" .word 0"); Index: lib/csu/common/notes.h =================================================================== --- lib/csu/common/notes.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-1-Clause - * - * Copyright 2012 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$ - */ - -#ifndef CSU_COMMON_NOTES_H -#define CSU_COMMON_NOTES_H - -#define NOTE_FREEBSD_VENDOR "FreeBSD" - -#define NOTE_SECTION ".note.tag" - -#endif Index: lib/csu/i386/Makefile =================================================================== --- lib/csu/i386/Makefile +++ lib/csu/i386/Makefile @@ -18,38 +18,19 @@ .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.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_c.o: crt1_c.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1_c.c 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 Index: lib/csu/mips/Makefile =================================================================== --- lib/csu/mips/Makefile +++ lib/csu/mips/Makefile @@ -20,28 +20,10 @@ CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s - -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include Index: lib/csu/powerpc/Makefile =================================================================== --- lib/csu/powerpc/Makefile +++ lib/csu/powerpc/Makefile @@ -18,30 +18,11 @@ .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s - -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include Index: lib/csu/powerpc64/Makefile =================================================================== --- lib/csu/powerpc64/Makefile +++ lib/csu/powerpc64/Makefile @@ -18,34 +18,19 @@ .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s crtsavres.S gcrt1.s Scrt1.s +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} +crt1.o: crt1.c + ${CC} ${CFLAGS} -c -o ${.TARGET} ${.CURDIR}/crt1.c # 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.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include Index: lib/csu/riscv/Makefile =================================================================== --- lib/csu/riscv/Makefile +++ lib/csu/riscv/Makefile @@ -18,30 +18,11 @@ .undef LIBRARIES_ONLY CLEANFILES= ${OBJS} -CLEANFILES+= crt1.s gcrt1.s Scrt1.s -# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not -# directly compiled to .o files. +gcrt1.o: crt1.c + ${CC} ${CFLAGS} -DGCRT -c -o ${.TARGET} ${.CURDIR}/crt1.c -crt1.s: crt1.c - ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -crt1.o: crt1.s - ${CC} ${CFLAGS:N-g} ${ACFLAGS} -c -o ${.TARGET} crt1.s - -gcrt1.s: crt1.c - ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed ${SED_FIX_NOTE} ${.TARGET} - -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: crt1.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o ${.TARGET} ${.CURDIR}/crt1.c .include