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 @@ -36,49 +36,25 @@ * 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 2f-1f\n" +" .word 4f-3f\n" +" .word " __XSTRING(NT_FREEBSD_ABI_TAG) "\n" +"1: .asciz \"FreeBSD\"\n" +"2: .p2align 2\n" +"3: .word " __XSTRING(__FreeBSD_version) "\n" +"4:"); -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 2f-1f\n" +" .word 4f-3f\n" +" .word " __XSTRING(NT_FREEBSD_FEATURE_CTL) "\n" +"1: .asciz \"FreeBSD\"\n" +"2: .p2align 2\n" +"3: .word 0\n" +"4:"); Index: lib/csu/common/ignore_init.c =================================================================== --- lib/csu/common/ignore_init.c +++ lib/csu/common/ignore_init.c @@ -141,17 +141,13 @@ } } -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 2f-1f\n" +" .word 4f-3f\n" +" .word " __XSTRING(NT_FREEBSD_NOINIT_TAG) "\n" +"1: .asciz \"FreeBSD\"\n" +"2: .p2align 2\n" +"3: .word 0\n" +"4:"); 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