aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/crunch
Commit message (Collapse)AuthorAgeFilesLines
* crunch: ldconfig and ldd are unrelated to GNU ldEd Maste2026-03-021-4/+4
| | | | | | Move them to the usr.bin section. Fixes: de5663609e4c ("This is the new crunch utility for making...")
* shar: remove from the tree well in advance of the 15.0 releaseKyle Evans2025-07-101-1/+1
| | | | | | | | | | | We have had deprecation notice in the manpage for nearly six months, and it is also present both in 13.5 and 14.3. tar(1) can supply this functionality for those that truly need it, and cy@ has also created a sysutils/freebsd-shar port for this version of a frontend to live on in ports -- this port has been available since December 18, 2024. Reviewed by: allanjude, cy, emaste, jrm Differential Revision: https://reviews.freebsd.org/D50925
* packages: rename elftoolchain to toolchain, add more thingsLexi Winter2025-05-281-0/+2
| | | | | | | | | | | | | | Rename the existing "elftoolchain" package to "toolchain", and move everything which is gated by MK_TOOLCHAIN (e.g. lex, yacc, ...) to the toolchain package. This means we have one package called "toolchain" which contains all the development-related utilities which are not compilers or already part of some other package (e.g., llvm). Reviewed by: des, emaste Approved by: des (mentor) Differential Revision: https://reviews.freebsd.org/D50286
* Remove residual blank line at start of MakefileWarner Losh2024-07-155-5/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* crunchgen: add --list optionMartin Tournoij2024-04-172-21/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "bsdbox --list" will print all tools in the binary, one per line. The main use case for this is to make it easier to create links: for t in $(bsdbox --list); do ln -s bsdbox $t done The name --list was taken from busybox. This just adds a new "program" with the name "--list". I don't think we need to do real argument parsing here, and this is also how busybox does it. An additional minor change is that just "bsdbox" will no longer print the binary name itself ("bsdbox" in this case). Before it would do: % bsdbox usage: boxlike <prog> <args> ..., where <prog> is one of: cp ls mv bsdbox And now just: % bsdbox usage: boxlike <prog> <args> ..., where <prog> is one of: cp ls mv And just "bsdbox" will also exit with code 0 (and print to stdout) rather than exit with 0 and print to stderr Example output: % ./bsdbox usage: bsdbox program [args ...] bsdbox --list program [args ...] bsdbox combines several programs in one executable. Create a link to this executable with the program name to run that program, or give the program name as the first argument. Currently defined programs: true false tail head uname % ./bsdbox --list true false tail head uname % ./bsdbox uname -a FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64 % ln -s bsdbox uname % ./uname -a FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64 Pull Request: https://github.com/freebsd/freebsd-src/pull/894 Signed-off-by: Martin Tournoij <martin@arp242.net> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/894
* usr.sbin: Remove repeated wordsElyes Haouas2024-04-111-1/+1
| | | | | | Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/887
* crunch: Fix typoElyes Haouas2024-04-111-1/+1
| | | | | | Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/882
* crunchgen: slap a dependency on the generated makefile for .loKyle Evans2024-03-091-2/+2
| | | | | | | | | | | | | | | | | crunchgen generates a foo.lo for each binary it will end up crunching into the final product. While they have a dependency on the libs that are used to link them, nothing will force relinking if the set of libs needed to link them is changed. Because of this, incremental builds may not be possible if one builds a version of, e.g., rescue/ with a broken set of libs specified for a project -- a subsequent fix won't be rolled in cleanly, it will require purging the rescue/ objdir. This is a bit crude, but the foo.mk we generate doesn't actually get regenerated all that often in practice, so a spurious relink for the vast majority of crunched objects won't actually happen all that often. Reviewed by: bapt, emaste, imp Differential Revision: https://reviews.freebsd.org/D43869
* crunch: remove fdisk from examplesEd Maste2024-01-243-3/+3
| | | | | It has been deprecated for a long time; gpart should be used instead. The man page was updated in 2015 to declare it obsolete (b8c19fd719945).
* usr.sbin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-272-2/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* crunchgen: fix "keep" for an ELF world, break it outKyle Evans2023-11-101-1/+1
| | | | | | | | | | | | | | | | "keep" currently adds a leading underscore, which hasn't been useful or accurate since a.out days. Preserve the symbol name as it's given rather than mangle it to match ELF-style symbol names. This was partially fixed back in 6cd35234a092d ("Assume ELF-style symbol names now.") for crunchgen, but the keeplist wasn't changed to match it. While we're here, break it out to bsd.crunchgen.mk for later use in bsdbox. Reviewed by: adrian, imp Differential Revision: https://reviews.freebsd.org/D42499
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-1611-11/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-165-10/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .c comment patternWarner Losh2023-08-161-1/+0
| | | | Remove /^/[*/]\s*\$FreeBSD\$.*\n/
* Mark usage function as __dead2 in programs where it does not returnAlfonso Gregory2023-07-071-1/+1
| | | | | | | | In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dead2. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/735
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-192-2/+0
|
* crunchide(1): Fix a typo in a commentGordon Bergling2022-07-161-1/+1
| | | | | | | - s/maek/make/ Obtained from: NetBSD MFC after: 3 days
* crunchgen: remove -dc from linker invocationFangrui Song2022-02-092-5/+3
| | | | | | | | | | | | | | | | | | | | | In GNU ld and ld.lld, -dc is used with -r to allocate space to COMMON symbols. It is presumably to work around legacy code which cannot handle COMMON symbols in relocatable output. ld.lld may remove -dc or make it a no-op for the 15.0.0 release. As of 7420b323a014 crunch/crunchide does not require -dc, as the symbol hiding technique no longer relied on making symbols local. In addition -fno-common is now the default in Clang and GCC, so -dc serves no purpose as the compiler does not generate COMMON symbols anyway. See https://maskray.me/blog/2022-02-06-all-about-common-symbols for more detail on common symbols. Reviewed by: emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D34215
* crunchgen: use realpath(3) instead of ``pwd -P''Alexey Dokuchaev2021-10-271-17/+3
| | | | | | | | | | | | | r366466 (9c7bd4f198e1) fixed a subtle bug by stripping the trailing '\n' appended to the output of popen("cd %s && pwd -P", p->srcdir). Replace this cumbersome implementation with a single realpath(3) call which avoids spawning a shell, reading from the stream with fgets(3), and final strdup(3). Reviewed by: arichardson, kevans Approved by: imp Differential Revision: https://reviews.freebsd.org/D26734
* crunch: drop WARNS overrideKyle Evans2021-08-191-2/+0
| | | | crunchide and crunchgen now build fine with default WARNS
* crunchgen: fix remaining issues under WARNS=6Kyle Evans2021-08-192-21/+23
| | | | | | | | Entirely variables that should be static, save for one 'no previous declaration' in mkskel.sh. Reviewed by: arichardson, imp Differential Revision: https://reviews.freebsd.org/D31610
* crunchide: static'ify remaining non-exported functionsKyle Evans2021-08-191-8/+8
| | | | | Reviewed by: arichardson, imp Differential Revision: https://reviews.freebsd.org/D31609
* crunchide: address complaints from WARNS=6Kyle Evans2021-08-192-9/+9
| | | | | | | | | | - One (1) constify - One (1) argument is unused - One (1) local shadows a global - Various globals that should be static Reviewed by: arichardson, imp Differential Revision: https://reviews.freebsd.org/D31608
* crunchgen: sprinkle some const-poisoning aroundKyle Evans2021-08-192-6/+6
| | | | | Reviewed by: arichardson, imp Differential Revision: https://reviews.freebsd.org/D31607
* Lift scope of buf[] to make it extend to a potential access via *basenameStefan Eßer2020-12-101-1/+1
| | | | | | | | | | | | It can be assumed that the contents of the buffer was still allocated and valid at the point of the out-of-scope access, so there was no security issue in practice. Reported by: Coverity Scan CID 1437697 MFC after: 3 days Notes: svn path=/head/; revision=368503
* crunchgen: fix NULL-deref bug introduced in r364647Alex Richardson2020-12-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | While porting over the local changes from CheriBSD for upstreaming, I accidentally committed a broken version of find_entry_point(): we have to return NULL if the value is not found instead of a value with ep->name == NULL, since the checks in main were changed to check ep instead of ep->name for NULL. This only matters if the crunched tool cannot be found using normal lookup and one of the fallback paths is used, so it's unlikely to be triggered in rescue. However, I noticed that one of our CheriBSD test scripts was failing to run commands under `su` on minimal disk images where all binaries are hardlinks to a `cheribsdbox` tool generated with crunchgen. This also updates the bootstrapping check in Makefile.inc1 to bootstrap crunchgen up to the next version bump. Reviewed By: kevans Differential Revision: https://reviews.freebsd.org/D27474 Notes: svn path=/head/; revision=368337
* crunchgen: fix MK_AUTO_OBJ logic after r364166Kyle Evans2020-10-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | r364166 converted echo -n `/bin/pwd` to a raw pwd invocation, leaving a trailing newline at the end of path. This caused a later stat() of it to erroneously fail and the fallback to MK_AUTO_OBJ=no logic proceeded as unexpected. Harry Schmalzbauer bissected the resulting build failure he experienced (stable/12 host, -HEAD build) down to r365887. This change is mostly unrelated, except it switches the build to bootstrapped crunchgen - clue! I then bissected recent crunchgen changes going back a bit since we wouldn't observe the failure immediately with -CURRENT in most configurations, which landed me on r364166. After many intense head-scratching minutes and printf debugging, I realized that the newline was the difference. This is where our tale ends. Reported by: Harry Schmalzbauer, O. Hartmann, Mike Tancsa, kevans MFC after: 3 days Notes: svn path=/head/; revision=366466
* [rcorder] [crunch] Fix C function declarations to include voidAdrian Chadd2020-09-211-1/+1
| | | | | | | | | | This fixes a compile issue under gcc6 which complains about legacy style C function declarations. Differential Revision: https://reviews.freebsd.org/D26504 Notes: svn path=/head/; revision=365957
* crunchgen(8): fix crunched application build with WARNS=6Kyle Evans2020-09-102-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was revealed by the rescue build with a patch I'm working on to default WARNS=6 everywhere. The issues resolved were: - Missing prototype for _crunched_${ident}_stub in the *_stub.c generated bits - Missing prototype for crunched_main - Incomplete prototype for _crunched_${ident}_stub in the generated parts of crunched_main - Literal strings in the stub table must drop const qualifier, unless we const'ify name - f field in struct stub didn't have a proper prototype Most of these issues are minor formalities and easily addressed. I note that if my patch to eventually raise WARNS for the rescue build lands, we'll need to bump the __FreeBSD_version requirement for bootstrapping crunchgen and wipe out the rescue .OBJDIR if it's stale, which we should be able to detect pretty easily from a couple of the issues that have been fixed here. Reviewed by: arichardson MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26363 Notes: svn path=/head/; revision=365605
* Correctly determine the real executable in crunched binariesAlex Richardson2020-08-241-19/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This should fix cases like su setting argv[0] to _su for /bin/sh. Previously cheribsdbox (a crunched tool we use in CheriBSD to reduce the size of our minimal disk images to allow loading them onto FPGAs without waiting forever for the transfer) would complain about _su not being compiled in, but now that we also look at AT_EXECPATH it correctly invokes the sh tool. Note: we use use AT_EXECPATH instead of the KERN_PROC_PATHNAME sysctl to get the crunchgen binary name since it seems like KERN_PROC_PATHNAME just returns the last cached path for a given hardlink. When using `su`, instead of invoking /bin/csh this would invoke the last used hardlink to cheribsdbox. This caused weird test failures when running tests due to `id` being executed instead of `echo`: $ id # id is a hardlink to /bin/cheribsdbox $ su postgres -c 'echo 1' # su is also a hardlink uid=1001(postgres) gid=1001(postgres) groups=1001(postgres) Obtained from: CheriBSD Reviewed By: emaste, brooks Differential Revision: https://reviews.freebsd.org/D25998 Notes: svn path=/head/; revision=364647
* Re-indent crunched_main.c in preparation for D25998Alex Richardson2020-08-241-43/+42
| | | | Notes: svn path=/head/; revision=364646
* crunchgen: use pwd -P without envAlex Richardson2020-08-141-1/+1
| | | | | | | | | | | | The -P flag is required by POSIX so we don't have to care whether pwd is a shell builtin or not. This also allows removing pwd from the list of bootstrap tools since all shells we care about for building have a builtin pwd command. This effectively reverts r364190. Suggested By: rgrimes, jrtc27 Notes: svn path=/head/; revision=364234
* Use env pwd instead of pwd in crunchgen.cAlex Richardson2020-08-121-1/+1
| | | | | | | | | | | | | In r364166 I changed /bin/pwd to pwd, but pwd can be shell builtin that may not correctly return a real path. To ensure that all symlinks are resolved use `env pwd -P` instead (the -P flag is part of POSIX so should be supported everywhere). Reported By: rgrimes Suggested By: jrtc27 Notes: svn path=/head/; revision=364174
* Fix crunchgen usage of mkstemp()Alex Richardson2020-08-121-10/+26
| | | | | | | | | | | | | | | | On Glibc systems mkstemp can only be used once with the same template string since it will be modified in-place and no longer contain any 'X' chars. It is fine to reuse the same file here but we need to be explicit and use open() instead of mkstemp() on the second use. While touching this file also avoid a hardcoded /bin/pwd since that may not work when building on non-FreeBSD systems. Reviewed By: brooks Differential Revision: https://reviews.freebsd.org/D25990 Notes: svn path=/head/; revision=364166
* crunch: remove rsh and rlogin from example config fileEd Maste2019-08-131-1/+1
| | | | | | | | | | | | | rcmds removed in r324351. Historical references in the README are maintained. There's a paragraph describing a "980K crunched 'fixit'" that references rsh and rlogin. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=350983
* Remove obsolete RELEASE_CRUNCHWarner Losh2019-07-191-3/+1
| | | | | | | | Remove documentation of RELEASE_CRUNCH here. It's obsolete and no longer a good example. Notes: svn path=/head/; revision=350152
* send-pr: wave goodbyeEitan Adler2018-08-191-1/+0
| | | | | | | | | | Entering into the world of 12.x we no longer need even the placeholder for send-pr. It has not done anything for some time. With Hat: bugmeister Notes: svn path=/head/; revision=338042
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-273-3/+10
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* Remove badsect(8).Konstantin Belousov2017-11-052-2/+3
| | | | | | | | | | | | | | Failure modes of the modern (that is, produced in the last 25 years) hard drives and SSDs made the utility outdated. Since the kernel interface to support it was removed in r324853, cut the userspace remnants as well. Discussed with: bde (who does not like the removal) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=325452
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-312-2/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Deorbit catman. The tradeoff of disk for performance has long since tippedGordon Tetlow2017-09-131-1/+1
| | | | | | | | | | | | | in favor of just rendering the manpage instead of relying on pre-formatted catpages. Note, this does not impede the ability to use existing catpages, it just removes the utility to generate them. Reviewed by: imp, allanjude Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D12317 Notes: svn path=/head/; revision=323550
* crunchgen: quiet -Wmissing-prototypesRyan Libby2017-09-072-17/+4
| | | | | | | | | Reviewed by: emaste (previous version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12107 Notes: svn path=/head/; revision=323276
* Teach crunchide about EM_S390 to make bootstrapping from futureBjoern A. Zeeb2017-01-101-0/+1
| | | | | | | | | | releases easier unless someone will fix the PR properly. MFC after: 3 days PR: 215940 Notes: svn path=/head/; revision=311876
* Show that the crunchgen configuration file name is not optional.Warren Block2017-01-061-3/+3
| | | | | | | | | | PR: 215087 Submitted by: Iblis Lin <iblis@hs.ntnu.edu.tw> MFC after: 1 week Sponsored by: iXsystems Notes: svn path=/head/; revision=311527
* crunchide: report explicit error for combined string tableEd Maste2016-11-171-0/+4
| | | | | | | | | | | | | | | | | Some tools produce objects with a combined strtab and shstrtab. These objects are not supported by crunchide since it rewrites the symtab and strtab to "hide" symbols. This invalidates section header offsets into a combined strtab/shstrtab. In the future we could support these objects (by ensuring that we retain unmodified section name strings in the output .strtab, and then rewriting each section header's sh_name). MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=308772
* crunchide: remove obsolete a.out header and commentEd Maste2016-11-161-2/+1
| | | | | | | | | | crunchide(1) gained ELF support in r39172, and lost the unused a.out and non-functional ECOFF suport in r281655. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=308734
* crunchgen: do not strip crunched binary (it will be done by install)Ed Maste2016-09-301-2/+0
| | | | | | | | Reviewed by: adrian, imp (earlier) Differential Revision: https://reviews.freebsd.org/D2003 Notes: svn path=/head/; revision=306497
* META_MODE/DIRDEPS_BUILD: Fix various issues with crunch builds.Bryan Drewery2016-09-011-0/+1
| | | | | | | | | | | | | | | | | - DIRDEPS_BUILD: Fix crunchgen builds losing their library dependencies on a nop-rebuild. - META_MODE: Fix not rebuilding various crunch.mk targets if their .meta files warrant a rebuild. They were lacking .meta files previously. This adds .NOMETA to the crunch objects being used since they are already built. Bmake was forcing a rebuild on them since their .meta files were not in the expected place; there is no reason to rebuild them. MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=305254
* WITH_AUTO_OBJ: Fix crunchgen builds.Bryan Drewery2016-05-261-1/+6
| | | | | | | | | | | | | | | | | | | | Passing MAKEOBJDIRPREFIX to the main prog build (rescue) would confuse WITH_AUTO_OBJ and cause it to create a recursed object directory that then broke the actual prog build. This is normally not a problem since we do not call 'make -f prog.mk obj' before building anything in it. Crunchgen(1) also assumes that if -o is not passed then if an object directory does not already exist then it should build in the source directories. The normal buildworld process will have already ran 'make obj' in each of the component directories so this is not a problem. With WITH_AUTO_OBJ though this is not the case. So we must tell crunchgen(1) that MK_AUTO_OBJ=yes will create the directory and to not require it be present before generating its Makefile. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=300806