2021-01-22 16:44:05 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-12-20 18:26:09 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "ERROR: No output file specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
OUTPUT_FILE="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
rm -f "${OUTPUT_FILE}"
|
|
|
|
|
2020-12-29 12:38:14 +00:00
|
|
|
while (( "$#" >= 3 )); do
|
2020-12-20 18:26:09 +00:00
|
|
|
SECTION_NAME="$1"
|
|
|
|
INPUT_FILE="$2"
|
2020-12-29 12:38:14 +00:00
|
|
|
FILE_SIZE="$3"
|
2020-12-20 18:26:09 +00:00
|
|
|
|
|
|
|
{
|
2020-12-29 12:38:14 +00:00
|
|
|
printf ' .file "%s"\n' "${OUTPUT_FILE}"
|
|
|
|
printf ' .data\n'
|
|
|
|
printf ' .section %s, "a", @progbits\n' "${SECTION_NAME}"
|
2020-12-20 18:26:09 +00:00
|
|
|
printf ' .align 4\n'
|
2020-12-29 12:38:14 +00:00
|
|
|
printf ' .globl %s\n' "${SECTION_NAME}_start"
|
|
|
|
printf ' .type %s, @object\n' "${SECTION_NAME}_start"
|
|
|
|
printf ' .size %s, 4\n' "${SECTION_NAME}_start"
|
|
|
|
printf '%s:\n' "${SECTION_NAME}_start"
|
2020-12-20 18:26:09 +00:00
|
|
|
printf ' .incbin "%s"\n' "${INPUT_FILE}"
|
2020-12-29 12:38:14 +00:00
|
|
|
printf ' .section serenity_embedded_resource_info, "a", @progbits\n'
|
|
|
|
printf ' .align 4\n'
|
|
|
|
printf ' .globl %s\n' "${SECTION_NAME}_size"
|
|
|
|
printf ' .type %s, @object\n' "${SECTION_NAME}_size"
|
|
|
|
printf ' .size %s, 4\n' "${SECTION_NAME}_size"
|
|
|
|
printf '%s:\n' "${SECTION_NAME}_size"
|
|
|
|
printf ' .long %s\n' "${FILE_SIZE}"
|
2020-12-20 18:26:09 +00:00
|
|
|
printf '\n'
|
|
|
|
} >> "${OUTPUT_FILE}"
|
2020-12-29 12:38:14 +00:00
|
|
|
shift 3
|
2020-12-20 18:26:09 +00:00
|
|
|
done
|