summaryrefslogtreecommitdiff
path: root/misc/genscripts.sh
blob: 5fafa335fc7dc87314140e8eb1cb7af80a77d255 (plain) (blame)
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
#!/bin/sh

# This shell script will generate the playstation.x linker script, and the psx-gcc and psx-elf2x shell scripts.

# You have to pass the PREFIX of the toolchain as the first argument of this shell script

echo "/* 
 * Linker script to generate an ELF file
 * that has to be converted to PS-X EXE.
 */

TARGET(\"elf32-littlemips\")
OUTPUT_ARCH(\"mips\")

ENTRY(\"_start\")

SEARCH_DIR(\"$1/lib\")
STARTUP(start.o)
INPUT(-lpsx -lgcc)

SECTIONS
{
	. = 0x80010000;

	.text ALIGN(4) :
	{
		*(.text*)
	}

	.rodata ALIGN(4) :
	{
		*(.rodata)
	}

	.data ALIGN(4) :
	{
		 *(.data)
	}

	.ctors ALIGN(4) :
	{
		*(.ctors)
	}

	.dtors ALIGN(4) :
 	{
		*(.dtors)
	}

	.bss  ALIGN(4) :
	{
		*(.bss)
		*(.bss.*)
		*(.gnu.linkonce.b.*)
		*(COMMON)
		*(.sbss)
		*(.sbss.*)
		*(.gnu.linkonce.sb.*)
		*(.scommon)
	}

	__text_start = ADDR(.text);
	__text_end = ADDR(.text) + SIZEOF(.text);

	__rodata_start = ADDR(.rodata);
	__rodata_end = ADDR(.rodata) + SIZEOF(.rodata);

	__data_start = ADDR(.data);
	__data_end = ADDR(.data) + SIZEOF(.data);

	__ctor_list = ADDR(.ctors);
	__ctor_end = ADDR(.ctors) + SIZEOF(.ctors);

	__dtor_list = ADDR(.dtors);
	__dtor_end = ADDR(.dtors) + SIZEOF(.dtors);
	
	__bss_start = ADDR(.bss);
	__bss_end = ADDR(.bss) + SIZEOF(.bss);
	
	__scratchpad = 0x1f800000;
}
" > playstation.x

echo "#!/bin/sh
mipsel-unknown-elf-gcc -D__PSXSDK__ -fno-strict-overflow -fsigned-char -msoft-float -mno-gpopt -fno-builtin -g -I$1/include -T $1/mipsel-unknown-elf/lib/ldscripts/playstation.x \$*"> psx-gcc
chmod +x psx-gcc
echo "#!/bin/sh
mipsel-unknown-elf-g++ -D__PSXSDK__ -fno-strict-overflow -fsigned-char -msoft-float -mno-gpopt -fno-builtin -g -I$1/include -T $1/mipsel-unknown-elf/lib/ldscripts/playstation.x -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-use-cxa-atexit \$*" > psx-g++
chmod +x psx-g++