2
0

relink-lib.sh 403 B

1234567891011121314
  1. #!/bin/sh
  2. [ $# -lt 4 -o -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ] && {
  3. echo "Usage: $0 <cross> <reference> <pic .a> <destination>"
  4. exit 1
  5. }
  6. cross="$1"; shift
  7. ref="$1"; shift
  8. pic="$1"; shift
  9. dest="$1"; shift
  10. SYMBOLS="$(${cross}nm "$ref" | grep -E '........ [TW] ' | awk '$3 {printf "-u%s ", $3}')"
  11. set -x
  12. ${cross}gcc -nostdlib -nostartfiles -shared -Wl,--gc-sections -o "$dest" $SYMBOLS "$pic" "$@"