0001
0002 #ifndef _LINUX_OBJTOOL_H
0003 #define _LINUX_OBJTOOL_H
0004
0005 #ifndef __ASSEMBLY__
0006
0007 #include <linux/types.h>
0008
0009
0010
0011
0012
0013 struct unwind_hint {
0014 u32 ip;
0015 s16 sp_offset;
0016 u8 sp_reg;
0017 u8 type;
0018 u8 end;
0019 };
0020 #endif
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #define UNWIND_HINT_TYPE_CALL 0
0039 #define UNWIND_HINT_TYPE_REGS 1
0040 #define UNWIND_HINT_TYPE_REGS_PARTIAL 2
0041 #define UNWIND_HINT_TYPE_FUNC 3
0042 #define UNWIND_HINT_TYPE_ENTRY 4
0043 #define UNWIND_HINT_TYPE_SAVE 5
0044 #define UNWIND_HINT_TYPE_RESTORE 6
0045
0046 #ifdef CONFIG_OBJTOOL
0047
0048 #include <asm/asm.h>
0049
0050 #ifndef __ASSEMBLY__
0051
0052 #define UNWIND_HINT(sp_reg, sp_offset, type, end) \
0053 "987: \n\t" \
0054 ".pushsection .discard.unwind_hints\n\t" \
0055 \
0056 ".long 987b - .\n\t" \
0057 ".short " __stringify(sp_offset) "\n\t" \
0058 ".byte " __stringify(sp_reg) "\n\t" \
0059 ".byte " __stringify(type) "\n\t" \
0060 ".byte " __stringify(end) "\n\t" \
0061 ".balign 4 \n\t" \
0062 ".popsection\n\t"
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 #define STACK_FRAME_NON_STANDARD(func) \
0073 static void __used __section(".discard.func_stack_frame_non_standard") \
0074 *__func_stack_frame_non_standard_##func = func
0075
0076
0077
0078
0079
0080
0081 #ifdef CONFIG_FRAME_POINTER
0082 #define STACK_FRAME_NON_STANDARD_FP(func) STACK_FRAME_NON_STANDARD(func)
0083 #else
0084 #define STACK_FRAME_NON_STANDARD_FP(func)
0085 #endif
0086
0087 #define ANNOTATE_NOENDBR \
0088 "986: \n\t" \
0089 ".pushsection .discard.noendbr\n\t" \
0090 _ASM_PTR " 986b\n\t" \
0091 ".popsection\n\t"
0092
0093 #define ASM_REACHABLE \
0094 "998:\n\t" \
0095 ".pushsection .discard.reachable\n\t" \
0096 ".long 998b - .\n\t" \
0097 ".popsection\n\t"
0098
0099 #else
0100
0101
0102
0103
0104
0105 #define ANNOTATE_INTRA_FUNCTION_CALL \
0106 999: \
0107 .pushsection .discard.intra_function_calls; \
0108 .long 999b; \
0109 .popsection;
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 .macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 end=0
0133 .Lunwind_hint_ip_\@:
0134 .pushsection .discard.unwind_hints
0135
0136 .long .Lunwind_hint_ip_\@ - .
0137 .short \sp_offset
0138 .byte \sp_reg
0139 .byte \type
0140 .byte \end
0141 .balign 4
0142 .popsection
0143 .endm
0144
0145 .macro STACK_FRAME_NON_STANDARD func:req
0146 .pushsection .discard.func_stack_frame_non_standard, "aw"
0147 _ASM_PTR \func
0148 .popsection
0149 .endm
0150
0151 .macro STACK_FRAME_NON_STANDARD_FP func:req
0152 #ifdef CONFIG_FRAME_POINTER
0153 STACK_FRAME_NON_STANDARD \func
0154 #endif
0155 .endm
0156
0157 .macro ANNOTATE_NOENDBR
0158 .Lhere_\@:
0159 .pushsection .discard.noendbr
0160 .quad .Lhere_\@
0161 .popsection
0162 .endm
0163
0164 .macro REACHABLE
0165 .Lhere_\@:
0166 .pushsection .discard.reachable
0167 .long .Lhere_\@ - .
0168 .popsection
0169 .endm
0170
0171 #endif
0172
0173 #else
0174
0175 #ifndef __ASSEMBLY__
0176
0177 #define UNWIND_HINT(sp_reg, sp_offset, type, end) \
0178 "\n\t"
0179 #define STACK_FRAME_NON_STANDARD(func)
0180 #define STACK_FRAME_NON_STANDARD_FP(func)
0181 #define ANNOTATE_NOENDBR
0182 #define ASM_REACHABLE
0183 #else
0184 #define ANNOTATE_INTRA_FUNCTION_CALL
0185 .macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 end=0
0186 .endm
0187 .macro STACK_FRAME_NON_STANDARD func:req
0188 .endm
0189 .macro ANNOTATE_NOENDBR
0190 .endm
0191 .macro REACHABLE
0192 .endm
0193 #endif
0194
0195 #endif
0196
0197 #endif