File tree Expand file tree Collapse file tree 6 files changed +173
-0
lines changed
tools/objtool/arch/loongarch Expand file tree Collapse file tree 6 files changed +173
-0
lines changed Original file line number Diff line number Diff line change
1
+ objtool-y += decode.o
2
+ objtool-y += special.o
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-or-later
2
+ #include <string.h>
3
+ #include <objtool/check.h>
4
+
5
+ int arch_ftrace_match (char * name )
6
+ {
7
+ return !strcmp (name , "_mcount" );
8
+ }
9
+
10
+ unsigned long arch_jump_destination (struct instruction * insn )
11
+ {
12
+ return insn -> offset + (insn -> immediate << 2 );
13
+ }
14
+
15
+ unsigned long arch_dest_reloc_offset (int addend )
16
+ {
17
+ return addend ;
18
+ }
19
+
20
+ bool arch_pc_relative_reloc (struct reloc * reloc )
21
+ {
22
+ return false;
23
+ }
24
+
25
+ bool arch_callee_saved_reg (unsigned char reg )
26
+ {
27
+ switch (reg ) {
28
+ case CFI_RA :
29
+ case CFI_FP :
30
+ case CFI_S0 ... CFI_S8 :
31
+ return true;
32
+ default :
33
+ return false;
34
+ }
35
+ }
36
+
37
+ int arch_decode_hint_reg (u8 sp_reg , int * base )
38
+ {
39
+ return 0 ;
40
+ }
41
+
42
+ int arch_decode_instruction (struct objtool_file * file , const struct section * sec ,
43
+ unsigned long offset , unsigned int maxlen ,
44
+ struct instruction * insn )
45
+ {
46
+ return 0 ;
47
+ }
48
+
49
+ const char * arch_nop_insn (int len )
50
+ {
51
+ return NULL ;
52
+ }
53
+
54
+ const char * arch_ret_insn (int len )
55
+ {
56
+ return NULL ;
57
+ }
58
+
59
+ void arch_initial_func_cfi_state (struct cfi_init_state * state )
60
+ {
61
+ int i ;
62
+
63
+ for (i = 0 ; i < CFI_NUM_REGS ; i ++ ) {
64
+ state -> regs [i ].base = CFI_UNDEFINED ;
65
+ state -> regs [i ].offset = 0 ;
66
+ }
67
+
68
+ /* initial CFA (call frame address) */
69
+ state -> cfa .base = CFI_SP ;
70
+ state -> cfa .offset = 0 ;
71
+ }
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-or-later */
2
+ #ifndef _OBJTOOL_ARCH_CFI_REGS_H
3
+ #define _OBJTOOL_ARCH_CFI_REGS_H
4
+
5
+ #define CFI_RA 1
6
+ #define CFI_SP 3
7
+ #define CFI_A0 4
8
+ #define CFI_FP 22
9
+ #define CFI_S0 23
10
+ #define CFI_S1 24
11
+ #define CFI_S2 25
12
+ #define CFI_S3 26
13
+ #define CFI_S4 27
14
+ #define CFI_S5 28
15
+ #define CFI_S6 29
16
+ #define CFI_S7 30
17
+ #define CFI_S8 31
18
+ #define CFI_NUM_REGS 32
19
+
20
+ #define CFI_BP CFI_FP
21
+
22
+ #endif /* _OBJTOOL_ARCH_CFI_REGS_H */
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-or-later */
2
+ #ifndef _OBJTOOL_ARCH_ELF_H
3
+ #define _OBJTOOL_ARCH_ELF_H
4
+
5
+ /*
6
+ * See the following link for more info about ELF Relocation types:
7
+ * https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_relocations
8
+ */
9
+ #ifndef R_LARCH_NONE
10
+ #define R_LARCH_NONE 0
11
+ #endif
12
+ #ifndef R_LARCH_32
13
+ #define R_LARCH_32 1
14
+ #endif
15
+ #ifndef R_LARCH_64
16
+ #define R_LARCH_64 2
17
+ #endif
18
+ #ifndef R_LARCH_32_PCREL
19
+ #define R_LARCH_32_PCREL 99
20
+ #endif
21
+
22
+ #define R_NONE R_LARCH_NONE
23
+ #define R_ABS32 R_LARCH_32
24
+ #define R_ABS64 R_LARCH_64
25
+ #define R_DATA32 R_LARCH_32_PCREL
26
+ #define R_DATA64 R_LARCH_32_PCREL
27
+ #define R_TEXT32 R_LARCH_32_PCREL
28
+ #define R_TEXT64 R_LARCH_32_PCREL
29
+
30
+ #endif /* _OBJTOOL_ARCH_ELF_H */
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-or-later */
2
+ #ifndef _OBJTOOL_ARCH_SPECIAL_H
3
+ #define _OBJTOOL_ARCH_SPECIAL_H
4
+
5
+ /*
6
+ * See more info about struct exception_table_entry
7
+ * in arch/loongarch/include/asm/extable.h
8
+ */
9
+ #define EX_ENTRY_SIZE 12
10
+ #define EX_ORIG_OFFSET 0
11
+ #define EX_NEW_OFFSET 4
12
+
13
+ /*
14
+ * See more info about struct jump_entry
15
+ * in include/linux/jump_label.h
16
+ */
17
+ #define JUMP_ENTRY_SIZE 16
18
+ #define JUMP_ORIG_OFFSET 0
19
+ #define JUMP_NEW_OFFSET 4
20
+ #define JUMP_KEY_OFFSET 8
21
+
22
+ /*
23
+ * See more info about struct alt_instr
24
+ * in arch/loongarch/include/asm/alternative.h
25
+ */
26
+ #define ALT_ENTRY_SIZE 12
27
+ #define ALT_ORIG_OFFSET 0
28
+ #define ALT_NEW_OFFSET 4
29
+ #define ALT_FEATURE_OFFSET 8
30
+ #define ALT_ORIG_LEN_OFFSET 10
31
+ #define ALT_NEW_LEN_OFFSET 11
32
+
33
+ #endif /* _OBJTOOL_ARCH_SPECIAL_H */
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-or-later
2
+ #include <objtool/special.h>
3
+
4
+ bool arch_support_alt_relocation (struct special_alt * special_alt ,
5
+ struct instruction * insn ,
6
+ struct reloc * reloc )
7
+ {
8
+ return false;
9
+ }
10
+
11
+ struct reloc * arch_find_switch_table (struct objtool_file * file ,
12
+ struct instruction * insn )
13
+ {
14
+ return NULL ;
15
+ }
You can’t perform that action at this time.
0 commit comments