Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/crunch/crunchgen Add new option -s to crunchgen(1) -...



details:   https://anonhg.NetBSD.org/src/rev/7c158c811d65
branches:  trunk
changeset: 833343:7c158c811d65
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Jun 21 10:55:54 2018 +0000

description:
Add new option -s to crunchgen(1) -- enable sanitization

As of today typical sanitizers require dynamic executables, while
crunchgen(1) programs are produced with static properties.

Lack of specified -s will:
 - generate a Makefile file with NOSANITIZER=
 - build programs that are dependencies with NOSANITIZER=

In future there is an option to handle sanitization in statically linked
programs.

An idea with -s LGTM by <christos>

diffstat:

 usr.bin/crunch/crunchgen/crunchgen.1 |   8 +++++---
 usr.bin/crunch/crunchgen/crunchgen.c |  13 ++++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)

diffs (97 lines):

diff -r 01a813777e2c -r 7c158c811d65 usr.bin/crunch/crunchgen/crunchgen.1
--- a/usr.bin/crunch/crunchgen/crunchgen.1      Thu Jun 21 10:46:39 2018 +0000
+++ b/usr.bin/crunch/crunchgen/crunchgen.1      Thu Jun 21 10:55:54 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: crunchgen.1,v 1.34 2017/10/09 10:31:50 wiz Exp $
+.\"    $NetBSD: crunchgen.1,v 1.35 2018/06/21 10:55:54 kamil Exp $
 .\"
 .\" Copyright (c) 1994 University of Maryland
 .\" All Rights Reserved.
@@ -24,7 +24,7 @@
 .\"                       Computer Science Department
 .\"                       University of Maryland at College Park
 .\"
-.Dd May 31, 2017
+.Dd June 21, 2018
 .Dt CRUNCHGEN 1
 .Os
 .Sh NAME
@@ -32,7 +32,7 @@
 .Nd generates build environment for a crunched binary
 .Sh SYNOPSIS
 .Nm
-.Op Fl fOopq
+.Op Fl fOopqs
 .Op Fl c Ar c-file-name
 .Op Fl D Ar src-root
 .Op Fl d Ar build-options
@@ -129,6 +129,8 @@
 .It Fl q
 Quiet operation.
 Status messages are suppressed.
+.It Fl s
+Enable sanitization.
 .It Fl v Ar varspec
 Append a variable specification to the on-the fly generated Makefile.
 .El
diff -r 01a813777e2c -r 7c158c811d65 usr.bin/crunch/crunchgen/crunchgen.c
--- a/usr.bin/crunch/crunchgen/crunchgen.c      Thu Jun 21 10:46:39 2018 +0000
+++ b/usr.bin/crunch/crunchgen/crunchgen.c      Thu Jun 21 10:55:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crunchgen.c,v 1.86 2018/05/08 23:05:17 mrg Exp $       */
+/*     $NetBSD: crunchgen.c,v 1.87 2018/06/21 10:55:54 kamil Exp $     */
 /*
  * Copyright (c) 1994 University of Maryland
  * All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: crunchgen.c,v 1.86 2018/05/08 23:05:17 mrg Exp $");
+__RCSID("$NetBSD: crunchgen.c,v 1.87 2018/06/21 10:55:54 kamil Exp $");
 #endif
 
 #include <stdlib.h>
@@ -102,7 +102,7 @@
 
 static const char *pname = "crunchgen";
 
-static int verbose, readcache, useobjs, oneobj, pie;   /* options */
+static int verbose, readcache, useobjs, oneobj, pie, sanitizer;        /* options */
 static int reading_cache;
 static char *machine;
 static char *makeobjdirprefix;
@@ -157,13 +157,14 @@
     if (argc > 0)
        pname = argv[0];
 
-    while ((optc = getopt(argc, argv, "m:c:d:e:fopqD:L:Ov:")) != -1) {
+    while ((optc = getopt(argc, argv, "m:c:d:e:fopqsD:L:Ov:")) != -1) {
        switch(optc) {
        case 'f':       readcache = 0; break;
        case 'p':       pie = 1; break;
        case 'q':       verbose = 0; break;
        case 'O':       oneobj = 0; break;
        case 'o':       useobjs = 1, oneobj = 0; break;
+       case 's':       sanitizer = 1; break;
 
        case 'm':       (void)estrlcpy(outmkname, optarg, sizeof(outmkname)); break;
        case 'c':       (void)estrlcpy(outcfname, optarg, sizeof(outcfname)); break;
@@ -922,6 +923,8 @@
 
     if (!pie)
            fprintf(outmk, "NOPIE=\n");
+    if (!sanitizer)
+           fprintf(outmk, "NOSANITIZER=\n");
     fprintf(outmk, "NOMAN=\n\n");
 
     fprintf(outmk, "DBG=%s\n", dbg);
@@ -1017,7 +1020,7 @@
        for (lst = vars; lst != NULL; lst = lst->next)
            fprintf(outmk, "%s\\n", lst->str);
        fprintf(outmk, "'\\\n");
-       fprintf(outmk, MAKECMD);
+       fprintf(outmk, MAKECMD "%s ", sanitizer ? "" : "NOSANITIZER=");
        if (p->objs)
            fprintf(outmk, "${%s_OBJS} ) \n\n", p->ident);
        else



Home | Main Index | Thread Index | Old Index