summaryrefslogtreecommitdiff
path: root/xen/tools/binfile
blob: 23099c49bf4d35bd623dcfae3ad125060a670f3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# usage: binfile [-i] [-a <align>] <target-src.S> <binary-file> <varname>
# -a <align>  align data at 2^<align> boundary (default: byte alignment)
# -i          add to .init.rodata (default: .rodata) section

section=""
align=0

OPTIND=1
while getopts "ia:" opt; do
    case "$opt" in
    i)
        section=".init"
        ;;
    a)
        align=$OPTARG
        ;;
    esac
done
SHIFT=$((OPTIND-1))
shift $SHIFT

target=$1
binsource=$2
varname=$3

cat <<EOF >$target
#include <asm/asm_defns.h>

        .section $section.rodata, "a", %progbits

        .p2align $align
        .global $varname
$varname:
        .incbin "$binsource"
.Lend:

        .type $varname, %object
        .size $varname, .Lend - $varname

        .global ${varname}_size
        ASM_INT(${varname}_size, .Lend - $varname)
EOF