File: djelfextract

package info (click to toggle)
djstub 0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 228 kB
  • sloc: ansic: 1,957; sh: 127; makefile: 72; asm: 15
file content (17 lines) | stat: -rwxr-xr-x 454 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash

if [ "$#" -lt 2 ]; then
  echo "Usage: djelfextract <solib_name> <out_elf>"
  exit 0
fi

ID="`LC_ALL=C readelf -W -S $1 | grep .dj64startup | sed -E -e 's/.+\] +//' | \
    tr -s '[:space:]'`"
if [ -z "$ID" ]; then
  echo ".dj64startup section not found"
  exit 1
fi

SZ=`echo "$ID" | cut -d " " -f 5 | sed -E -e 's/0*/0x/'`
OFF=`echo "$ID" | cut -d " " -f 4 | sed -E -e 's/0*/0x/'`
dd if=$1 of=$2 bs=1 count=$(($SZ)) skip=$(($OFF))