1#!/bin/sh 2# usage: binfile [-i] [-a <align>] <target-src.S> <binary-file> <varname> 3# -a <align> align data at 2^<align> boundary (default: byte alignment) 4# -i add to .init.rodata (default: .rodata) section 5 6section="" 7align=0 8 9OPTIND=1 10while getopts "ia:" opt; do 11 case "$opt" in 12 i) 13 section=".init" 14 ;; 15 a) 16 align=$OPTARG 17 ;; 18 esac 19done 20SHIFT=$((OPTIND-1)) 21shift $SHIFT 22 23target=$1 24binsource=$2 25varname=$3 26 27cat <<EOF >$target 28#include <asm/asm_defns.h> 29 30 .section $section.rodata, "a", %progbits 31 32 .p2align $align 33 .global $varname 34$varname: 35 .incbin "$binsource" 36.Lend: 37 38 .type $varname, %object 39 .size $varname, .Lend - $varname 40 41 .global ${varname}_size 42 ASM_INT(${varname}_size, .Lend - $varname) 43EOF 44