update to ida 7.6, add builds

This commit is contained in:
2021-10-31 21:20:46 +02:00
parent e0e0f2be99
commit b1809fe2d9
1408 changed files with 279193 additions and 302468 deletions

14
idasdk76/ldr/os9/makefile Normal file
View File

@@ -0,0 +1,14 @@
PROC=os9
include ../loader.mak
# MAKEDEP dependency list ------------------
$(F)os9$(O) : $(I)auto.hpp $(I)bitrange.hpp $(I)bytes.hpp \
$(I)config.hpp $(I)diskio.hpp $(I)entry.hpp \
$(I)fixup.hpp $(I)fpro.h $(I)funcs.hpp \
$(I)ida.hpp $(I)idp.hpp $(I)ieee.h $(I)kernwin.hpp \
$(I)lines.hpp $(I)llong.hpp $(I)loader.hpp $(I)nalt.hpp \
$(I)name.hpp $(I)netnode.hpp $(I)offset.hpp $(I)pro.h \
$(I)range.hpp $(I)segment.hpp $(I)segregs.hpp $(I)ua.hpp \
$(I)xref.hpp ../../module/mc68xx/notify_codes.hpp \
../idaldr.h os9.cpp os9.hpp

332
idasdk76/ldr/os9/os9.cpp Normal file
View File

