-
Notifications
You must be signed in to change notification settings - Fork 7
/
elf_end
executable file
·32 lines (29 loc) · 1.11 KB
/
elf_end
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
#!/bin/bash
#device/test8/image.elf: file format elf32-little
#
#Sections:
#Idx Name Size VMA LMA File off Algn
# 0 .data 0000004e 00800100 00001aae 00001b42 2**0
# CONTENTS, ALLOC, LOAD, DATA
# 1 .text 00001aae 00000000 00000000 00000094 2**1
# CONTENTS, ALLOC, LOAD, READONLY, CODE
# 2 .bss 000000cd 0080014e 0080014e 00001b90 2**0
# ALLOC
# 3 .stab 000097a4 00000000 00000000 00001b90 2**2
# CONTENTS, READONLY, DEBUGGING
# 4 .stabstr 00002bd9 00000000 00000000 0000b334 2**0
# CONTENTS, READONLY, DEBUGGING
# 5 .comment 00000011 00000000 00000000 0000df0d 2**0
# CONTENTS, READONLY
# align jj
if [ -z "$1" ] ; then
echo "Usage: $0 elf_file [section:bss] [align:file]" >&2
exit 1
fi
SECTION=.${2:-bss}
${OBJDUMP:-objdump} -h "$1" | while read a b c d e f g ; do
if [ "$b" = "$SECTION" ] ; then
ALIGN=${3:-$g}
printf "0x%x\n" $(( ((0x$c + 0x$e + ($ALIGN - 1) ) / $ALIGN) * $ALIGN ))
fi
done