From 4cca6183314a905fe485c551cbe45a8adc9795f6 Mon Sep 17 00:00:00 2001 From: uebayasi Date: Sat, 6 Nov 2010 16:03:23 +0000 Subject: [PATCH] Handle md(4)'s embedded root disk image and size symbol names other than the default ones ("md_root_image" / "md_root_size"). (References to xmd(4) are deliberately removed.) --- .../binutils/usr.sbin/mdsetimage/mdsetimage.8 | 13 ++++++++-- .../binutils/usr.sbin/mdsetimage/mdsetimage.c | 24 ++++++++++++------- usr.sbin/mdsetimage/mdsetimage.8 | 13 ++++++++-- usr.sbin/mdsetimage/mdsetimage.c | 23 +++++++++++------- 4 files changed, 52 insertions(+), 21 deletions(-) diff --git a/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8 b/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8 index a4121cec2d52..b3ea065a1675 100644 --- a/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8 +++ b/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: mdsetimage.8,v 1.1 2009/08/18 20:22:20 skrll Exp $ +.\" $NetBSD: mdsetimage.8,v 1.2 2010/11/06 16:03:23 uebayasi Exp $ .\" .\" Copyright (c) 1996 Christopher G. Demetriou .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" <> .\" -.Dd September 27, 2002 +.Dd November 4, 2010 .Dt MDSETIMAGE 8 .Os .Sh NAME @@ -36,6 +36,8 @@ .Sh SYNOPSIS .Nm .Op Fl svx +.Op Fl I Ar image_symbol +.Op Fl S Ar size_symbol .Op Fl b Ar bfdname .Ar kernel .Ar image @@ -51,6 +53,13 @@ The file system present in will typically be used by the kernel as the root file system. .Pp +The +.Fl I +and +.Fl S +flags specify the symbol names of image and size of memory disk +drivers respectively. +.Pp To recognize kernel executable format, the .Fl b flag specifies BFD name of kernel. diff --git a/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c b/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c index 636697808d20..15b8664e42a7 100644 --- a/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c +++ b/external/gpl3/binutils/usr.sbin/mdsetimage/mdsetimage.c @@ -1,4 +1,4 @@ -/* $NetBSD: mdsetimage.c,v 1.1 2009/08/18 20:22:20 skrll Exp $ */ +/* $NetBSD: mdsetimage.c,v 1.2 2010/11/06 16:03:23 uebayasi Exp $ */ /* from: NetBSD: mdsetimage.c,v 1.15 2001/03/21 23:46:48 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1996\ Christopher G. Demetriou. All rights reserved."); -__RCSID("$NetBSD: mdsetimage.c,v 1.1 2009/08/18 20:22:20 skrll Exp $"); +__RCSID("$NetBSD: mdsetimage.c,v 1.2 2010/11/06 16:03:23 uebayasi Exp $"); #endif /* not lint */ #include @@ -58,13 +58,9 @@ __RCSID("$NetBSD: mdsetimage.c,v 1.1 2009/08/18 20:22:20 skrll Exp $"); struct symbols { char *name; size_t offset; -} md_root_symbols[] = { -#define X_MD_ROOT_IMAGE 0 - { "_md_root_image", 0 }, -#define X_MD_ROOT_SIZE 1 - { "_md_root_size", 0 }, - { NULL, 0 } }; +#define X_MD_ROOT_IMAGE 0 +#define X_MD_ROOT_SIZE 1 #define CHUNKSIZE (64 * 1024) @@ -94,11 +90,21 @@ main(int argc, char *argv[]) char *bfdname = NULL; bfd *abfd; ssize_t left_to_copy; + struct symbols md_root_symbols[3] = { { 0 } }; + + md_root_symbols[X_MD_ROOT_IMAGE].name = "_md_root_image"; + md_root_symbols[X_MD_ROOT_SIZE].name = "_md_root_size"; setprogname(argv[0]); - while ((ch = getopt(argc, argv, "b:svx")) != -1) + while ((ch = getopt(argc, argv, "I:S:b:svx")) != -1) switch (ch) { + case 'I': + md_root_symbols[X_MD_ROOT_IMAGE].name = optarg; + break; + case 'S': + md_root_symbols[X_MD_ROOT_SIZE].name = optarg; + break; case 'b': bfdname = optarg; break; diff --git a/usr.sbin/mdsetimage/mdsetimage.8 b/usr.sbin/mdsetimage/mdsetimage.8 index 0d2923e1a8c6..dd66bdd0d872 100644 --- a/usr.sbin/mdsetimage/mdsetimage.8 +++ b/usr.sbin/mdsetimage/mdsetimage.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: mdsetimage.8,v 1.9 2002/01/19 03:35:05 wiz Exp $ +.\" $NetBSD: mdsetimage.8,v 1.10 2010/11/06 16:03:23 uebayasi Exp $ .\" .\" Copyright (c) 1996 Christopher G. Demetriou .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" <> .\" -.Dd October 3, 1996 +.Dd November 4, 2010 .Dt MDSETIMAGE 8 .Os .Sh NAME @@ -35,6 +35,8 @@ .Nd set kernel RAM disk image .Sh SYNOPSIS .Nm +.Op Fl I Ar image_symbol +.Op Fl S Ar size_symbol .Op Fl T Ar address .Op Fl v .Ar kernel @@ -51,6 +53,13 @@ The file system present in will typically be used by the kernel as the root file system. .Pp +The +.Fl I +and +.Fl S +flags specify the symbol names of image and size of memory disk +drivers respectively. +.Pp For a.out kernels only, the .Fl T flag specifies the starting address of kernel text. diff --git a/usr.sbin/mdsetimage/mdsetimage.c b/usr.sbin/mdsetimage/mdsetimage.c index bffe83d45735..91be8aa15bba 100644 --- a/usr.sbin/mdsetimage/mdsetimage.c +++ b/usr.sbin/mdsetimage/mdsetimage.c @@ -1,4 +1,4 @@ -/* $NetBSD: mdsetimage.c,v 1.19 2009/07/30 15:16:38 tsutsui Exp $ */ +/* $NetBSD: mdsetimage.c,v 1.20 2010/11/06 16:03:23 uebayasi Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou @@ -36,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1996\ #endif /* not lint */ #ifndef lint -__RCSID("$NetBSD: mdsetimage.c,v 1.19 2009/07/30 15:16:38 tsutsui Exp $"); +__RCSID("$NetBSD: mdsetimage.c,v 1.20 2010/11/06 16:03:23 uebayasi Exp $"); #endif /* not lint */ #include @@ -49,6 +49,7 @@ __RCSID("$NetBSD: mdsetimage.c,v 1.19 2009/07/30 15:16:38 tsutsui Exp $"); #include #include #include +#include #include #include "extern.h" @@ -58,13 +59,8 @@ static void usage __P((void)) __dead; static int find_md_root __P((const char *, const char *, size_t, const struct nlist *, size_t *, u_int32_t *)); -static struct nlist md_root_nlist[] = { #define X_MD_ROOT_IMAGE 0 - { "_md_root_image", 0, 0, 0, 0 }, #define X_MD_ROOT_SIZE 1 - { "_md_root_size", 0, 0, 0, 0 }, - { NULL, 0, 0, 0, 0 } -}; int verbose; #ifdef NLIST_AOUT @@ -88,14 +84,25 @@ main(argc, argv) const char *kfile, *fsfile; char *mappedkfile; int ch, kfd, fsfd, rv; + struct nlist md_root_nlist[3]; + + (void)memset(md_root_nlist, 0, sizeof(md_root_nlist)); + N_NAME(&md_root_nlist[X_MD_ROOT_IMAGE]) = "_md_root_image"; + N_NAME(&md_root_nlist[X_MD_ROOT_SIZE]) = "_md_root_size"; setprogname(argv[0]); - while ((ch = getopt(argc, argv, "T:v")) != -1) + while ((ch = getopt(argc, argv, "I:S:T:v")) != -1) switch (ch) { case 'v': verbose = 1; break; + case 'I': + N_NAME(&md_root_nlist[X_MD_ROOT_IMAGE]) = optarg; + break; + case 'S': + N_NAME(&md_root_nlist[X_MD_ROOT_SIZE]) = optarg; + break; case 'T': #ifdef NLIST_AOUT T_flag_specified = 1;