1
- //! Targets the Nintendo Game Boy Advance (GBA).
1
+ //! Targets the Nintendo Game Boy Advance (GBA), a handheld game device from 2001 .
2
2
//!
3
- //! The GBA is a handheld game device from 2001. Inside, the CPU is an ARM7TDMI.
4
- //! That's in the ARMv4T architecture family.
3
+ //! Please ping @Lokathor if changes are needed.
5
4
//!
6
- //! Technically the device has no OS, however we're going to copy the
7
- //! `mipsel_sony_psp` target setup and set the OS string to be "GBA". Other than
8
- //! the setting of the `target_os` and `target_vendor` values, this target is a
9
- //! fairly standard configuration for `thumbv4t`
5
+ //! Important: This target **does not** specify a linker script or the ROM
6
+ //! header. You'll still need to provide these yourself to construct a final
7
+ //! binary. Generally you'd do this with something like
8
+ //! `-Clink-arg=-Tmy_script.ld` and `-Clink-arg=my_crt.o`.
10
9
11
10
use crate :: spec:: { LinkerFlavor , LldFlavor , Target , TargetOptions , TargetResult } ;
12
11
@@ -16,14 +15,65 @@ pub fn target() -> TargetResult {
16
15
target_endian : "little" . to_string ( ) ,
17
16
target_pointer_width : "32" . to_string ( ) ,
18
17
target_c_int_width : "32" . to_string ( ) ,
19
- target_os : "gba " . to_string ( ) ,
20
- target_env : String :: new ( ) ,
18
+ target_os : "none " . to_string ( ) ,
19
+ target_env : "gba" . to_string ( ) ,
21
20
target_vendor : "nintendo" . to_string ( ) ,
22
21
arch : "arm" . to_string ( ) ,
23
- data_layout : "TODO" . to_string ( ) ,
22
+ /* Data layout args are '-' separated:
23
+ * little endian
24
+ * stack is 64-bit aligned (EABI)
25
+ * pointers are 32-bit
26
+ * i64 must be 64-bit aligned (EABI)
27
+ * mangle names with ELF style
28
+ * native integers are 32-bit
29
+ * All other elements are default
30
+ */
31
+ data_layout : "e-S64-p:32:32-i64:64-m:e-n32" . to_string ( ) ,
24
32
linker_flavor : LinkerFlavor :: Ld ,
25
33
options : TargetOptions {
26
- // TODO
34
+ linker : Some ( "arm-none-eabi-ld" . to_string ( ) ) ,
35
+ linker_is_gnu : true ,
36
+
37
+ // extra args passed to the external assembler
38
+ asm_args : vec ! [ "-mcpu=arm7tdmi" . to_string( ) , "-mthumb-interwork" . to_string( ) ] ,
39
+
40
+ cpu : "arm7tdmi" . to_string ( ) ,
41
+
42
+ // minimum extra features, these cannot be disabled via -C
43
+ features : "+soft-float,+strict-align" . to_string ( ) ,
44
+
45
+ executables : true ,
46
+
47
+ relocation_model : RelocModel :: Static ,
48
+
49
+ //function_sections: bool,
50
+ //exe_suffix: String,
51
+ main_needs_argc_argv : false ,
52
+
53
+ // if we have thread-local storage
54
+ has_elf_tls : false ,
55
+
56
+ // don't have atomic compare-and-swap
57
+ atomic_cas : false ,
58
+
59
+ // always just abort
60
+ panic_strategy : PanicStrategy :: Abort ,
61
+
62
+ // ABIs to not use
63
+ unsupported_abis : super :: arm_base:: unsupported_abis ( ) ,
64
+
65
+ // The minimum alignment for global symbols.
66
+ min_global_align : Some ( 4 ) ,
67
+
68
+ // no threads here
69
+ singlethread : true ,
70
+
71
+ // GBA has no builtins
72
+ no_builtins : true ,
73
+
74
+ // this is off just like in the `thumb_base`
75
+ emit_debug_gdb_scripts : false ,
76
+
27
77
..TargetOptions :: default ( )
28
78
} ,
29
79
} )
0 commit comments