1# This awk script processes the output of objdump --dynamic-syms 2# into a simple format that should not change when the ABI is not changing. 3 4BEGIN { 5 if (combine_fullname) 6 combine = 1; 7 if (combine) 8 parse_names = 1; 9} 10 11# Per-file header. 12/[^ :]+\.so\.[0-9.]+:[ ]+.file format .*$/ { 13 emit(0); 14 15 seen_opd = 0; 16 17 sofullname = $1; 18 sub(/:$/, "", sofullname); 19 soname = sofullname; 20 sub(/^.*\//, "", soname); 21 sub(/\.so\.[0-9.]+$/, "", soname); 22 23 suppress = ((filename_regexp != "" && sofullname !~ filename_regexp) \ 24 || (libname_regexp != "" && soname !~ libname_regexp)); 25 26 next 27} 28 29suppress { next } 30 31# Normalize columns. 32/^[0-9a-fA-F]+ / { sub(/ /, " - ") } 33 34# Skip undefineds. 35$4 == "*UND*" { next } 36 37# Skip locals. 38$2 == "l" { next } 39 40# If the target uses ST_OTHER, it will be output before the symbol name. 41$2 == "g" || $2 == "w" && (NF == 7 || NF == 8) { 42 type = $3; 43 size = $5; 44 sub(/^0*/, "", size); 45 if (size == "") { 46 size = " 0x0"; 47 } else { 48 size = " 0x" size; 49 } 50 version = $6; 51 symbol = $NF; 52 gsub(/[()]/, "", version); 53 54 # binutils versions up through at least 2.23 have some bugs that 55 # caused STV_HIDDEN symbols to appear in .dynsym, though that is useless. 56 if (NF > 7 && $7 == ".hidden") next; 57 58 if (version ~ /^GLIBC_ABI_/ && !include_abi_version) next; 59 60 if (version == "GLIBC_PRIVATE" && !include_private) next; 61 62 desc = ""; 63 if (type == "D" && ($4 == ".tbss" || $4 == ".tdata")) { 64 type = "T"; 65 } 66 else if (type == "D" && $4 == ".opd") { 67 type = "F"; 68 size = ""; 69 if (seen_opd < 0) 70 type = "O"; 71 seen_opd = 1; 72 } 73 else if (type == "D" && NF == 8 && $7 == "0x80") { 74 # Alpha functions avoiding plt entry in users 75 type = "F"; 76 size = ""; 77 seen_opd = -1; 78 } 79 else if ($4 == "*ABS*") { 80 next; 81 } 82 else if (type == "D") { 83 # Accept unchanged. 84 } 85 else if (type == "DO") { 86 type = "D"; 87 } 88 else if (type == "DF") { 89 if (symbol ~ /^\./ && seen_opd >= 0) 90 next; 91 seen_opd = -1; 92 type = "F"; 93 size = ""; 94 } 95 else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) { 96 # Indirect functions. 97 type = "F"; 98 size = ""; 99 } 100 else { 101 print "ERROR: Unable to handle this type of symbol:", $0 102 exit 1 103 } 104 105 if (desc == "") 106 desc = symbol " " type size; 107 108 if (combine) 109 version = soname " " version (combine_fullname ? " " sofullname : ""); 110 111 # Append to the string which collects the results. 112 descs = descs version " " desc "\n"; 113 next; 114} 115 116# Header crapola. 117NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next } 118 119{ 120 print "ERROR: Unable to interpret this line:", $0 121 exit 1 122} 123 124function emit(end) { 125 if (!end && (combine || ! parse_names || soname == "")) 126 return; 127 tofile = parse_names && !combine; 128 129 if (tofile) { 130 out = prefix soname ".symlist"; 131 if (soname in outfiles) 132 out = out "." ++outfiles[soname]; 133 else 134 outfiles[soname] = 1; 135 outpipe = "LC_ALL=C sort -u > " out; 136 } else { 137 outpipe = "LC_ALL=C sort -u"; 138 } 139 140 printf "%s", descs | outpipe; 141 142 descs = ""; 143 144 if (tofile) 145 print "wrote", out, "for", sofullname; 146} 147 148END { 149 emit(1); 150} 151