Merge tag 'objtool-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull build tooling updates from Thomas Gleixner:

- Remove obsolete CONFIG_X86_SMAP reference from objtool

- Fix overlapping text section failures in faddr2line for real

- Remove OBJECT_FILES_NON_STANDARD usage from x86 ftrace and replace it
with finegrained annotations so objtool can validate that code
correctly.

* tag 'objtool-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/ftrace: Remove OBJECT_FILES_NON_STANDARD usage
faddr2line: Fix overlapping text section failures, the sequel
objtool: Fix obsolete reference to CONFIG_X86_SMAP

Changed files
+55 -19
arch
x86
include
linux
lib
scripts
tools
include
linux
-4
arch/x86/kernel/Makefile
··· 36 36 37 37 OBJECT_FILES_NON_STANDARD_test_nx.o := y 38 38 39 - ifdef CONFIG_FRAME_POINTER 40 - OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y 41 - endif 42 - 43 39 # If instrumentation of this dir is enabled, boot hangs during first second. 44 40 # Probably could be more selective here, but note that files related to irqs, 45 41 # boot, dumpstack/stacktrace, etc are either non-interesting or can lead to
+8 -3
arch/x86/kernel/ftrace_64.S
··· 175 175 176 176 jmp ftrace_epilogue 177 177 SYM_FUNC_END(ftrace_caller); 178 + STACK_FRAME_NON_STANDARD_FP(ftrace_caller) 178 179 179 180 SYM_FUNC_START(ftrace_epilogue) 180 181 /* ··· 283 282 jmp ftrace_epilogue 284 283 285 284 SYM_FUNC_END(ftrace_regs_caller) 285 + STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller) 286 286 287 287 288 288 #else /* ! CONFIG_DYNAMIC_FTRACE */ ··· 313 311 jmp ftrace_stub 314 312 SYM_FUNC_END(__fentry__) 315 313 EXPORT_SYMBOL(__fentry__) 314 + STACK_FRAME_NON_STANDARD_FP(__fentry__) 315 + 316 316 #endif /* CONFIG_DYNAMIC_FTRACE */ 317 317 318 318 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 319 - SYM_FUNC_START(return_to_handler) 319 + SYM_CODE_START(return_to_handler) 320 + UNWIND_HINT_EMPTY 321 + ANNOTATE_NOENDBR 320 322 subq $16, %rsp 321 323 322 324 /* Save the return values */ ··· 345 339 int3 346 340 .Ldo_rop: 347 341 mov %rdi, (%rsp) 348 - UNWIND_HINT_FUNC 349 342 RET 350 - SYM_FUNC_END(return_to_handler) 343 + SYM_CODE_END(return_to_handler) 351 344 #endif
+6
include/linux/objtool.h
··· 143 143 .popsection 144 144 .endm 145 145 146 + .macro STACK_FRAME_NON_STANDARD_FP func:req 147 + #ifdef CONFIG_FRAME_POINTER 148 + STACK_FRAME_NON_STANDARD \func 149 + #endif 150 + .endm 151 + 146 152 .macro ANNOTATE_NOENDBR 147 153 .Lhere_\@: 148 154 .pushsection .discard.noendbr
+1 -1
lib/Kconfig.ubsan
··· 94 94 bool "Perform checking for unreachable code" 95 95 # objtool already handles unreachable checking and gets angry about 96 96 # seeing UBSan instrumentation located in unreachable places. 97 - depends on !(OBJTOOL && (STACK_VALIDATION || UNWINDER_ORC || X86_SMAP)) 97 + depends on !(OBJTOOL && (STACK_VALIDATION || UNWINDER_ORC || HAVE_UACCESS_VALIDATION)) 98 98 depends on $(cc-option,-fsanitize=unreachable) 99 99 help 100 100 This option enables -fsanitize=unreachable which checks for control
+34 -11
scripts/faddr2line
··· 95 95 local print_warnings=$4 96 96 97 97 local sym_name=${func_addr%+*} 98 - local offset=${func_addr#*+} 99 - offset=${offset%/*} 98 + local func_offset=${func_addr#*+} 99 + func_offset=${func_offset%/*} 100 100 local user_size= 101 + local file_type 102 + local is_vmlinux=0 101 103 [[ $func_addr =~ "/" ]] && user_size=${func_addr#*/} 102 104 103 - if [[ -z $sym_name ]] || [[ -z $offset ]] || [[ $sym_name = $func_addr ]]; then 105 + if [[ -z $sym_name ]] || [[ -z $func_offset ]] || [[ $sym_name = $func_addr ]]; then 104 106 warn "bad func+offset $func_addr" 105 107 DONE=1 106 108 return 107 109 fi 110 + 111 + # vmlinux uses absolute addresses in the section table rather than 112 + # section offsets. 113 + local file_type=$(${READELF} --file-header $objfile | 114 + ${AWK} '$1 == "Type:" { print $2; exit }') 115 + [[ $file_type = "EXEC" ]] && is_vmlinux=1 108 116 109 117 # Go through each of the object's symbols which match the func name. 110 118 # In rare cases there might be duplicates, in which case we print all ··· 122 114 local sym_addr=0x${fields[1]} 123 115 local sym_elf_size=${fields[2]} 124 116 local sym_sec=${fields[6]} 117 + local sec_size 118 + local sec_name 125 119 126 120 # Get the section size: 127 - local sec_size=$(${READELF} --section-headers --wide $objfile | 121 + sec_size=$(${READELF} --section-headers --wide $objfile | 128 122 sed 's/\[ /\[/' | 129 123 ${AWK} -v sec=$sym_sec '$1 == "[" sec "]" { print "0x" $6; exit }') 130 124 131 125 if [[ -z $sec_size ]]; then 132 126 warn "bad section size: section: $sym_sec" 127 + DONE=1 128 + return 129 + fi 130 + 131 + # Get the section name: 132 + sec_name=$(${READELF} --section-headers --wide $objfile | 133 + sed 's/\[ /\[/' | 134 + ${AWK} -v sec=$sym_sec '$1 == "[" sec "]" { print $2; exit }') 135 + 136 + if [[ -z $sec_name ]]; then 137 + warn "bad section name: section: $sym_sec" 133 138 DONE=1 134 139 return 135 140 fi ··· 195 174 196 175 sym_size=0x$(printf %x $sym_size) 197 176 198 - # Calculate the section address from user-supplied offset: 199 - local addr=$(($sym_addr + $offset)) 177 + # Calculate the address from user-supplied offset: 178 + local addr=$(($sym_addr + $func_offset)) 200 179 if [[ -z $addr ]] || [[ $addr = 0 ]]; then 201 - warn "bad address: $sym_addr + $offset" 180 + warn "bad address: $sym_addr + $func_offset" 202 181 DONE=1 203 182 return 204 183 fi ··· 212 191 fi 213 192 214 193 # Make sure the provided offset is within the symbol's range: 215 - if [[ $offset -gt $sym_size ]]; then 194 + if [[ $func_offset -gt $sym_size ]]; then 216 195 [[ $print_warnings = 1 ]] && 217 - echo "skipping $sym_name address at $addr due to size mismatch ($offset > $sym_size)" 196 + echo "skipping $sym_name address at $addr due to size mismatch ($func_offset > $sym_size)" 218 197 continue 219 198 fi 220 199 ··· 223 202 [[ $FIRST = 0 ]] && echo 224 203 FIRST=0 225 204 226 - echo "$sym_name+$offset/$sym_size:" 205 + echo "$sym_name+$func_offset/$sym_size:" 227 206 228 207 # Pass section address to addr2line and strip absolute paths 229 208 # from the output: 230 - local output=$(${ADDR2LINE} -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;") 209 + local args="--functions --pretty-print --inlines --exe=$objfile" 210 + [[ $is_vmlinux = 0 ]] && args="$args --section=$sec_name" 211 + local output=$(${ADDR2LINE} $args $addr | sed "s; $dir_prefix\(\./\)*; ;") 231 212 [[ -z $output ]] && continue 232 213 233 214 # Default output (non --list):
+6
tools/include/linux/objtool.h
··· 143 143 .popsection 144 144 .endm 145 145 146 + .macro STACK_FRAME_NON_STANDARD_FP func:req 147 + #ifdef CONFIG_FRAME_POINTER 148 + STACK_FRAME_NON_STANDARD \func 149 + #endif 150 + .endm 151 + 146 152 .macro ANNOTATE_NOENDBR 147 153 .Lhere_\@: 148 154 .pushsection .discard.noendbr