emaste created this revision.
emaste added a reviewer: andrew.
emaste added a subscriber: freebsd-toolchain-list.
Herald added subscribers: emaste, bdrewery.

REVISION SUMMARY
  ELF Tool Chain elfcopy is nearly a drop-in replacement for GNU objcopy (but 
does not currently support PE output, needed for building x86 UEFI bits). Add a 
make.conf knob to allow installing it as objcopy and set it by default for 
aarch64 only, where we don't have a native binutils.
  
  This is WIP for comment and testing.

REVISION DETAIL
  https://reviews.freebsd.org/D2887

AFFECTED FILES
  gnu/usr.bin/binutils/Makefile
  share/mk/src.opts.mk
  tools/build/mk/OptionalObsoleteFiles.inc
  tools/build/options/WITH_ELFCOPY_AS_OBJCOPY
  usr.bin/elfcopy/Makefile

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: emaste, andrew
Cc: bdrewery, freebsd-toolchain-list, emaste
diff --git a/usr.bin/elfcopy/Makefile b/usr.bin/elfcopy/Makefile
--- a/usr.bin/elfcopy/Makefile
+++ b/usr.bin/elfcopy/Makefile
@@ -7,7 +7,15 @@
 
 .PATH: ${ELFCOPYDIR}
 
+.if ${MK_ELFCOPY_AS_OBJCOPY} != "no"
+PROG=	objcopy
+objcopy.1: elfcopy.1
+	sed -e 's/\.Dt ELFCOPY 1/.Dt OBJCOPY 1/' \
+	    -e 's/\.Nm elfcopy/.Nm objcopy/' < ${.ALLSRC} > ${.TARGET}
+CLEANFILES+= objcopy.1
+.else
 PROG=	elfcopy
+.endif
 
 SRCS=	archive.c ascii.c binary.c main.c sections.c segments.c symbols.c
 
@@ -17,8 +25,8 @@
 
 CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common
 
-MAN=	elfcopy.1 strip.1
+MAN=	${PROG}.1 strip.1
 
-LINKS=	${BINDIR}/elfcopy ${BINDIR}/strip
+LINKS=	${BINDIR}/${PROG} ${BINDIR}/strip
 
 .include <bsd.prog.mk>
diff --git a/tools/build/options/WITH_ELFCOPY_AS_OBJCOPY b/tools/build/options/WITH_ELFCOPY_AS_OBJCOPY
new file mode 100644
--- /dev/null
+++ b/tools/build/options/WITH_ELFCOPY_AS_OBJCOPY
@@ -0,0 +1,4 @@
+.\" $FreeBSD$
+Set to build and install ELF Tool Chain's elfcopy as
+.Xr objcopy 1 ,
+instead of the one from GNU Binutils.
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -184,7 +184,9 @@
 .if ${MK_BINUTILS} == no
 OLD_FILES+=usr/bin/as
 OLD_FILES+=usr/bin/ld
+.if ${MK_ELFTOOLCHAIN_TOOLS} != no && ${MK_ELFCOPY_AS_OBJCOPY} == no
 OLD_FILES+=usr/bin/objcopy
+.endif
 OLD_FILES+=usr/bin/objdump
 OLD_FILES+=usr/bin/readelf
 OLD_FILES+=usr/libdata/ldscripts/elf_x86_64_fbsd.x
@@ -202,7 +204,9 @@
 OLD_FILES+=usr/libdata/ldscripts/elf_x86_64_fbsd.xw
 OLD_FILES+=usr/share/man/man1/as.1.gz
 OLD_FILES+=usr/share/man/man1/ld.1.gz
+.if ${MK_ELFTOOLCHAIN_TOOLS} != no && ${MK_ELFCOPY_AS_OBJCOPY} == no
 OLD_FILES+=usr/share/man/man1/objcopy.1.gz
+.endif
 OLD_FILES+=usr/share/man/man1/objdump.1.gz
 OLD_FILES+=usr/share/man/man1/readelf.1.gz
 OLD_FILES+=usr/share/man/man7/as.7.gz
@@ -1648,7 +1652,8 @@
 OLD_FILES+=usr/share/nls/uk_UA.KOI8-U/ee.cat
 .endif
 
-.if ${MK_ELFTOOLCHAIN_TOOLS} == no
+.if ${MK_ELFTOOLCHAIN_TOOLS} == no || \
+    (${MK_ELFTOOLCHAIN_TOOLS} != no && MK_ELFCOPY_AS_OBJCOPY == no)
 OLD_FILES+=usr/bin/elfcopy
 OLD_FILES+=usr/share/man/man1/elfcopy.1.gz
 .endif
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -234,6 +234,9 @@
 .endif
 .if ${__T} == "aarch64"
 BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
+__DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY
+.else
+__DEFAULT_NO_OPTIONS+=ELFCOPY_AS_OBJCOPY
 .endif
 # LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
 .if ${__T} == "arm" || ${__T} == "armeb"
diff --git a/gnu/usr.bin/binutils/Makefile b/gnu/usr.bin/binutils/Makefile
--- a/gnu/usr.bin/binutils/Makefile
+++ b/gnu/usr.bin/binutils/Makefile
@@ -11,7 +11,7 @@
 	as \
 	ld \
 	${_nm} \
-	objcopy \
+	${_objcopy} \
 	objdump \
 	${_readelf} \
 	${_size} \
@@ -26,5 +26,8 @@
 _strings=	strings
 _strip=		strip
 .endif
+.if ${MK_ELFTOOLCHAIN_TOOLS} == "no" || ${MK_ELFCOPY_AS_OBJCOPY} == "no"
+_objcopy=	objcopy
+.endif
 
 .include <bsd.subdir.mk>

_______________________________________________
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"

Reply via email to