riscv-software-src / riscv-software-src/opensbi

Why ld is leaving a hole in memory?

Open
#367 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.5k
Forks
712
PR merge metrics
No merged PRs in 30d

Description

Hi

opensbi using a large amount of memory now, and there is a memory hole, is there any way to avoid it?thanks.

opensbi/firmware/fw_base.ldS

PROVIDE(_rodata_end = .);

/* End of the read-only data sections */

/*
* PMP regions must be to be power-of-2. RX/RW will have separate
* regions, so ensure that the split is power-of-2.
*/
. = ALIGN(1 << LOG2CEIL((SIZEOF(.rodata) + SIZEOF(.text)
		+ SIZEOF(.dynsym) + SIZEOF(.rela.dyn))));

PROVIDE(_fw_rw_start = .);

Sections sample:
rela.dyn end 0x200674e8, data start 0x20080000, there is a 98K memory hole

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         000185a0  0000000020040000  0000000020040000  00001000  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       000029a8  0000000020059000  0000000020059000  0001a000  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .dynsym       00000210  00000000200658f8  00000000200658f8  000268f8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynstr       0000019f  000000002005b9a8  000000002005b9a8  0001c9a8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .hash         000000a4  000000002005bb48  000000002005bb48  0001cb48  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .gnu.hash     000000b4  000000002005bbf0  000000002005bbf0  0001cbf0  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .eh_frame     00008bd4  000000002005bca8  000000002005bca8  0001cca8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .eh_frame_hdr 0000107c  000000002006487c  000000002006487c  0002587c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rela.dyn     000014e8  0000000020066000  0000000020066000  00027000  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .data         00001398  0000000020080000  0000000020080000  00029000  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 10 .dynamic      00000110  0000000020081398  0000000020081398  0002a398  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 11 .got          000000a8  00000000200814a8  00000000200814a8  0002a4a8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 12 .got.plt      00000010  0000000020081550  0000000020081550  0002a550  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 13 .bss          00002c90  0000000020082000  0000000020082000  0002a560  2**3
                  ALLOC

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with opensbi/firmware/fw_base.ldS and compare the ALIGN expression with the reported .rela.dyn and .data addresses. Inspect the linker output or section map to determine whether the gap is caused by the power-of-two PMP alignment; done means explaining the gap and identifying whether the layout can safely avoid it.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.