| 1 |
#!/bin/bash |
|---|
| 2 |
|
|---|
| 3 |
# get a list of all symbols - YOU MUST RUN THIS SCRIPT WITH THE LATEST VERSIONS OF GLIBC |
|---|
| 4 |
# currently blacklists all newer than 2.3.0 |
|---|
| 5 |
|
|---|
| 6 |
if [ -e syms ]; then rm syms; fi |
|---|
| 7 |
if [ -e allsym ]; then rm allsym; fi |
|---|
| 8 |
for f in /lib/*; do |
|---|
| 9 |
if [ ! -f $f ]; then continue; fi |
|---|
| 10 |
readelf -s --wide $f >>syms |
|---|
| 11 |
objdump -T $f | grep "GLIBC_" | sed 's/\(.*\)GLIBC_//; s/)//' | grep -v PRIVATE | column -t >>allsym |
|---|
| 12 |
done |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
# get a list of all symbol versions only available in 2.3+ |
|---|
| 16 |
grep @@GLIBC_ syms | awk ' { print $8 } ' | sed 's/@@/ /; /GLIBC_P/d; s/GLIBC_//' | awk ' { if ($2 > 2.3) print $1 " " $2 } ' | column -t >glibc2.4.syms |
|---|
| 17 |
|
|---|
| 18 |
# select the symbols that already existed, but were obsoleted by 2.2+ versions |
|---|
| 19 |
cat glibc2.4.syms | awk '{print $1}' | while read; do grep $REPLY allsym; done | sed '/2\.4/d' >syms-to-header |
|---|
| 20 |
|
|---|
| 21 |
# select the latest symbols of that set |
|---|
| 22 |
# build a header from them |
|---|
| 23 |
cat syms-to-header | awk '{print $2 " " $1 }' | sort | uniq >output |
|---|
| 24 |
cat glibc2.4.syms | sort | uniq >> output |
|---|
| 25 |
|
|---|
| 26 |
cat output | sort | uniq | awk '{print $2 " " $1}' | sort -k2,1 | awk '{ if ($1 <= 2.3) print $1 " " $2 }' | column -t | sort -k2 | uniq -f1 >output2 |
|---|
| 27 |
|
|---|
| 28 |
# output the symbols that are brand new to 2.3+, ie not the ones that had earlier versions |
|---|
| 29 |
cat glibc2.4.syms | awk '{ print $1 }' | while read; do if ! grep "$REPLY" output2 >/dev/null; then echo "DONT_USE_THIS_SYMBOL $REPLY" >>output2; fi; done; |
|---|
| 30 |
|
|---|
| 31 |
cat output2 | column -t | awk '{ print "__asm__(\".symver " $2 "," $2 "@GLIBC_" $1 "\");" }' > output |
|---|
| 32 |
|
|---|
| 33 |
# now remove dl_iterate_phdr as it's weak anyway (we should probably do this for all weak syms) |
|---|
| 34 |
cat output | sed 's/__asm__("\.symver dl_iterate_phdr.*//' >output2 |
|---|
| 35 |
|
|---|
| 36 |
cat <<EOF >apsymbols.h |
|---|
| 37 |
/* apbuild embedded metadata */ |
|---|
| 38 |
#define APBUILD_NOTE_METADATA(s) \ |
|---|
| 39 |
__asm__(".section .metadata, \"MS\", @note, 1\n\t.string \"" s "\"\n\t.previous\n\t") |
|---|
| 40 |
|
|---|
| 41 |
#ifdef APBUILD_VERSION |
|---|
| 42 |
APBUILD_NOTE_METADATA("apbuild.version=" APBUILD_VERSION); |
|---|
| 43 |
#endif |
|---|
| 44 |
|
|---|
| 45 |
/* apbuild generated symbol exclusion list */ |
|---|
| 46 |
EOF |
|---|
| 47 |
cat output2 >> apsymbols.h |
|---|
| 48 |
rm output2 |
|---|