OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / tools / misc / bin2elf
1 #!/bin/sh
2 # Convert a binary file to elf format.  Useful for loading with gdb.
3
4 case "$#" in
5 3)      ;;
6 4)      ARCH=$1-
7         shift
8         ;;
9 *)      echo "Usage: bin2elf [arch] input output address" >&2
10         exit 1
11         ;;
12 esac
13
14 INPUT=$1
15 OUTPUT=$2
16 ADDR=$3
17
18 touch /tmp/empty.c
19 ${ARCH}gcc -nostartfiles -nostdlib /tmp/empty.c -o $OUTPUT 2> /dev/null
20 rm /tmp/empty.c
21
22 ${ARCH}objcopy --remove-section=.text --remove-section=.data --remove-section=.bss --remove-section=.sbss --remove-section=.comment --remove-section=.note --add-section=.bin=$INPUT --adjust-section-vma=.bin=$ADDR --no-adjust-warnings --set-section-flags=.bin=alloc,load,data $OUTPUT 2> /dev/null