git: 332166892ef3 - stable/12 - crunchgen: remove -dc from linker invocation

From: Ed Maste <>
Date: Thu, 17 Feb 2022 01:13:57 UTC
The branch stable/12 has been updated by emaste:


commit 332166892ef341664a733e581ea99c0adad17566
Author:     Fangrui Song <>
AuthorDate: 2022-02-09 00:59:53 +0000
Commit:     Ed Maste <>
CommitDate: 2022-02-17 01:07:30 +0000

    crunchgen: remove -dc from linker invocation
    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
    See for more
    detail on common symbols.
    Reviewed by:    emaste
    MFC after:      1 week
    Differential Revision:
    (cherry picked from commit ec81497cc7260b26c2af615c54aa80f515d6c539)
 usr.sbin/crunch/crunchgen/crunchgen.c | 2 +-
 usr.sbin/crunch/crunchide/crunchide.c | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c
index 94792c5ec50b..9d603abc9114 100644
--- a/usr.sbin/crunch/crunchgen/crunchgen.c
+++ b/usr.sbin/crunch/crunchgen/crunchgen.c
@@ -1137,7 +1137,7 @@ prog_makefile_rules(FILE *outmk, prog_t *p)
 		fprintf(outmk, " $(%s_LIBS)", p->ident);
 	fprintf(outmk, "\n");
-	fprintf(outmk, "\t$(CC) -nostdlib -Wl,-dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)",
+	fprintf(outmk, "\t$(CC) -nostdlib -r -o %s.lo %s_stub.o $(%s_OBJPATHS)",
 	    p->name, p->name, p->ident);
 	if (p->libs)
 		fprintf(outmk, " $(%s_LIBS)", p->ident);
diff --git a/usr.sbin/crunch/crunchide/crunchide.c b/usr.sbin/crunch/crunchide/crunchide.c
index 1f2f98893bac..bd663e1d57bd 100644
--- a/usr.sbin/crunch/crunchide/crunchide.c
+++ b/usr.sbin/crunch/crunchide/crunchide.c
@@ -28,9 +28,7 @@
  * crunchide.c - tiptoes through a symbol table, hiding all defined
  *	global symbols.  Allows the user to supply a "keep list" of symbols
- *	that are not to be hidden.  This program relies on the use of the
- * 	linker's -dc flag to actually put global bss data into the file's
- * 	bss segment (rather than leaving it as undefined "common" data).
+ *	that are not to be hidden.
  * 	The point of all this is to allow multiple programs to be linked
  *	together without getting multiple-defined errors.
@@ -40,7 +38,7 @@
  *	    int foo_main(int argc, char **argv){ return main(argc, argv); }
  *      like so:
  *	    cc -c foo.c foostub.c
- *	    ld -dc -r foo.o foostub.o -o foo.combined.o
+ *	    ld -r foo.o foostub.o -o foo.combined.o
  *	    crunchide -k _foo_main foo.combined.o
  *	at this point, foo.combined.o can be linked with another program
  * 	and invoked with "foo_main(argc, argv)".  foo's main() and any