From ca0fc8ef2f97709d3dfeac54e2c762e1c6ec6559 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 31 Mar 2025 09:37:35 -0400 Subject: elfcopy: Restore upstream name ELF Tool Chain's objcopy-equivalent is called elfcopy. Restore the upstream name in our build infrastructure to make it more clear where different binary utility components come from. Reviewed by: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49784 --- Makefile.inc1 | 12 +++++----- usr.bin/Makefile | 4 ++-- usr.bin/elfcopy/Makefile | 50 +++++++++++++++++++++++++++++++++++++++++ usr.bin/elfcopy/Makefile.depend | 19 ++++++++++++++++ usr.bin/objcopy/Makefile | 50 ----------------------------------------- usr.bin/objcopy/Makefile.depend | 19 ---------------- 6 files changed, 77 insertions(+), 77 deletions(-) create mode 100644 usr.bin/elfcopy/Makefile create mode 100644 usr.bin/elfcopy/Makefile.depend delete mode 100644 usr.bin/objcopy/Makefile delete mode 100644 usr.bin/objcopy/Makefile.depend diff --git a/Makefile.inc1 b/Makefile.inc1 index af9e4736a65a..a18d10e80f17 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -2910,14 +2910,14 @@ _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \ .endif .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no" -# Some bespoke tools from or based on ELF Tool Chain. objcopy (elfcopy) is -# included because llvm-objcopy is currently not capable of translating ELF to -# PE32+, which is required for EFI boot programs. +# Some bespoke tools from or based on ELF Tool Chain. elfcopy is included +# because llvm-objcopy is currently not capable of translating ELF to PE32+, +# which is required for EFI boot programs. _elftctools= lib/libelftc \ lib/libpe \ + usr.bin/elfcopy \ usr.bin/elfctl \ - usr.bin/elfdump \ - usr.bin/objcopy + usr.bin/elfdump # If we're given an XNM we don't need to build standard binary utilities. .if ${XNM:M/*} == "" _elftctools+= usr.bin/nm \ @@ -3011,7 +3011,7 @@ NXBDIRS+= \ usr.bin/cmp \ usr.bin/diff \ usr.bin/dirname \ - usr.bin/objcopy \ + usr.bin/elfcopy \ usr.bin/env \ usr.bin/fetch \ usr.bin/find \ diff --git a/usr.bin/Makefile b/usr.bin/Makefile index b9e4d6c1153a..87896a2c0781 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -263,14 +263,14 @@ SUBDIR.${MK_TOOLCHAIN}+= ctags .if ${MK_LLVM_CXXFILT} == "no" SUBDIR.${MK_TOOLCHAIN}+= cxxfilt .endif +# ELF Tool Chain elfcopy required for EFI objects (PR280771) +SUBDIR.${MK_TOOLCHAIN}+= elfcopy SUBDIR.${MK_TOOLCHAIN}+= file2c SUBDIR.${MK_TOOLCHAIN}+= gprof SUBDIR.${MK_TOOLCHAIN}+= indent SUBDIR.${MK_TOOLCHAIN}+= lex SUBDIR.${MK_TOOLCHAIN}+= lorder SUBDIR.${MK_TOOLCHAIN}+= mkstr -# ELF Tool Chain elfcopy required for EFI objects (PR280771) -SUBDIR.${MK_TOOLCHAIN}+= objcopy SUBDIR.${MK_TOOLCHAIN}+= rpcgen SUBDIR.${MK_TOOLCHAIN}+= unifdef SUBDIR.${MK_TOOLCHAIN}+= xstr diff --git a/usr.bin/elfcopy/Makefile b/usr.bin/elfcopy/Makefile new file mode 100644 index 000000000000..2f3386d95ebe --- /dev/null +++ b/usr.bin/elfcopy/Makefile @@ -0,0 +1,50 @@ +.include + +PACKAGE= elftoolchain + +ELFTCDIR= ${SRCTOP}/contrib/elftoolchain +ELFCOPYDIR= ${ELFTCDIR}/elfcopy + +.PATH: ${ELFCOPYDIR} + +PROG= elfcopy +MAN= elfcopy.1 + +.if ${MK_LLVM_BINUTILS} == "no" + +LINKS+= ${BINDIR}/${PROG} ${BINDIR}/objcopy +LINKS+= ${BINDIR}/${PROG} ${BINDIR}/strip +MAN+= objcopy.1 strip.1 + +objcopy.1: elfcopy.1 + sed -e 's/\.Dt ELFCOPY 1/.Dt OBJCOPY 1/' \ + -e '/\.Nm elfcopy ,/d' < ${.ALLSRC} > ${.TARGET} +CLEANFILES+= objcopy.1 + +.endif + +SRCS= archive.c ascii.c binary.c main.c pe.c sections.c segments.c symbols.c + +WARNS?= 5 + +LIBADD= archive elftc elf pe + +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/libpe -I${ELFTCDIR}/common +CFLAGS+=-DWITH_PE=1 + + + +# This same hack is in lib/libelf/Makefile and usr.bin/readelf/Makefile +# We need to link against the correct version of these files. One +# solution is to include SRCTOP/sys in the include path. This causes +# problems when a header file in sys depends on a file in another +# part of the tree, e.g. a machine dependent header. +# +SRCS+= sys/elf_common.h +CLEANDIRS= sys +CFLAGS+= -I. +sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA + mkdir -p ${.OBJDIR}/sys + ln -sf ${.ALLSRC} ${.TARGET} + +.include diff --git a/usr.bin/elfcopy/Makefile.depend b/usr.bin/elfcopy/Makefile.depend new file mode 100644 index 000000000000..898aa8b2b146 --- /dev/null +++ b/usr.bin/elfcopy/Makefile.depend @@ -0,0 +1,19 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libarchive \ + lib/libc \ + lib/libcompiler_rt \ + lib/libelf \ + lib/libelftc \ + lib/libpe \ + + +.include + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/usr.bin/objcopy/Makefile b/usr.bin/objcopy/Makefile deleted file mode 100644 index 2f3386d95ebe..000000000000 --- a/usr.bin/objcopy/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -.include - -PACKAGE= elftoolchain - -ELFTCDIR= ${SRCTOP}/contrib/elftoolchain -ELFCOPYDIR= ${ELFTCDIR}/elfcopy - -.PATH: ${ELFCOPYDIR} - -PROG= elfcopy -MAN= elfcopy.1 - -.if ${MK_LLVM_BINUTILS} == "no" - -LINKS+= ${BINDIR}/${PROG} ${BINDIR}/objcopy -LINKS+= ${BINDIR}/${PROG} ${BINDIR}/strip -MAN+= objcopy.1 strip.1 - -objcopy.1: elfcopy.1 - sed -e 's/\.Dt ELFCOPY 1/.Dt OBJCOPY 1/' \ - -e '/\.Nm elfcopy ,/d' < ${.ALLSRC} > ${.TARGET} -CLEANFILES+= objcopy.1 - -.endif - -SRCS= archive.c ascii.c binary.c main.c pe.c sections.c segments.c symbols.c - -WARNS?= 5 - -LIBADD= archive elftc elf pe - -CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/libpe -I${ELFTCDIR}/common -CFLAGS+=-DWITH_PE=1 - - - -# This same hack is in lib/libelf/Makefile and usr.bin/readelf/Makefile -# We need to link against the correct version of these files. One -# solution is to include SRCTOP/sys in the include path. This causes -# problems when a header file in sys depends on a file in another -# part of the tree, e.g. a machine dependent header. -# -SRCS+= sys/elf_common.h -CLEANDIRS= sys -CFLAGS+= -I. -sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA - mkdir -p ${.OBJDIR}/sys - ln -sf ${.ALLSRC} ${.TARGET} - -.include diff --git a/usr.bin/objcopy/Makefile.depend b/usr.bin/objcopy/Makefile.depend deleted file mode 100644 index 898aa8b2b146..000000000000 --- a/usr.bin/objcopy/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libarchive \ - lib/libc \ - lib/libcompiler_rt \ - lib/libelf \ - lib/libelftc \ - lib/libpe \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif -- cgit v1.3