星期二, 2月 20, 2024

取出so 內function name

  nm -D libmy.so | sed -n 's/^[0-9a-f]* [Tt] \(.*\)/\1/p'


  1. parsing name
    1.  nm -D ./libmy.so | sed -n -e 's/^\([0-9a-f]*\) [Tt] \(.*\)/\2 \U\2/p' | sed -e 's/\([^ ]*\) *\([^_]*\)_.*/,\1, \2, 0},/'| nl|sed -e 's/^/{/'
    2. //{num, name, define, bused}
      1. { 27,   mutual_exclusion_read_unlock, MUTUAL_EXCLUSION_READ, 0},
  2. class out
    1.  nm -D ./libmy.so | sed -n -e 's/^\([0-9a-f]*\) [Tt] \(.*\)/\2 \U\2/p' | sed -e 's/\([^ ]*\) *\([^_]*\)_.*/,\1, \2, 0},/'| nl|sed -e 's/^/{/' |awk -F ", " '{print $2}' | awk '!seen[$0]++'
    2. VPI
  3. enum out
    1. nm -D ./libmy.so | sed -n -e 's/^\([0-9a-f]*\) [Tt] \(.*\)/\2 \U\2/p' | sed -e 's/\([^ ]*\) *\([^_]*\)_.*/,\1, \2, 0},/'| nl|sed -e 's/^/{/' |awk -F ", " '{print $2}' | awk '!seen[$0]++'| awk '{print $0 "=" NR-1 ","}'

      1. CGI=0,
      2. EEPROM=1,
      3. GET=2,
      4. IPC=3,
      5. MQ=4,
      6. MUTUAL=5,
      7. PRINTLOG=6,
      8. PUT=7,

    沒有留言: