Automatically find so dependent

Source: Internet
Author: User

First, script writing

When adapting the system, you need to find some dependent files, manual use of Winhex or UltraEdit to find a very troublesome.

So I wrote a shell script to get these dependencies in batches.

Under the Linux system, save the following as Getneed.sh

[Plain]View Plaincopy print?
  1. #/bin/bash
  2. #by Changyuet
  3. printf "**************************************\n"
  4. printf "Put this shell to system folder\n"
  5. printf "**************************************\n"
  6. function Getneed ()
  7. {
  8. Echo ' <<<<<<getting need for ' >>>>>> '
  9. Case $ in
  10. LIB/HW)
  11. Name=lib_hw
  12. ;;
  13. Vendor/bin)
  14. Name=vendor_bin
  15. ;;
  16. Vendor/lib)
  17. Name=vendor_lib
  18. ;;
  19. VENDOR/LIB/HW)
  20. Name=vendor_lib_hw
  21. ;;
  22. *)
  23. Name=$1
  24. ;;
  25. Esac
  26. if [!-D $];then
  27. printf "can ' t find $ folder!\n"
  28. Else
  29. LS $1-p | grep [^/]$ > Info_$name.txt
  30. Cat Info_$name.txt |while Read line
  31. Do
  32. echo "Getting Need for" $line
  33. echo $line >> Need_$name.txt
  34. Objdump-x $1/$line | grep "NEEDED" >> need_$name.txt
  35. echo "*************************************" >> need_$name.txt
  36. Done
  37. RM info_$name.txt
  38. Fi
  39. }
  40. Getneed bin;
  41. Getneed Lib;
  42. Getneed LIB/HW;
  43. Getneed Vendor/bin;
  44. Getneed Vendor/lib;
  45. Getneed VENDOR/LIB/HW;
  46. printf "**********completed!**********\n"

Ii. Description of Use

The following operations are done under Linux (operating under Linux ext3 or EXT4 file systems), first ensure that your Linux has objdump this program

Unzip the ROM and copy the getneed.sh to the system directory

Open the shell and navigate to the system directory. #先给权限chmod a+x getneed.sh to execute again./getneed.sh

After execution, the need_xxx.txt generated in the directory is a batch-listed dependency file

If the file does not contain needed, there is no dependency on the file, or it cannot be recognized by objdump

How to interpret (example):

ADB NEEDED libc.so NEEDED libstdc++.so NEEDED libm.so

*************************************

This paragraph means:

ADB this program, need libc.so, libstdc++.so, libm.so these three files

========================================================================================

Additional knowledge:

Sometimes lacks lib, does not prompt the file name, but prompts a string for example: _zn3net15

At this point, you can find it by this command.

Grep-r "_zn3net15" *

Automatically find so dependent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.