relocs_check.sh 717 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Get a list of all the relocations, remove from it the relocations
  4. # that are known to be legitimate and return this list to arch specific
  5. # script that will look for suspicious relocations.
  6. objdump="$1"
  7. nm="$2"
  8. vmlinux="$3"
  9. # Remove from the possible bad relocations those that match an undefined
  10. # weak symbol which will result in an absolute relocation to 0.
  11. # Weak unresolved symbols are of that form in nm output:
  12. # " w _binary__btf_vmlinux_bin_end"
  13. undef_weak_symbols=$($nm "$vmlinux" | awk '$1 ~ /w/ { print $2 }')
  14. $objdump -R "$vmlinux" |
  15. grep -E '\<R_' |
  16. ([ "$undef_weak_symbols" ] && grep -F -w -v "$undef_weak_symbols" || cat)