Open U2654 opened 3 years ago
Could you please add:
run
./hifive-vp firmware.elf
SystemC 2.3.3-Accellera --- Feb 22 2021 22:06:21
Copyright (c) 1996-2018 by all Contributors,
ALL RIGHTS RESERVED
Assertion failed: ((addr >= offset) && (addr + p->p_memsz <= offset + size)), function load_executable_image, file /Users/matthias/embedded/riscv-vp/vp/src/./core/common/elf_loader.h, line 54.
Abort trap: 6
The assert does not expect the vaddr 0x80000b10.
As we don't use the freedom-studio, could you post your ELF?
Do you know why the assertion fails, what are the other parameters?
Usually, a .bss
is no problem.
Yes, it is not a .bss problem. Actually, it is a sifive ld-script issue. However, the elf works on physical hw. Thus, it might be useful to consider. Attached is the "hello world" example built of the freedom-e-sdk for the hifive1 platform. Same issue... hello.elf.gz
Solution introduced breaks certain other setups. As far as I understand it, your ELFs do not contain zero-bit sections but mention it, other ELFs actually carry the zeroes.
As far as I remember, paddr was not accepted (assert) as paddr > offset + size.
The Specification states:
ELF allows for any segment to contain NOBITS sections. The link-editor places such sections at the end of the segment they are assigned to. This is implemented using the program header entry p_filesz and p_memsz fields, which must follow the following rule.
p_memsz >= p_filesz
If p_memsz is greater than p_filesz, the extra bytes are NOBITS. The first p_filesz bytes come from the object file, and any remaining bytes up to p_memsz are zeroed by the system prior to use.
The default assignment rules assign read-only NOBITS sections to the text segment, and writable NOBITS sections to the data segment. The link-editor defines the bss segment as an alternative segment that can accept writable NOBITS sections. This segment is disabled by default, and must be explicitly enabled to be used.
Since writable NOBITS sections are easily handled as part of the data segment, the benefit of having a separate bss segment may not be immediately obvious. By convention, the process dynamic memory heap starts at the end of the final segment, which must be writable. This is usually the data segment, but if bss is enabled, bss becomes the final segment. When building a dynamic executable, enabling the bss segment with an appropriate alignment can be used to enable large page assignment of the heap. For example, the following enables the bss segment and sets an alignment of 4MB.
LOAD_SEGMENT bss {
ALIGN=0x400000;
};
Our Problem was, that if NOBITS was detected, all data was discarded.
The correct way would be copying for p_filesz
bytes and then filling the rest with zeroes.
I'm on that.
The following elf program header fails within elf_loader.h in line 54. The used linker script is a standard one of the freedom-e-sdk. The problem is the fourth section which corresponds to the .bss section and surprises the GenericElfLoader...