Module Name:    src
Committed By:   christos
Date:           Sun Oct  8 15:06:17 UTC 2017

Modified Files:
        src/usr.bin/crunch/crunchgen: crunchgen.1 crunchgen.c

Log Message:
Handle static PIE


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/crunch/crunchgen/crunchgen.1
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/crunch/crunchgen/crunchgen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/crunch/crunchgen/crunchgen.1
diff -u src/usr.bin/crunch/crunchgen/crunchgen.1:1.32 src/usr.bin/crunch/crunchgen/crunchgen.1:1.33
--- src/usr.bin/crunch/crunchgen/crunchgen.1:1.32	Tue Mar 18 14:20:44 2014
+++ src/usr.bin/crunch/crunchgen/crunchgen.1	Sun Oct  8 11:06:17 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crunchgen.1,v 1.32 2014/03/18 18:20:44 riastradh Exp $
+.\"	$NetBSD: crunchgen.1,v 1.33 2017/10/08 15:06:17 christos Exp $
 .\"
 .\" Copyright (c) 1994 University of Maryland
 .\" All Rights Reserved.
@@ -24,7 +24,7 @@
 .\"			   Computer Science Department
 .\"			   University of Maryland at College Park
 .\"
-.Dd June 10, 2013
+.Dd May 31, 2017
 .Dt CRUNCHGEN 1
 .Os
 .Sh NAME
@@ -32,7 +32,7 @@
 .Nd generates build environment for a crunched binary
 .Sh SYNOPSIS
 .Nm
-.Op Fl fOoq
+.Op Fl fOopq
 .Op Fl c Ar c-file-name
 .Op Fl D Ar src-root
 .Op Fl d Ar build-options
@@ -124,6 +124,8 @@ the program objects into a single reloca
 Use existing object files.
 Rather than rebuilding object files via reach-over
 makefiles, instead search for and use existing object files.
+.It Fl p
+Produce static pie (position independent executables).
 .It Fl q
 Quiet operation.
 Status messages are suppressed.

Index: src/usr.bin/crunch/crunchgen/crunchgen.c
diff -u src/usr.bin/crunch/crunchgen/crunchgen.c:1.84 src/usr.bin/crunch/crunchgen/crunchgen.c:1.85
--- src/usr.bin/crunch/crunchgen/crunchgen.c:1.84	Sun May 29 12:12:58 2016
+++ src/usr.bin/crunch/crunchgen/crunchgen.c	Sun Oct  8 11:06:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: crunchgen.c,v 1.84 2016/05/29 16:12:58 christos Exp $	*/
+/*	$NetBSD: crunchgen.c,v 1.85 2017/10/08 15:06:17 christos 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.84 2016/05/29 16:12:58 christos Exp $");
+__RCSID("$NetBSD: crunchgen.c,v 1.85 2017/10/08 15:06:17 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -102,7 +102,7 @@ static int goterror = 0;
 
 static const char *pname = "crunchgen";
 
-static int verbose, readcache, useobjs, oneobj;	/* options */
+static int verbose, readcache, useobjs, oneobj, pie;	/* options */
 static int reading_cache;
 static char *machine;
 static char *makeobjdirprefix;
@@ -151,14 +151,16 @@ main(int argc, char **argv)
     readcache = 1;
     useobjs = 0;
     oneobj = 1;
+    pie = 0;
     *outmkname = *outcfname = *execfname = '\0';
     
     if (argc > 0)
 	pname = argv[0];
 
-    while ((optc = getopt(argc, argv, "m:c:d:e:foqD:L:Ov:")) != -1) {
+    while ((optc = getopt(argc, argv, "m:c:d:e:fopqD: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;
@@ -918,7 +920,8 @@ top_makefile_rules(FILE *outmk)
 {
     prog_t *p;
 
-    fprintf(outmk, "NOPIE=\n");
+    if (!pie)
+	    fprintf(outmk, "NOPIE=\n");
     fprintf(outmk, "NOMAN=\n\n");
 
     fprintf(outmk, "DBG=%s\n", dbg);
@@ -948,7 +951,7 @@ top_makefile_rules(FILE *outmk)
 	fprintf(outmk, " %s_make", p->ident);
     fprintf(outmk, "\n\n");
 
-    fprintf(outmk, "LDSTATIC=-static\n\n");
+    fprintf(outmk, "LDSTATIC=-static%s\n\n", pie ? " -pie" : "");
     fprintf(outmk, "PROG=%s\n\n", execfname);
     
     fprintf(outmk, "all: ${PROG}.crunched\n");

Reply via email to