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
|
|
|
|
2023-03-16 04:28:50 +03:00
|
|
|
"$OBJDUMP_FOR_TARGET" -t "$1" | ( "$SED" '/[[:<:]]d[[:>:]]/d' 2>/dev/null || "$SED" '/\bd\b/d' ) | sort > "$TMP1"
|
2023-06-20 09:54:53 +03:00
|
|
|
"$GREP" "F $4" < "$TMP1" | cut -d' ' -f1 > "$TMP2"
|
|
|
|
"$GREP" "F $4" < "$TMP1" | "$AWK" 'NF{ print $NF }' > "$TMP3"
|
2021-02-25 03:24:54 +03:00
|
|
|
|
2022-08-13 21:32:06 +03:00
|
|
|
echo ".section .$2_map" > "$TMP4"
|
|
|
|
echo ".globl $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-09-01 12:48:32 +03:00
|
|
|
paste -d'#' "$TMP2" "$TMP3" | "$SED" 's/^/.long 0x/g;s/$/"/g;s/#/\
|
2022-08-13 21:32:06 +03:00
|
|
|
.asciz "/g' >> "$TMP4"
|
|
|
|
echo ".long 0xffffffff" >> "$TMP4"
|
2022-02-01 10:04:55 +03:00
|
|
|
elif [ "$3" = "64" ]; then
|
2022-09-01 12:48:32 +03:00
|
|
|
paste -d'#' "$TMP2" "$TMP3" | "$SED" 's/^/.quad 0x/g;s/$/"/g;s/#/\
|
2022-08-13 21:32:06 +03:00
|
|
|
.asciz "/g' >> "$TMP4"
|
|
|
|
echo ".quad 0xffffffffffffffff" >> "$TMP4"
|
2021-04-08 02:15:35 +03:00
|
|
|
fi
|
2022-08-13 21:32:06 +03:00
|
|
|
|
|
|
|
mv "$TMP4" "$2.map.S"
|