3 # Calculate the amount of space needed to run the kernel, including room for
4 # the .bss and .brk sections.
7 # objdump -h a.out | perl calc_run_size.pl
13 my $sections=" *[0-9]+ \.(?:bss|brk) +";
15 if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) {
19 if ($file_offset == 0) {
20 $file_offset = $offset;
21 } elsif ($file_offset != $offset) {
22 # BFD linker shows the same file offset in ELF.
23 # Gold linker shows them as consecutive.
24 next if ($file_offset + $mem_size == $offset + $size);
26 printf STDERR "file_offset: 0x%lx\n", $file_offset;
27 printf STDERR "mem_size: 0x%lx\n", $mem_size;
28 printf STDERR "offset: 0x%lx\n", $offset;
29 printf STDERR "size: 0x%lx\n", $size;
31 die ".bss and .brk are non-contiguous\n";
36 if ($file_offset == 0) {
37 die "Never found .bss or .brk file offset\n";
39 printf("%d\n", $mem_size + $file_offset);