-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmergeelfs
More file actions
executable file
·40 lines (35 loc) · 875 Bytes
/
mergeelfs
File metadata and controls
executable file
·40 lines (35 loc) · 875 Bytes
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
#!/bin/bash
#set -x
if test -n "$OBJDUMPCMD"; then
OBJDUMPCMD=${OBJDUMPCMD:-powerpc-bgp-linux-objdump}
else
OBJDUMPCMD=${CROSS_COMPILE}objdump
fi
if test -n "$OBJCPYCMD"; then
OBJCPYCMD=${OBJCPYCMD:-powerpc-bgp-linux-objcopy}
else
OBJCPYCMD=${CROSS_COMPILE}objcopy
fi
if (( $# < 2 )); then
echo "$0: <outfile> <primary elf> <single section elfs to add>"
exit -1
fi
out=$1
shift
primary=$1
shift
add="$@"
typeset -i j=0
pid=$$
secargs=$(for i in $add
do
${OBJDUMPCMD} -h $i | grep '^ *[0-9]' | while read idx name size addr rest
do
section=$(basename $i)
section=${section%%.elf}.bin
${OBJCPYCMD} -O binary $i $pid.$section
echo "--add-section $section=$pid.$section --change-section-address $section=0x$addr --set-section-flags $section=contents,alloc,load,data"
done
((j++))
done)
${OBJCPYCMD} $secargs $primary $out