490 lines
16 KiB
Plaintext
490 lines
16 KiB
Plaintext
#include <sys/types.h>
|
|
#include <sys/syscall.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
struct syscall
|
|
{
|
|
char *name;
|
|
int vec;
|
|
} syscalls[] =
|
|
{
|
|
#define SYSTEM_CALL(func,vec,args,stk) { #func, vec},
|
|
#include "../include/sys/syscall.def"
|
|
#undef SYSTEM_CALL
|
|
};
|
|
|
|
int nsyscall = sizeof(syscalls) / sizeof(syscalls[0]);
|
|
|
|
#define IXEMULBASE "_ixemulbase"
|
|
#define IXEMULBASELEN 11
|
|
|
|
#define BASEREL_OFFSET1 19
|
|
#define BASEREL_OFFSET2 31
|
|
|
|
/* The following code is a hexdump of this assembly program:
|
|
|
|
.globl _FUNCTION
|
|
_FUNCTION: movel a4@(_ixemulbase:W),a0
|
|
jmp a0@(OFFSET:w)
|
|
*/
|
|
|
|
static short baserel_code[] = {
|
|
0x0000, 0x0107, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0018, 0x0000, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
|
|
0x206c, 0x0000, 0x4ee8, 0xff46, 0x0000, 0x0002, 0x0000, 0x0138,
|
|
0x0000, 0x0004, 0x0500, 0x0000, 0x0000, 0x0000, 0x0000, 0x0011,
|
|
0x0100, 0x0000, 0x0000, 0x0000
|
|
};
|
|
|
|
#define LARGE_BASEREL_OFFSET1 21
|
|
#define LARGE_BASEREL_OFFSET2 33
|
|
|
|
/* The following code is a hexdump of this assembly program:
|
|
|
|
.globl _FUNCTION
|
|
_FUNCTION: movel a4@(_ixemulbase:L),a0
|
|
jmp a0@(OFFSET:w)
|
|
*/
|
|
|
|
static short large_baserel_code[] = {
|
|
0x0000, 0x0107, 0x0000, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0018, 0x0000, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
|
|
0x2074, 0x0170, 0x0000, 0x0000, 0x4ee8, 0xffe2, 0x0000, 0x0004,
|
|
0x0000, 0x0158, 0x0000, 0x0004, 0x0500, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x000e, 0x0100, 0x0000, 0x0000, 0x0000
|
|
};
|
|
|
|
#define NO_BASEREL_OFFSET1 20
|
|
#define NO_BASEREL_OFFSET2 33
|
|
|
|
/* The following code is a hexdump of this assembly program:
|
|
|
|
.globl _FUNCTION
|
|
_FUNCTION: movel _ixemulbase,a0
|
|
jmp a0@(OFFSET:w)
|
|
*/
|
|
|
|
static short no_baserel_code[] = {
|
|
0x0000, 0x0107, 0x0000, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0018, 0x0000, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
|
|
0x2079, 0x0000, 0x0000, 0x4ee8, 0xffe2, 0x0000, 0x0000, 0x0002,
|
|
0x0000, 0x0150, 0x0000, 0x0004, 0x0500, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x000b, 0x0100, 0x0000, 0x0000, 0x0000
|
|
};
|
|
|
|
|
|
#define PPC_NOBASEREL_OFFSET1 31
|
|
#define PPC_NOBASEREL_OFFSET2 0x0235
|
|
|
|
// assemble with ppc-amigaos-as
|
|
/* Generate this from this short ppc source:
|
|
|
|
.text
|
|
.global abcdefghijlkmnopqrstuvwxyzabcde
|
|
abcdefghijlkmnopqrstuvwxyzabcde:
|
|
|
|
lis 12,_ixbasearray@ha
|
|
lwz 12,_ixbasearray@l(12)
|
|
lwz 12,0(12)
|
|
mtctr 12
|
|
bctr
|
|
|
|
end:
|
|
.type abcdefghijlkmnopqrstuvwxyzabcde,@function
|
|
.size abcdefghijlkmnopqrstuvwxyzabcde,end-abcdefghijlkmnopqrstuvwxyzabcde
|
|
*/
|
|
static short powerup_code[] = {
|
|
0x7F45, 0x4C46, 0x0102, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0001, 0x0014, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0080, 0x0000, 0x0000, 0x0034, 0x0000, 0x0000, 0x0028,
|
|
0x0008, 0x0005, 0x3D80, 0x0000, 0x818C, 0x0000, 0x818C, 0x0000,
|
|
0x7D89, 0x03A6, 0x4E80, 0x0420, 0x002E, 0x7379, 0x6D74, 0x6162,
|
|
0x002E, 0x7374, 0x7274, 0x6162, 0x002E, 0x7368, 0x7374, 0x7274,
|
|
0x6162, 0x002E, 0x7465, 0x7874, 0x002E, 0x7265, 0x6C61, 0x2E74,
|
|
0x6578, 0x7400, 0x2E64, 0x6174, 0x6100, 0x2E62, 0x7373, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x001B, 0x0000, 0x0001,
|
|
0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0034, 0x0000, 0x0014,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0021, 0x0000, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0264, 0x0000, 0x0018, 0x0000, 0x0006, 0x0000, 0x0001,
|
|
0x0000, 0x0004, 0x0000, 0x000C, 0x0000, 0x002C, 0x0000, 0x0001,
|
|
0x0000, 0x0003, 0x0000, 0x0000, 0x0000, 0x0048, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0032, 0x0000, 0x0008, 0x0000, 0x0003, 0x0000, 0x0000,
|
|
0x0000, 0x0048, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0048, 0x0000, 0x0037,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0001, 0x0000, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x01C0, 0x0000, 0x0070, 0x0000, 0x0007, 0x0000, 0x0005,
|
|
0x0000, 0x0004, 0x0000, 0x0010, 0x0000, 0x0009, 0x0000, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0230, 0x0000, 0x0032,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0001,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0004,
|
|
0x0000, 0x0001, 0x0000, 0x0014, 0x0000, 0x0000, 0x0100, 0x0001,
|
|
0x0000, 0x0005, 0x0000, 0x0000, 0x0000, 0x0014, 0x1200, 0x0001,
|
|
0x0000, 0x0025, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000,
|
|
0x0065, 0x6E64, 0x0061, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6C,
|
|
0x6B6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7879, 0x7A61,
|
|
0x6263, 0x6465, 0x005F, 0x6978, 0x6261, 0x7365, 0x6172, 0x7261,
|
|
0x7900, 0x0000, 0x0000, 0x0002, 0x0000, 0x0606, 0x0000, 0x0000,
|
|
0x0000, 0x0006, 0x0000, 0x0604, 0x0000, 0x0000
|
|
};
|
|
|
|
#define PPC_BASEREL_OFFSET1 29
|
|
#define PPC_BASEREL_OFFSET2 0x0231
|
|
// assemble with ppc-amigaos-as
|
|
/* Generate this from this short ppc source:
|
|
|
|
.text
|
|
.global abcdefghijlkmnopqrstuvwxyzabcde
|
|
abcdefghijlkmnopqrstuvwxyzabcde:
|
|
|
|
lwz 12,_ixbasearray@sdarel(13)
|
|
lwz 12,0(12)
|
|
mtctr 12
|
|
bctr
|
|
|
|
end:
|
|
.type abcdefghijlkmnopqrstuvwxyzabcde,@function
|
|
.size abcdefghijlkmnopqrstuvwxyzabcde,end-abcdefghijlkmnopqrstuvwxyzabcde
|
|
*/
|
|
static short powerup_baserel_code[] = {
|
|
0x7F45, 0x4C46, 0x0102, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0001, 0x0014, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x007C, 0x0000, 0x0000, 0x0034, 0x0000, 0x0000, 0x0028,
|
|
0x0008, 0x0005, 0x818D, 0x0000, 0x818C, 0x0000, 0x7D89, 0x03A6,
|
|
0x4E80, 0x0420, 0x002E, 0x7379, 0x6D74, 0x6162, 0x002E, 0x7374,
|
|
0x7274, 0x6162, 0x002E, 0x7368, 0x7374, 0x7274, 0x6162, 0x002E,
|
|
0x7465, 0x7874, 0x002E, 0x7265, 0x6C61, 0x2E74, 0x6578, 0x7400,
|
|
0x2E64, 0x6174, 0x6100, 0x2E62, 0x7373, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x001B, 0x0000, 0x0001, 0x0000, 0x0006,
|
|
0x0000, 0x0000, 0x0000, 0x0034, 0x0000, 0x0010, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0021,
|
|
0x0000, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0260,
|
|
0x0000, 0x000C, 0x0000, 0x0006, 0x0000, 0x0001, 0x0000, 0x0004,
|
|
0x0000, 0x000C, 0x0000, 0x002C, 0x0000, 0x0001, 0x0000, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0044, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0032,
|
|
0x0000, 0x0008, 0x0000, 0x0003, 0x0000, 0x0000, 0x0000, 0x0044,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001,
|
|
0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0003, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0044, 0x0000, 0x0037, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0001,
|
|
0x0000, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01BC,
|
|
0x0000, 0x0070, 0x0000, 0x0007, 0x0000, 0x0005, 0x0000, 0x0004,
|
|
0x0000, 0x0010, 0x0000, 0x0009, 0x0000, 0x0003, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x022C, 0x0000, 0x0032, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0003, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0004, 0x0000, 0x0001,
|
|
0x0000, 0x0010, 0x0000, 0x0000, 0x0100, 0x0001, 0x0000, 0x0005,
|
|
0x0000, 0x0000, 0x0000, 0x0010, 0x1200, 0x0001, 0x0000, 0x0025,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x0065, 0x6E64,
|
|
0x0061, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6C, 0x6B6D, 0x6E6F,
|
|
0x7071, 0x7273, 0x7475, 0x7677, 0x7879, 0x7A61, 0x6263, 0x6465,
|
|
0x005F, 0x6978, 0x6261, 0x7365, 0x6172, 0x7261, 0x7900, 0x0000,
|
|
0x0000, 0x0002, 0x0000, 0x0620, 0x0000, 0x0000
|
|
};
|
|
|
|
|
|
#define PPC_LBASEREL_OFFSET1 31
|
|
#define PPC_LBASEREL_OFFSET2 0x0235
|
|
|
|
// assemble with ppc-amigaos-as
|
|
/* Generate this from this short ppc source:
|
|
|
|
.text
|
|
.global abcdefghijlkmnopqrstuvwxyzabcde
|
|
abcdefghijlkmnopqrstuvwxyzabcde:
|
|
|
|
addis 12,13,_ixbasearray@drelha
|
|
lwz 12,_ixbasearray@drell(12)
|
|
lwz 12,0(12)
|
|
mtctr 12
|
|
bctr
|
|
|
|
end:
|
|
.type abcdefghijlkmnopqrstuvwxyzabcde,@function
|
|
.size abcdefghijlkmnopqrstuvwxyzabcde,end-abcdefghijlkmnopqrstuvwxyzabcde
|
|
*/
|
|
static short powerup_lbaserel_code[] = {
|
|
0x7F45, 0x4C46, 0x0102, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0001, 0x0014, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0080, 0x0000, 0x0000, 0x0034, 0x0000, 0x0000, 0x0028,
|
|
0x0008, 0x0005, 0x3D8D, 0x0000, 0x818C, 0x0000, 0x818C, 0x0000,
|
|
0x7D89, 0x03A6, 0x4E80, 0x0420, 0x002E, 0x7379, 0x6D74, 0x6162,
|
|
0x002E, 0x7374, 0x7274, 0x6162, 0x002E, 0x7368, 0x7374, 0x7274,
|
|
0x6162, 0x002E, 0x7465, 0x7874, 0x002E, 0x7265, 0x6C61, 0x2E74,
|
|
0x6578, 0x7400, 0x2E64, 0x6174, 0x6100, 0x2E62, 0x7373, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x001B, 0x0000, 0x0001,
|
|
0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0034, 0x0000, 0x0014,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0021, 0x0000, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0264, 0x0000, 0x0018, 0x0000, 0x0006, 0x0000, 0x0001,
|
|
0x0000, 0x0004, 0x0000, 0x000C, 0x0000, 0x002C, 0x0000, 0x0001,
|
|
0x0000, 0x0003, 0x0000, 0x0000, 0x0000, 0x0048, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0032, 0x0000, 0x0008, 0x0000, 0x0003, 0x0000, 0x0000,
|
|
0x0000, 0x0048, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0048, 0x0000, 0x0037,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0001, 0x0000, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x01C0, 0x0000, 0x0070, 0x0000, 0x0007, 0x0000, 0x0005,
|
|
0x0000, 0x0004, 0x0000, 0x0010, 0x0000, 0x0009, 0x0000, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0230, 0x0000, 0x0032,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0001,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0003,
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0004,
|
|
0x0000, 0x0001, 0x0000, 0x0014, 0x0000, 0x0000, 0x0100, 0x0001,
|
|
0x0000, 0x0005, 0x0000, 0x0000, 0x0000, 0x0014, 0x1200, 0x0001,
|
|
0x0000, 0x0025, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000,
|
|
0x0065, 0x6E64, 0x0061, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6C,
|
|
0x6B6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7879, 0x7A61,
|
|
0x6263, 0x6465, 0x005F, 0x6978, 0x6261, 0x7365, 0x6172, 0x7261,
|
|
0x7900, 0x0000, 0x0000, 0x0002, 0x0000, 0x06CB, 0x0000, 0x0000,
|
|
0x0000, 0x0006, 0x0000, 0x06C9, 0x0000, 0x0000
|
|
};
|
|
|
|
#define PROFILING_OFFSET1 29
|
|
#define PROFILING_OFFSET2 51
|
|
#define PROFILING_OFFSET3 57
|
|
#define PROFILING_OFFSET4 63
|
|
|
|
/* The following code is a hexdump of this assembly program:
|
|
|
|
.globl _FUNCTION
|
|
_FUNCTION:
|
|
.data
|
|
PROFFUNCTION:
|
|
.long 0
|
|
|
|
.text
|
|
link a5,#0
|
|
lea PROFFUNCTION,a0
|
|
jsr mcount
|
|
unlk a5
|
|
movel _ixemulbase,a0
|
|
jmp a0@(OFFSET:w)
|
|
*/
|
|
|
|
static short profiling_code[] = {
|
|
0x0000, 0x0107, 0x0000, 0x001c, 0x0000, 0x0004, 0x0000, 0x0000,
|
|
0x0000, 0x0030, 0x0000, 0x0000, 0x0000, 0x0018, 0x0000, 0x0000,
|
|
0x4e55, 0x0000, 0x41f9, 0x0000, 0x001c, 0x4eb9, 0x0000, 0x0000,
|
|
0x4e5d, 0x2079, 0x0000, 0x0000, 0x4ee8, 0xffe2, 0x0000, 0x0000,
|
|
0x0000, 0x0006, 0x0000, 0x0640, 0x0000, 0x000c, 0x0000, 0x0250,
|
|
0x0000, 0x0014, 0x0000, 0x0350, 0x0000, 0x0004, 0x0500, 0x0000,
|
|
0x0000, 0x0000, 0x0000, 0x000b, 0x0600, 0x0000, 0x0000, 0x001c,
|
|
0x0000, 0x0015, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x001c,
|
|
0x0100, 0x0000, 0x0000, 0x0000
|
|
};
|
|
|
|
|
|
void usage(void)
|
|
{
|
|
fprintf(stderr, "Usage: gen_glue baserel | large-baserel | no-baserel |" " powerup | powerup-rel | morphos | morphos-rel | profiling\n");
|
|
exit(1);
|
|
}
|
|
|
|
void write_code(short *code, int len, FILE * f)
|
|
{
|
|
const short endian = 0x0100;
|
|
|
|
/* test if gen_glue is compiled on a big or little endian machine */
|
|
if (((char *)&endian)[0])
|
|
{
|
|
fwrite(code, len, 1, f); /* big endian */
|
|
}
|
|
else
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < len / 2; i++)
|
|
{
|
|
short x = code[i]; /* little endian */
|
|
|
|
fputc(((char *)&x)[1], f);
|
|
fputc(((char *)&x)[0], f);
|
|
}
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
FILE *fp;
|
|
struct syscall *sc;
|
|
int i, v, baserel = 0, profiling = 0, lbaserel = 0, powerup = 0, morphos = 0;
|
|
short *code;
|
|
int offset1, offset2, size;
|
|
int zero = 0;
|
|
|
|
if (argc != 2)
|
|
usage();
|
|
if (!strcmp(argv[1], "baserel"))
|
|
baserel = 1;
|
|
else if (!strcmp(argv[1], "baserel32"))
|
|
lbaserel = 1;
|
|
else if (!strcmp(argv[1], "profiling"))
|
|
profiling = 1;
|
|
else if (!strcmp(argv[1], "powerup"))
|
|
powerup = 1;
|
|
else if (!strcmp(argv[1], "powerup-rel"))
|
|
powerup = 1, baserel = 1;
|
|
else if (!strcmp(argv[1], "morphos"))
|
|
morphos = 1;
|
|
else if (!strcmp(argv[1], "morphos-rel"))
|
|
morphos = 1, baserel = 1;
|
|
else if (!strcmp(argv[1], "morphos-rel32"))
|
|
morphos = 1, lbaserel = 1;
|
|
else if (strcmp(argv[1], "no-baserel"))baserel = 0;
|
|
//usage();
|
|
|
|
for (i = 0, sc = syscalls; i < nsyscall; i++, sc++)
|
|
{
|
|
int namelen = strlen(sc->name);
|
|
char name[namelen + 3];
|
|
#if 0
|
|
if (powerup)
|
|
{
|
|
switch (sc->vec)
|
|
{
|
|
case SYS_memcpy:
|
|
/*
|
|
case SYS_strcpy:
|
|
case SYS_strlen:
|
|
case SYS_strcmp:
|
|
*/
|
|
case SYS_sin:
|
|
case SYS_cos:
|
|
case SYS_sqrt:
|
|
case SYS_exp:
|
|
case SYS_log:
|
|
case SYS_log10:
|
|
case SYS_pow:
|
|
case SYS_atan:
|
|
case SYS_acos:
|
|
case SYS_asin:
|
|
case SYS_ceil:
|
|
case SYS_floor:
|
|
case SYS_fabs:
|
|
case SYS_frexp:
|
|
case SYS_isnan:
|
|
continue;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
if (!memcmp(sc->name, "__obsolete", 10))
|
|
continue;
|
|
if (!memcmp(sc->name, "__must_recompile", 16))
|
|
continue;
|
|
if (!memcmp(sc->name, "__stk", 5))
|
|
continue;
|
|
v = -(sc->vec + 4) * 6;
|
|
sprintf(name, "%s.o", sc->name);
|
|
|
|
fp = fopen(name, "w");
|
|
|
|
if (!fp)
|
|
{
|
|
perror(sc->name);
|
|
exit(20);
|
|
}
|
|
|
|
code = no_baserel_code;
|
|
size = sizeof(no_baserel_code);
|
|
offset1 = NO_BASEREL_OFFSET1;
|
|
offset2 = NO_BASEREL_OFFSET2;
|
|
if (powerup || morphos)
|
|
{
|
|
if (baserel)
|
|
{
|
|
powerup_baserel_code[PPC_BASEREL_OFFSET1] = (sc->vec - 1) * 4;
|
|
|
|
write_code(powerup_baserel_code, sizeof(powerup_baserel_code), fp);
|
|
fseek(fp, PPC_BASEREL_OFFSET2, SEEK_SET);
|
|
fwrite(sc->name, namelen + 1, 1, fp);
|
|
}
|
|
else if (lbaserel)
|
|
{
|
|
powerup_lbaserel_code[PPC_LBASEREL_OFFSET1] = (sc->vec - 1) * 4;
|
|
|
|
write_code(powerup_lbaserel_code, sizeof(powerup_lbaserel_code), fp);
|
|
fseek(fp, PPC_LBASEREL_OFFSET2, SEEK_SET);
|
|
fwrite(sc->name, namelen + 1, 1, fp);
|
|
}
|
|
else
|
|
{
|
|
powerup_code[PPC_NOBASEREL_OFFSET1] = (sc->vec - 1) * 4;
|
|
|
|
write_code(powerup_code, sizeof(powerup_code), fp);
|
|
fseek(fp, PPC_NOBASEREL_OFFSET2, SEEK_SET);
|
|
fwrite(sc->name, namelen + 1, 1, fp);
|
|
}
|
|
}
|
|
#if 0
|
|
else
|
|
{
|
|
if (profiling)
|
|
{
|
|
profiling_code[PROFILING_OFFSET1] = v;
|
|
profiling_code[PROFILING_OFFSET2] = 6 + namelen;
|
|
profiling_code[PROFILING_OFFSET3] = 6 + namelen * 2 + 5;
|
|
profiling_code[PROFILING_OFFSET4] = 6 + namelen * 2 + 5 + 7;
|
|
write_code(profiling_code, sizeof(profiling_code), fp);
|
|
fwrite(&zero, 3, 1, fp);
|
|
fputc((char)(namelen * 2 + 7 + IXEMULBASELEN + 1 + 7 + 4), fp);
|
|
fputc('_', fp);
|
|
fwrite(sc->name, namelen + 1, 1, fp);
|
|
fprintf(fp, "PROF");
|
|
fwrite(sc->name, namelen + 1, 1, fp);
|
|
fwrite("mcount", 7, 1, fp);
|
|
}
|
|
else
|
|
{
|
|
if (baserel && sc->vec != SYS_ix_geta4)
|
|
{
|
|
code = baserel_code;
|
|
size = sizeof(baserel_code);
|
|
offset1 = BASEREL_OFFSET1;
|
|
offset2 = BASEREL_OFFSET2;
|
|
}
|
|
else if (lbaserel && sc->vec != SYS_ix_geta4)
|
|
{
|
|
code = large_baserel_code;
|
|
size = sizeof(large_baserel_code);
|
|
offset1 = LARGE_BASEREL_OFFSET1;
|
|
offset2 = LARGE_BASEREL_OFFSET2;
|
|
}
|
|
code[offset1] = v;
|
|
code[offset2] = namelen + 4 + 2;
|
|
write_code(code, size, fp);
|
|
fwrite(&zero, 3, 1, fp);
|
|
fputc((char)(namelen + 2 + IXEMULBASELEN + 1 + 4), fp);
|
|
fputc('_', fp);
|
|
fwrite(sc->name, namelen + 1, 1, fp);
|
|
}
|
|
fwrite(IXEMULBASE, IXEMULBASELEN + 1, 1, fp);
|
|
}
|
|
#endif
|
|
fclose(fp);
|
|
}
|
|
exit(0);
|
|
}
|