Skip to content

Commit

Permalink
Mk/Uses: Add elfctl
Browse files Browse the repository at this point in the history
Add USES=elfctl to change an ELF binary's feature control note.

Example:

USES=           elfctl
ELF_FEATURES=   +noaslr,wxneeded:foo

Reported by:	emaste
Approved by:	brooks, tcberner (portmgr)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34125
  • Loading branch information
Jehops committed Feb 18, 2022
1 parent 0051e68 commit 092c4b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Mk/Uses/elfctl.mk
@@ -0,0 +1,27 @@
# Change an ELF binary's feature control note
#
# Feature: elfctl
# Usage: USES=elfctl
# Valid ARGS: none
#
# Variables
#
# ELF_FEATURES= featurelist:path/to/file1 \
# featurelist:path/to/file1 \
featurelist:path/to/file2
#
# The file paths listed in ELF_FEATURES are relative to ${BUILD_WRKSRC}.
#

.if !defined(_INCLUDE_USES_ELFCTL_MK)
_INCLUDE_USES_ELFCTL_MK= yes

. if ! empty(ELF_FEATURES)
_USES_build+= 720:elfctl-post-build
elfctl-post-build:
. for feat in ${ELF_FEATURES}
${ELFCTL} -i -e ${feat:C/:.*//} ${BUILD_WRKSRC}/${feat:C/.*://}
. endfor
. endif

.endif
1 change: 1 addition & 0 deletions Mk/bsd.commands.mk
Expand Up @@ -34,6 +34,7 @@ DIALOG4PORTS?= ${LOCALBASE}/bin/dialog4ports
DIFF?= /usr/bin/diff
DIRNAME?= /usr/bin/dirname
EGREP?= /usr/bin/egrep
ELFCTL?= /usr/bin/elfctl
EXPR?= /bin/expr
FALSE?= false # Shell builtin
FILE?= /usr/bin/file
Expand Down

0 comments on commit 092c4b3

Please sign in to comment.