@@ -0,0 +1,332 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-99 by Ilfak Guilfanov <ig@datarescue.com>
* ALL RIGHTS RESERVED.
*
* This file is able to load:
* - OS9 object files
* - FLEX STX files
* for 6809
*
*/
#include "../idaldr.h"
#include "../../module/mc68xx/notify_codes.hpp"
#include "os9.hpp"
//----------------------------------------------------------------------
static void swap_os9_header(os9_header_t &h)
{
#if __MF__
qnotused(h);
#else
h.magic = swap16(h.magic);
h.size = swap16(h.size);
h.name = swap16(h.name);
h.start = swap16(h.start);
h.storage = swap16(h.storage);
#endif
}
//----------------------------------------------------------------------
// calc header parity
static uchar calc_os9_parity(os9_header_t &h)
{
uchar *ptr = (uchar *)&h;
int parity = 0;
for ( int i=0; i < 8; i++ )
parity ^= *ptr++;
return (uchar)~parity;
}
//----------------------------------------------------------------------
static const char object_name[] = "OS9 object file for 6809";
static bool is_os9_object_file(qstring *fileformatname, linput_t *li)
{
os9_header_t h;
qlseek(li, 0);
if ( qlread(li,&h,sizeof(os9_header_t)) != sizeof(os9_header_t) )
return false;
swap_os9_header(h);
if ( h.magic == OS9_MAGIC
&& calc_os9_parity(h) == h.parity
&& (h.type_lang & OS9_LANG) == OS9_LANG_OBJ )
{
*fileformatname = object_name;
return true;
}
return false;
}
//----------------------------------------------------------------------
static const char flex_name[] = "FLEX STX file";
static bool is_os9_flex_file(qstring *fileformatname, linput_t *li)
{
qlseek(li, 0);
int64 fsize = qlsize(li);
int nrec2 = 0;
qoff64_t fpos = 0;
while ( 1 )
{
if ( fpos > fsize )
return false;
qlseek(li, fpos, SEEK_SET);
int c = qlgetc(li);
if ( c == EOF )
break;
if ( fpos == 0 && c != 0x2 )
return false; // the first byte must be 0x2
switch ( c )
{
case 0:
fpos++;
break;
case 0x2:
{
c = qlgetc(li);
int adr = (c<<8) | qlgetc(li);
if ( adr == EOF )
return false;
c = qlgetc(li); // number of bytes
if ( c == 0 || c == EOF )
return false;
fpos += c+4;
nrec2++;
}
break;
case 0x16:
fpos += 3;
break;
default:
return false;
}
}
if ( nrec2 == 0 )
return false;
*fileformatname = flex_name;
return true;
}
//----------------------------------------------------------------------
static int idaapi accept_file(
qstring *fileformatname,
qstring *processor,
linput_t *li,
const char *)
{
if ( is_os9_object_file(fileformatname, li) // OS9
|| is_os9_flex_file(fileformatname, li) ) // FLEX
{
*processor = "6809";
return 1;
}
return 0;
}
//----------------------------------------------------------------------
static const char *get_os9_type_name(uchar type)
{
switch ( type )
{
case OS9_TYPE_ILL: return "illegal";
case OS9_TYPE_PRG: return "Program module";
case OS9_TYPE_SUB: return "Subroutine module";
case OS9_TYPE_MUL: return "Multi-Module (for future use)";
case OS9_TYPE_DAT: return "Data module";
case OS9_TYPE_SYS: return "OS-9 System Module";
case OS9_TYPE_FIL: return "OS-9 File Manager Module";
case OS9_TYPE_DRV: return "OS-9 Device Driver Module";
case OS9_TYPE_DDM: return "OS-9 Device Descriptor Module";
default: return "unknown";
}
}
//----------------------------------------------------------------------
static const char *get_os9_lang_name(uchar lang)
{
switch ( lang )
{
case OS9_LANG_DAT: return "Data (not executable)";
case OS9_LANG_OBJ: return "6809 object code";
case OS9_LANG_BAS: return "BASIC09 I-Code";
case OS9_LANG_PAS: return "PASCAL P-Code";
case OS9_LANG_C: return "C I-Code";
case OS9_LANG_CBL: return "COBOL I-Code";
case OS9_LANG_FTN: return "FORTRAN I-Code";
default: return "unknown";
}
}
//--------------------------------------------------------------------------
static void create32(
sel_t sel,
ea_t start_ea,
ea_t end_ea,
const char *name,
const char *classname)
{
set_selector(sel, 0);
segment_t s;
s.sel = sel;
s.start_ea = start_ea;
s.end_ea = end_ea;
s.align = saRelByte;
s.comb = scPub;
if ( !add_segm_ex(&s, name, classname, ADDSEG_NOSREG|ADDSEG_SPARSE) )
loader_failure();
}
//----------------------------------------------------------------------
#define LOADING_OFFSET 0x1000
void load_obj_file(linput_t *li)
{
os9_header_t h;
qlseek(li, 0);
lread(li, &h, sizeof(os9_header_t));
swap_os9_header(h);
set_processor_type("6809", SETPROC_LOADER);
set_target_assembler(5);
uint64 fsize = qlsize(li);
qoff64_t fpos = qltell(li);
uint64 rest = fsize - fpos;
ea_t start = to_ea(inf_get_baseaddr(), LOADING_OFFSET);
ea_t end = start + h.size;
if ( end <= start || fsize < fpos || fsize-fpos < rest )
loader_failure("Corrupted input file");
file2base(li, 0, start, end, FILEREG_PATCHABLE);
create32(inf_get_baseaddr(), start, start + h.size, "TEXT", "CODE");
create_filename_cmt();
ea_t ea = start;
set_name(ea, "magic", SN_IDBENC);
create_word(ea, 2);
op_num(ea,0);
ea += 2;
set_name(ea, "size", SN_IDBENC);
create_word(ea, 2);
op_num(ea,0);
ea += 2;
set_name(ea, "name", SN_IDBENC);
create_word(ea, 2);
if ( h.name < h.size )
op_plain_offset(ea,0, start);
ea += 2;
set_name(ea, "type_lang", SN_IDBENC);
create_byte(ea, 1);
op_num(ea,0);
append_cmt(ea, get_os9_type_name(h.type_lang & OS9_TYPE), 0);
append_cmt(ea, get_os9_lang_name(h.type_lang & OS9_LANG), 0);
ea += 1;
set_name(ea, "attrib", SN_IDBENC);
create_byte(ea, 1);
op_num(ea,0);
if ( h.attrib & OS9_SHARED )
append_cmt(ea, "Shared module", 0);
ea += 1;
set_name(ea, "parity", SN_IDBENC);
create_byte(ea, 1);
op_num(ea,0);
ea += 1;
set_name(ea, "start_ptr", SN_IDBENC);
create_word(ea, 2);
op_plain_offset(ea,0, start);
ea += 2;
set_name(ea, "storage", SN_IDBENC);
create_word(ea, 2); op_num(ea,0);
inf_set_start_ip(LOADING_OFFSET + h.start);
inf_set_start_cs(inf_get_baseaddr());
}
//----------------------------------------------------------------------
void load_flex_file(linput_t *li)
{
qlseek(li, 0);
set_processor_type("6809", SETPROC_LOADER);
set_target_assembler(5);
ea_t bottom = BADADDR;
ea_t top = 0;
while ( 1 )
{
int c = qlgetc(li);
if ( c == EOF )
break;
switch ( c )
{
case 0:
break;
case 0x2:
{
c = qlgetc(li);
int adr = (c<<8) | qlgetc(li);
c = qlgetc(li); // number of bytes
ea_t start = to_ea(inf_get_baseaddr(), adr);
ea_t end = start + c;
file2base(li, qltell(li), start, end, FILEREG_PATCHABLE);
if ( bottom > start )
bottom = start;
if ( top < end )
top = end;
}
break;
case 0x16:
c = qlgetc(li);
inf_set_start_ip(int(c<<8) | qlgetc(li));
inf_set_start_cs(inf_get_baseaddr());
break;
default:
INTERR(20065);
}
}
create32(inf_get_baseaddr(), bottom, top, "TEXT", "CODE");
create_filename_cmt();
mc68xx_module_t::notify_flex_format(); // tell the module that the file has FLEX format
}
//----------------------------------------------------------------------
void idaapi load_file(linput_t *li,ushort /*_neflags*/,const char *fileformatname)
{
if ( strcmp(fileformatname, object_name) == 0 )
load_obj_file(li);
else
load_flex_file(li);
}
//--------------------------------------------------------------------------
loader_t LDSC =
{
IDP_INTERFACE_VERSION,
0, // loader flags
//
// check input file format. if recognized, then return 1
// and fill 'fileformatname'.
// otherwise return 0
//
accept_file,
//
// load file into the database.
//
load_file,
//
// create output file from the database.
// this function may be absent.
//
NULL,
// take care of a moved segment (fix up relocations, for example)
NULL,
NULL,
};

