summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C
blob: 321c55130aab050e42ed3656cae2097563e9f154 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// { dg-do assemble  }
// { dg-options "-O" }
// GROUPS passed old-abort
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
extern int swap_endian;			 
inline ushort
swapshort(ushort value)
{
    value &= 0xffff;
    return ((value << 8) | (value >> 8));
}
struct eshort
{
    ushort	data;			 
    operator ushort() { return swap_endian ? swapshort(data) : data;}
    eshort(ushort t) { data = swap_endian ? swapshort(t) : t;}
    eshort() {}
};
inline ulong
swaplong(ulong value)
{
    ulong v = (value << 16) | (value >> 16);
    return ((v >> 8) & 0x00ff00ff) | ((v << 8) & 0xff00ff00);
}
struct elong
{
    ulong	data;			 
    operator ulong() { return swap_endian ? swaplong(data) : data;}
    elong(ulong t) { data = swap_endian ? swaplong(t) : t; }
    elong() {}
};
struct digiheader
{
    uchar	type[2];		 
    eshort	soft_version;		 
    eshort	lo_boot_rev;		 
    eshort	hi_boot_rev;		 
    eshort	load_segment;		 
    eshort	length;			 
    eshort	exec_start;		 
    eshort	image_offset;		 
    elong	startup_code[2];	 
    elong	checksum;		 
};
extern void uncompress(uchar* buf, ulong len);
extern ulong compress(char* filename, uchar* buffer, ulong);
struct filehdr
{
    eshort	f_magic;		 
    eshort	f_nscns;		 
    elong	f_timdat;		 
    elong	f_symptr;		 
    elong	f_nsyms;		 
    eshort	f_opthdr;		 
    eshort	f_flags;		 
};
struct aouthdr
{
    eshort	magic;			 
    eshort	vstamp;			 
    elong	tsize;			 
    elong	dsize;			 
    elong	bsize;			 
    elong	entry;			 
    elong	text_start;		 
    elong	data_start;		 
    elong	bss_start;		 
    elong	gprmask;		 
    elong	cprmask[4];		 
    elong	gp_value;		 
};
struct scnhdr
{
    char	s_name[8];		 
    elong	s_paddr;		 
    elong	s_vaddr;		 
    elong	s_size;			 
    elong	s_scnptr;		 
    elong	s_relptr;		 
    elong	s_lnnoptr;		 
    eshort	s_nreloc;		 
    eshort	s_nlnno;		 
    elong	s_flags;		 
};
int file_little_endian;			 
int host_little_endian;			 
int swap_endian;			 
int docheck;				 
int expand;				 
ulong memsize;				 
ulong compression_quality;		 
char *compressfile;			 
int debug_level;			 
extern "C" int getopt (int, char**, const char*);
int
main(int argc, char** argv)
{
    uchar checksum;
    uchar docrc;
    ulong len;
    ulong maxlen;
    int i;
    int c;
    int magic;
    int tsize;
    int dsize;
    int quality;
    char dummy;
    uchar* code;
    uchar* buf;
    char* ap;
    digiheader *dh;
    compression_quality = 10000;
    docheck = 0;
    while ((c = getopt(argc, argv, "Ccdf:k:q:x:")) != -1)
    {
	switch (c)
	{
	default:
	    goto usage;
	}
    }
    if ((expand && (docheck || compressfile || quality)) ||
	(quality && !compressfile))
    {
    usage:
	return(2);
    }
    if (compressfile)
    {
	dh->image_offset = len;
	
	len += compress(compressfile, code + len, maxlen - len);
    }
}