check-plt.sh 620 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. allowed="
  3. calloc
  4. free
  5. malloc
  6. memalign
  7. realloc
  8. "
  9. ${OBJDUMP:-objdump} -d ${top_builddir:-../..}/lib/libc.so.? | \
  10. gawk -v allowed="${allowed}" '
  11. BEGIN {
  12. COUNT = split(" " allowed, ALLOWED);
  13. }
  14. # Strip away the noise. The name will be like:
  15. # <brk>:
  16. # <foo@plt>
  17. function symstrip(name) {
  18. return gensub(/.*<([^>@]*).*/, "\\1", "", name);
  19. }
  20. {
  21. # Match the start of the symbol disassembly
  22. # 00009720 <brk>:
  23. if ($2 ~ />:$/) {
  24. f = symstrip($2);
  25. } else if ($NF ~ /@plt>/) {
  26. rf = symstrip($NF);
  27. for (a in ALLOWED) {
  28. a = ALLOWED[a];
  29. if (a == rf)
  30. next;
  31. }
  32. print "Func " f " references " rf;
  33. }
  34. }' | sort -u