Author: arichardson
Date: Tue Aug 11 16:46:27 2020
New Revision: 364119
URL: https://svnweb.freebsd.org/changeset/base/364119

Log:
  Allow overriding the tool used for stripping binaries
  
  Since the make variable STRIP is already used for other purposes, this
  uses STRIPBIN (which is also used for the same purpose by install(1).
  This allows using LLVM objcopy to strip binaries instead of the in-tree
  elftoolchain objcopy. We make use of this in CheriBSD since passing
  binaries generated by our toolchain to elftoolchain strip sometimes results
  in assertion failures.
  
  This allows working around 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248516
  by specifying STRIPBIN=/path/to/llvm-strip
  
  Obtained from:        CheriBSD
  Reviewed By:  emaste, brooks
  Differential Revision: https://reviews.freebsd.org/D25988

Modified:
  head/Makefile.inc1
  head/share/mk/sys.mk
  head/stand/i386/loader/Makefile
  head/sys/modules/linux/Makefile
  head/sys/modules/linux64/Makefile

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1  Tue Aug 11 16:40:09 2020        (r364118)
+++ head/Makefile.inc1  Tue Aug 11 16:46:27 2020        (r364119)
@@ -180,7 +180,7 @@ MK_SYSTEM_LINKER=   no
 .if defined(CROSS_TOOLCHAIN_PREFIX)
 CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
 .endif
-XBINUTILS=     AS AR LD NM OBJCOPY RANLIB SIZE STRINGS
+XBINUTILS=     AS AR LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN
 .for BINUTIL in ${XBINUTILS}
 .if defined(CROSS_BINUTILS_PREFIX) && \
     exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
@@ -755,7 +755,7 @@ CROSSENV+=  CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXF
                AS="${XAS}" AR="${XAR}" LD="${XLD}" LLVM_LINK="${XLLVM_LINK}" \
                NM=${XNM} OBJCOPY="${XOBJCOPY}" \
                RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
-               SIZE="${XSIZE}"
+               SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}"
 
 .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
 # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a

Modified: head/share/mk/sys.mk
==============================================================================
--- head/share/mk/sys.mk        Tue Aug 11 16:40:09 2020        (r364118)
+++ head/share/mk/sys.mk        Tue Aug 11 16:46:27 2020        (r364119)
@@ -275,6 +275,7 @@ SHELL               ?=      sh
 
 .if !defined(%POSIX)
 SIZE           ?=      size
+STRIPBIN       ?=      strip
 .endif
 
 YACC           ?=      yacc

Modified: head/stand/i386/loader/Makefile
==============================================================================
--- head/stand/i386/loader/Makefile     Tue Aug 11 16:40:09 2020        
(r364118)
+++ head/stand/i386/loader/Makefile     Tue Aug 11 16:46:27 2020        
(r364119)
@@ -64,7 +64,7 @@ ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN}
                -b ${BTXKERN} ${LOADER}.bin
 
 ${LOADER}.bin: ${LOADER}.sym
-       strip -R .comment -R .note -o ${.TARGET} ${.ALLSRC}
+       ${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC}
 
 .if ${MK_LOADER_ZFS} == "yes" && ${LOADER_INTERP} == ${LOADER_DEFAULT_INTERP}
 LINKS+=                ${BINDIR}/${LOADER} ${BINDIR}/zfsloader

Modified: head/sys/modules/linux/Makefile
==============================================================================
--- head/sys/modules/linux/Makefile     Tue Aug 11 16:40:09 2020        
(r364118)
+++ head/sys/modules/linux/Makefile     Tue Aug 11 16:46:27 2020        
(r364119)
@@ -69,12 +69,12 @@ linux${SFX}_support.o: linux${SFX}_assym.h assym.inc
 ${VDSO}.so: linux${SFX}_locore.o
        ${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd   
                \
            --binary-architecture i386 linux${SFX}_locore.o ${.TARGET}
-       strip -N _binary_linux${SFX}_locore_o_size ${.TARGET}
+       ${STRIPBIN} -N _binary_linux${SFX}_locore_o_size ${.TARGET}
 .else
 ${VDSO}.so: linux${SFX}_locore.o
        ${OBJCOPY} --input-target binary --output-target elf32-i386-freebsd     
                \
            --binary-architecture i386 linux${SFX}_locore.o ${.TARGET}
-       strip -N _binary_linux_locore_o_size ${.TARGET}
+       ${STRIPBIN} -N _binary_linux_locore_o_size ${.TARGET}
 .endif
 
 linux${SFX}_genassym.o: offset.inc

Modified: head/sys/modules/linux64/Makefile
==============================================================================
--- head/sys/modules/linux64/Makefile   Tue Aug 11 16:40:09 2020        
(r364118)
+++ head/sys/modules/linux64/Makefile   Tue Aug 11 16:46:27 2020        
(r364119)
@@ -46,7 +46,7 @@ OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-a
 ${VDSO}.so: linux_locore.o
        ${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} -S -g \
            linux_locore.o ${.TARGET}
-       strip -N _binary_linux_locore_o_size ${.TARGET}
+       ${STRIPBIN} -N _binary_linux_locore_o_size ${.TARGET}
 
 linux_support.o: assym.inc linux_assym.h
        ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to