78
idasdk76/ldr/os9/os9.hpp Normal file
View File

@@ -0,0 +1,78 @@
/*
* Interactive disassembler (IDA).
* Copyright (c) 1990-99 by Ilfak Guilfanov <ig@datarescue.com>
* ALL RIGHTS RESERVED.
*
* This file describes two different formats:
* - OS9 object files
* - FLEX STX files
*
*/
#ifndef _OS9_HPP
#define _OS9_HPP
#pragma pack(push, 1)
//----------------------------------------------------------------------
//
// OS9 object code files have the following header at the start:
//
struct os9_header_t
{
ushort magic; // $00 2 Sync Bytes (always $87CD)
#define OS9_MAGIC 0x87CD
ushort size; // $02 2 Module Size (bytes)
ushort name; // $04 2 Module Name Offset
uchar type_lang; // $06 1 Type/Language
#define OS9_TYPE 0xF0 // Type
#define OS9_TYPE_ILL 0x00 // this one is illegal
#define OS9_TYPE_PRG 0x10 // Program module
#define OS9_TYPE_SUB 0x20 // Subroutine module
#define OS9_TYPE_MUL 0x30 // Multi-Module (for future use)
#define OS9_TYPE_DAT 0x40 // Data module
//#define OS9_$50-$B0 User defined
#define OS9_TYPE_SYS 0xC0 // OS-9 System Module
#define OS9_TYPE_FIL 0xD0 // OS-9 File Manager Module
#define OS9_TYPE_DRV 0xE0 // OS-9 Device Driver Module
#define OS9_TYPE_DDM 0xF0 // OS-9 Device Descriptor Module
#define OS9_LANG 0x0F // Language
#define OS9_LANG_DAT 0x00 // Data (not executable)
#define OS9_LANG_OBJ 0x01 // 6809 object code <- this is the only one to disassemble
#define OS9_LANG_BAS 0x02 // BASIC09 I-Code
#define OS9_LANG_PAS 0x03 // PASCAL P-Code
#define OS9_LANG_C 0x04 // C I-Code
#define OS9_LANG_CBL 0x05 // COBOL I-Code
#define OS9_LANG_FTN 0x06 // FORTRAN I-Code
uchar attrib; // $07 1 Attrib/Revision
#define OS9_REVSN 0x0F // Module revision
// The higher the number the more current
// the revision. When modules are loaded by
// the OS, if there is already module loaded
// with the same name, type, language, etc.
// the one with the highest revision will be used.
#define OS9_SHARED 0x80 // The module is reentrant and sharable
uchar parity; // $08 1 header parity byte
// It is the ones complement of the vertical
// parity (exclusive OR) of the previous
// eight bytes.
ushort start; // $09 2 Execution Offset
ushort storage; // $0B 2 Permenant Storage Requirements
// $0D Module Body
};
//----------------------------------------------------------------------
// Flex files have the following format:
// 0x02 0xYY 0xYY 0xZZ ...........
// where 0xYY is a 16 bit address, and 0xZZ is the byte count (0x00-0xFF).
// The reason for this is that the user could assign a program to be
// loaded and executed from anywhere in memory. So each executable file
// had the loading info in the file.
// 0x16 0xYY 0xYY
// The starting address of the program was specified in the binary files
// with a 0x16 0xYY 0xYY record. The 0xYY was the transfer address to be
// JMP'ed to when the program finished loading. This is the way FLEX and
// SK*DOS worked for the 6800, 6809 and 68K.
#pragma pack(pop)
#endif // define _OS9_HPP