espsystem: add support for RISC-V panic backtrace

Add .eh_frame and .eh_frame_hdr sections to the binary (can be
enabled/disabled within menuconfig). These sections are parsed
when a panic occurs. Their DWARF instructions are decoded and
executed at runtime, to retrieve the whole backtrace. This
parser has been tested on both RISC-V and x86 architectures.

This feature needs esptool's merge adjacent ELF sections feature.
This commit is contained in:
Omar Chebib
2021-01-14 12:09:40 +08:00
parent 34c16dba93
commit b967dc0dbf
17 changed files with 1560 additions and 4 deletions

View File

@@ -116,3 +116,8 @@ REGION_ALIAS("rtc_data_location", rtc_iram_seg );
ASSERT(_flash_rodata_dummy_start == ORIGIN(default_rodata_seg),
".flash_rodata_dummy section must be placed at the beginning of the rodata segment.")
#endif
#if CONFIG_ESP_SYSTEM_USE_EH_FRAME
ASSERT ((_eh_frame_end > _eh_frame), "Error: eh_frame size is null!");
ASSERT ((_eh_frame_hdr_end > _eh_frame_hdr), "Error: eh_frame_hdr size is null!");
#endif

View File

@@ -289,9 +289,6 @@ SECTIONS
*(.gcc_except_table .gcc_except_table.*)
*(.gnu.linkonce.e.*)
*(.gnu.version_r)
. = (. + 3) & ~ 3;
__eh_frame = ABSOLUTE(.);
KEEP(*(.eh_frame))
. = (. + 7) & ~ 3;
/*
* C++ constructor and destructor tables
@@ -345,6 +342,20 @@ SECTIONS
. = ALIGN(4);
} > default_rodata_seg
.eh_frame :
{
_eh_frame = ABSOLUTE(.);
KEEP (*(.eh_frame))
_eh_frame_end = ABSOLUTE(.);
} > drom0_0_seg
.eh_frame_hdr :
{
_eh_frame_hdr = ABSOLUTE(.);
KEEP (*(.eh_frame_hdr))
_eh_frame_hdr_end = ABSOLUTE(.);
} > drom0_0_seg
.flash.rodata_noload (NOLOAD) :
{
. = ALIGN (4);