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 Handle static PIE



details:   https://anonhg.NetBSD.org/src/rev/5e5f68a6516e
branches:  trunk
changeset: 827007:5e5f68a6516e
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 08 15:06:17 2017 +0000

description:
Handle static PIE

diffstat:

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

diffs (100 lines):

diff -r b0d4ec83c395 -r 5e5f68a6516e usr.bin/crunch/crunchgen/crunchgen.1
--- a/usr.bin/crunch/crunchgen/crunchgen.1      Sun Oct 08 15:05:19 2017 +0000
+++ b/usr.bin/crunch/crunchgen/crunchgen.1      Sun Oct 08 15:06:17 2017 +0000
@@ -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 @@
 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.
diff -r b0d4ec83c395 -r 5e5f68a6516e usr.bin/crunch/crunchgen/crunchgen.c
--- a/usr.bin/crunch/crunchgen/crunchgen.c      Sun Oct 08 15:05:19 2017 +0000
+++ b/usr.bin/crunch/crunchgen/crunchgen.c      Sun Oct 08 15:06:17 2017 +0000
@@ -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 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 @@
     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 @@
 {
     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 @@
        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");



Home | Main Index | Thread Index | Old Index