140KB was high (not sure where I got it as  a debug build is 160KB):

$ readelf -lS kernel.elf
There are 15 section headers, starting at offset 0x1a158:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk
Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0
0  0
  [ 1] .boot.text        PROGBITS        ff800000 001000 001dfe 00  AX  0
0  2
  [ 2] .boot.rodata      PROGBITS        ff801dfe 002dfe 0000ca 00   A  0
0  2
  [ 3] .text             PROGBITS        ff802000 003000 00d19a 00  AX  0
0 64
  [ 4] .sdata            PROGBITS        ff80f19c 01019c 000004 00  WA  0
0  4
  [ 5] .srodata          PROGBITS        ff80f1a0 0101a0 000010 00   A  0
0  4
  [ 6] .rodata           PROGBITS        ff80f1b0 0101b0 0063d6 00   A  0
0  4
  [ 7] ._idle_thread     PROGBITS        ff815600 016600 000200 00  WA  0
0 256
  [ 8] .boot.bss         PROGBITS        ff815800 016800 00025c 00  WA  0
0 64
  [ 9] .bss              NOBITS          ff815a5c 016a5c 0075ac 00  WA  0
0  4
  [10] .riscv.attributes RISCV_ATTRIBUTE 00000000 016a5c 00002f 00      0
0  1
  [11] .comment          PROGBITS        00000000 016a8b 000012 01  MS  0
0  1
  [12] .symtab           SYMTAB          00000000 016aa0 001b90 10     13
 95  4
  [13] .strtab           STRTAB          00000000 018630 001ab2 00      0
0  1
  [14] .shstrtab         STRTAB          00000000 01a0e2 000076 00      0
0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  D (mbind), p (processor specific)

Elf file type is EXEC (Executable file)
Entry point 0xff800000
There is 1 program header, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0xff800000 0x28000000 0x15a5c 0x1d008 RWE 0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .boot.text .boot.rodata .text .sdata .srodata .rodata
._idle_thread .boot.bss .bss

So a release build is 116KB at start and 108KB after boot completes (I
wasn't considering the reclaiming of .boot sections). I built an image w/o
CONFIG_PRINTING and got 84KB/76KB.  As I noted before we have multiple
kernel changes so this is likely in-line with your 56KB number. Regardless,
these numbers are small compared to the rootserver. But thanks for making
me look :)

Why isn't .boot.bss reclaimed? Can you point me in the direction of the
.boot section reclaiming? (didn't immediately see it)

On Tue, Jul 12, 2022 at 4:39 PM Kent Mcleod <[email protected]> wrote:

> >> It's unchanged because opentitan uses the kernel.elf headers to specify
> where to load the kernel (prior to applying the PR the SBI reservation was
> just ignored)--which took me a while to understand :().
> >>>
> >>>
> >>> What is the size of the kernel image footprint that you're observing?
> >>
> >>
> >> Looks like ~130KB, likely because we have CONFIG_PRINTING + some
> drivers. I haven't looked too closely at that # because the immediate goal
> is to reclaim all the rootserver resources which will allow us to meet our
> target platform constraints--and that looks doable. We likely have lots of
> places we can trim fat (e.g. kernel config, user space optimizations,
> removing devel facilities).
> >>>
>
> Are you able to send a dump of the kernel.elf's section and program
> headers? When I do a release build of the riscv32 kernel I get a
> kernel footprint of 56KiB.  (One interesting thing of note is the
> .boot.bss section is in the wrong place and so won't be recovered when
> switching to user level):
> Program Header:
>     LOAD off    0x00001000 vaddr 0xff800000 paddr 0x84000000 align 2**12
>          filesz 0x000098e8 memsz 0x0000e000 flags rwx
>
> Sections:
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .boot.text    00001558  ff800000  84000000  00001000  2**1
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   1 .boot.rodata  00000008  ff801558  84001558  00002558  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   2 .text         00006b6a  ff802000  84002000  00003000  2**6
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   3 .small        000001f4  ff808b80  84008b80  00009b80  2**6
>                   CONTENTS, ALLOC, LOAD, DATA
>   4 .rodata       000006b0  ff808d74  84008d74  00009d74  2**2
>                   CONTENTS, ALLOC, LOAD, READONLY, DATA
>   5 ._idle_thread 00000200  ff809500  84009500  0000a500  2**8
>                   CONTENTS, ALLOC, LOAD, DATA
>   6 .boot.bss     000001e8  ff809700  84009700  0000a700  2**2
>                   CONTENTS, ALLOC, LOAD, DATA
>   7 .bss          00004718  ff8098e8  840098e8  0000a8e8  2**12
>                   ALLOC
>   8 .riscv.attributes 0000002b  00000000  00000000  0000a8e8  2**0
>                   CONTENTS, READONLY
>   9 .comment      0000000e  00000000  00000000  0000a913  2**0
>                   CONTENTS, READONLY
>
>
>
> >>>
> >>>
> >>> > -Sam
> >>> > _______________________________________________
> >>> > Devel mailing list -- [email protected]
> >>> > To unsubscribe send an email to [email protected]
>
_______________________________________________
Devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to