2022-01-21 04:24:36 +03:00
|
|
|
#! /bin/sh
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2021-07-26 17:09:03 +03:00
|
|
|
set -e
|
2021-07-26 21:19:40 +03:00
|
|
|
|
2022-02-01 10:04:55 +03:00
|
|
|
LC_ALL=C
|
|
|
|
export LC_ALL
|
2022-01-21 04:24:36 +03:00
|
|
|
|
2022-05-21 04:19:57 +03:00
|
|
|
TMP0="$(mktemp)"
|
2021-08-07 08:26:34 +03:00
|
|
|
|
2021-11-28 21:00:49 +03:00
|
|
|
cat >"$TMP0" <<EOF
|
2022-01-21 04:57:31 +03:00
|
|
|
#! /bin/sh
|
2021-11-28 21:00:49 +03:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
set -o pipefail 2>/dev/null
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x "$TMP0"
|
|
|
|
|
|
|
|
"$TMP0" && set -o pipefail
|
|
|
|
|
|
|
|
rm "$TMP0"
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2022-05-21 04:19:57 +03:00
|
|
|
TMP1="$(mktemp)"
|
|
|
|
TMP2="$(mktemp)"
|
|
|
|
TMP3="$(mktemp)"
|
|
|
|
TMP4="$(mktemp)"
|
|
|
|
|
|
|
|
trap "rm -f '$TMP1' '$TMP2' '$TMP3' '$TMP4'; trap - EXIT; exit" EXIT INT TERM QUIT HUP
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2022-07-05 10:14:48 +03:00
|
|
|
"$CROSS_OBJDUMP" -t "$1" | ( "$SED" '/[[:<:]]d[[:>:]]/d' 2>/dev/null || "$SED" '/\bd\b/d' ) | sort > "$TMP1"
|
2022-04-20 05:00:00 +03:00
|
|
|
"$GREP" "$4" < "$TMP1" | cut -d' ' -f1 > "$TMP2"
|
|
|
|
"$GREP" "$4" < "$TMP1" | "$AWK" 'NF{ print $NF }' > "$TMP3"
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2022-07-23 23:54:08 +03:00
|
|
|
echo "section .$2_map" > "$TMP4"
|
|
|
|
echo "global $2_map" >> "$TMP4"
|
2022-02-01 10:04:55 +03:00
|
|
|
echo "$2_map:" >> "$TMP4"
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2022-02-01 10:04:55 +03:00
|
|
|
if [ "$3" = "32" ]; then
|
2022-07-23 23:54:08 +03:00
|
|
|
paste -d'$' "$TMP2" "$TMP3" | "$SED" 's/^/dd 0x/g;s/$/", 0/g;s/\$/\
|
|
|
|
db "/g' >> "$TMP4"
|
|
|
|
echo "dd 0xffffffff" >> "$TMP4"
|
|
|
|
nasm -f elf32 "$TMP4" -o $2.map.o
|
2022-02-01 10:04:55 +03:00
|
|
|
elif [ "$3" = "64" ]; then
|
2022-07-23 23:54:08 +03:00
|
|
|
paste -d'$' "$TMP2" "$TMP3" | "$SED" 's/^/dq 0x/g;s/$/", 0/g;s/\$/\
|
|
|
|
db "/g' >> "$TMP4"
|
|
|
|
echo "dq 0xffffffffffffffff" >> "$TMP4"
|
|
|
|
nasm -f elf64 "$TMP4" -o $2.map.o
|
2021-04-08 02:15:35 +03:00
|
|
|
fi
|