Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* which quickstrip ?
@ 1996-01-04 14:52 Fred Roy
  1996-01-04 15:50 ` Erik Troan
  1996-01-05  2:13 ` Jim Paradis
  0 siblings, 2 replies; 3+ messages in thread
From: Fred Roy @ 1996-01-04 14:52 UTC (permalink / raw)


My question comes after a recent mail exchange on the way to rebuild a
kernel from the RedHat distribution.
I am also attempting to rebuild a Linux/Alpha kernel for the first time,
here from the BLADE_0.3 distribution. The Makefile in arch/alpha/boot
fails because the `quickstrip' command is not found. Should I use the
BLADE_0.3 /usr/bin/strip instead ??
fred

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: which quickstrip ?
  1996-01-04 14:52 which quickstrip ? Fred Roy
@ 1996-01-04 15:50 ` Erik Troan
  1996-01-05  2:13 ` Jim Paradis
  1 sibling, 0 replies; 3+ messages in thread
From: Erik Troan @ 1996-01-04 15:50 UTC (permalink / raw)


On Thu, 4 Jan 1996, Fred Roy wrote:

> My question comes after a recent mail exchange on the way to rebuild a
> kernel from the RedHat distribution.
> I am also attempting to rebuild a Linux/Alpha kernel for the first time,
> here from the BLADE_0.3 distribution. The Makefile in arch/alpha/boot
> fails because the `quickstrip' command is not found. Should I use the
> BLADE_0.3 /usr/bin/strip instead ??

No! That will result in a unbootable kernel, unless you're using a very 
recent binutils. If you bought a Red Hat CD, quickstrip was included. If 
you installed the Beta or downloaded it, you may be missing it.

In either case, ftp the file quickstrip-1.0-1.axp.rpm from ftp.redhat.com
in the /pub/redhat-2.1/axp-beta/RedHat/RPMS directory. After you get
it, do "rpm -ivh quickstrip-1.0-1.axp.rpm".

Erik

-------------------------------------------------------------------------------
 "Eggheads unite!  You have nothing to lose but your yolks" - Adlai Stevenson

    Erik Troan   =   http://sunsite.unc.edu/ewt/   =   ewt@sunsite.unc.edu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: which quickstrip ?
  1996-01-04 14:52 which quickstrip ? Fred Roy
  1996-01-04 15:50 ` Erik Troan
@ 1996-01-05  2:13 ` Jim Paradis
  1 sibling, 0 replies; 3+ messages in thread
From: Jim Paradis @ 1996-01-05  2:13 UTC (permalink / raw)


