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