> I am also attempting to rebuild a Linux/Alpha kernel for the first time,
> here from the BLADE_0.3 distribution. The Makefile in arch/alpha/boot
> fails because the `quickstrip' command is not found. Should I use the
> BLADE_0.3 /usr/bin/strip instead ??

No, do not use /usr/bin/strip... it does a bit of "rearranging" of the
executable image such that the MILO loader no longer loads it correctly.

Here's the source for quickstrip if you don't have it already... it's
really simple and straightforward...

------------------------------- cut here ------------------------------------

#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>

struct filehdr {
    unsigned short	f_magic;	/* Magic number (must be ALPHAMAGIC) */
    unsigned short	f_nscns;	/* Number of sections */
    int			f_timdat;	/* Time/date of creation */
    int			f_symptr;	/* Pointer to symbolic header */
    int			f_symptr_pad;	/* Hi half of symptr quadword SBZ */
    int			f_nsyms;
    unsigned short	f_opthdr;	/* sozeof optional header */
    unsigned short	f_flags;	/* flags */
};

/* Usage: quickstrip infile [outfile] */

#define BUFSIZE 1024
char	iobuf[BUFSIZE];

#define	LITTLE_MAGIC	0x0183
#define	BIG_MAGIC	0x8301

main(int argc, char ** argv)
{

    if(argc == 2) { 
	strip_in_place(argv[1]);
    }
    else if(argc == 3) {
	strip_to_output(argv[1], argv[2]);
    }
    else {
        printf("Usage: %s infile [outfile]\n", argv[0]);
        exit(0);
    }
    
}

strip_in_place(char * filename)
{
    int		infile;
    struct filehdr fh;
    int		big_endian = 0;

    infile = open(filename, O_RDWR);
    if(infile < 0) {
        perror(filename);
        exit(0);
    }
    
    if(read(infile, &fh, sizeof(struct filehdr)) != sizeof(struct filehdr)) {
	perror("read");
	exit(0);
    }   

    if(fh.f_magic == BIG_MAGIC) {
	big_endian = 1;
	swap_fh(&fh);
    }

#ifdef DEBUG
printf("quickstrip: filhdr contents:\n");
printf("	f_magic: 0x%x\n", fh.f_magic);
printf("	f_nscns: 0x%x\n", fh.f_nscns);
printf("	f_timdat: 0x%x\n", fh.f_timdat);
printf("	f_symptr: 0x%x\n", fh.f_symptr);
printf("	f_symptr_pad: 0x%x\n", fh.f_symptr_pad);
printf("	f_nsyms: 0x%x\n", fh.f_nsyms);
printf("	f_opthdr: 0x%x\n", fh.f_opthdr);
printf("	f_flags: 0x%x\n", fh.f_flags);
#endif

    if(fh.f_symptr) {
        ftruncate(infile, fh.f_symptr);
	printf("%s truncated at %d\n", filename, fh.f_symptr);
	fh.f_symptr = 0;
	lseek(infile, 0, SEEK_SET);
	if(big_endian) {
	    swap_fh(fh);
	}
	write(infile, &fh, sizeof(struct filehdr));
    }
    else {
	printf("It looks like %s is already stripped!\n", filename);
    }
    
    close(infile);    
}

strip_to_output(char * name1, char * name2)
{
    int		infile;
    int		outfile;
    struct filehdr fh;
    struct stat st;
    int		bytesleft;
    int		iosize;
    int		nwritten = 0;
    int		big_endian = 0;

    infile = open(name1, O_RDONLY);
    if(infile < 0) {
        perror(name1);
        exit(0);
    }

    if(read(infile, &fh, sizeof(struct filehdr)) != sizeof(struct filehdr)) {
	perror("read");
	exit(0);
    }   

    if(fh.f_magic == BIG_MAGIC) {
	big_endian = 1;
	swap_fh(&fh);
    }

#ifdef DEBUG
printf("quickstrip: filhdr contents:\n");
printf("	f_magic: 0x%x\n", fh.f_magic);
printf("	f_nscns: 0x%x\n", fh.f_nscns);
printf("	f_timdat: 0x%x\n", fh.f_timdat);
printf("	f_symptr: 0x%x\n", fh.f_symptr);
printf("	f_symptr_pad: 0x%x\n", fh.f_symptr_pad);
printf("	f_nsyms: 0x%x\n", fh.f_nsyms);
printf("	f_opthdr: 0x%x\n", fh.f_opthdr);
printf("	f_flags: 0x%x\n", fh.f_flags);
#endif

    if(!fh.f_symptr) { 
	printf("Looks as though %s is already stripped.  Doing nothing.\n", name1);
	exit(0);
    }

    fstat(infile, &st);
    outfile = open(name2, O_WRONLY|O_CREAT, st.st_mode);
    if(outfile < 0) {
	perror(name2);
	close(infile);
	exit(0);
    }

    bytesleft = fh.f_symptr - sizeof(struct filehdr);

    fh.f_symptr = 0;
    if(big_endian) {
	swap_fh(&fh);
    }
    write(outfile, &fh, sizeof(struct filehdr));

    while(bytesleft > 0) {
	iosize = (bytesleft > BUFSIZE) ? BUFSIZE : bytesleft;

	read(infile, iobuf, iosize);
	write(outfile, iobuf, iosize);
	nwritten += iosize;
	bytesleft -= iosize;
    }

    printf("%d bytes written to %s\n", nwritten, name2);
    close(outfile);
}

unsigned short swap16(unsigned short s)
{
    return((unsigned short)( ((s << 8) & 0xff00) | ((s >> 8) & 0x00ff)));
}

unsigned int swap32(unsigned int i)
{
    return((unsigned int)(
		((i << 24) & 0xff000000) |
		((i << 8) & 0x00ff0000) |
		((i >> 8) & 0x0000ff00) |
		((i >> 24) & 0x000000ff)) );
}

swap_fh(struct filehdr *fh)
{
    fh->f_magic = swap16(fh->f_magic);
    fh->f_nscns = swap16(fh->f_nscns);
    fh->f_timdat = swap32(fh->f_timdat);
    fh->f_symptr = swap32(fh->f_symptr);
    fh->f_symptr_pad = swap32(fh->f_symptr_pad);
    fh->f_nsyms = swap32(fh->f_nsyms);
    fh->f_opthdr = swap16(fh->f_opthdr);
    fh->f_flags = swap16(fh->f_flags);
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-01-05  2:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-01-04 14:52 which quickstrip ? Fred Roy
1996-01-04 15:50 ` Erik Troan
1996-01-05  2:13 ` Jim Paradis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox