tum-ei-eda / etiss

Extendable Translating Instruction Set Simulator
https://tum-ei-eda.github.io/etiss/
Other
29 stars 36 forks source link

SimpleMemSystem: skip empty elf segments #110

Closed PhilippvK closed 2 years ago

PhilippvK commented 2 years ago

A recent version of the RISCV GCC Toolchain caused ETISS crashes due to an unexpected new memory segment added to the ELF:

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOPROC+0x3     0x02f113 0x00000000 0x00000000 0x0008f 0x00000 R   0x1
  LOAD           0x001000 0x00000000 0x00000000 0x1220c 0x1220c R E 0x1000
  LOAD           0x014000 0x00100000 0x00100000 0x009cc 0x08af8 RW  0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .riscv.attributes
   01     .vectors .text .text.startup .rodata .eh_frame
   02     .init_array .data .sdata .bss .stack

This PR adds a check to skip empty segments in the SimpleMemSystem (as recommended by @rafzi)

github-actions[bot] commented 2 years ago

Performance Statistics

Status for the gcc Just-In-Time Engine (for commit 8d5769f8): 🥇 New best performance! Current dhrystone MIPS for gcc JIT : 39.05 Previous best for gcc JIT (recorded in commit 8d5769f8): 39.05, difference 9.21%

Status for the llvm Just-In-Time Engine (for commit 8d5769f8): 🥇 New best performance! Current dhrystone MIPS for llvm JIT : 21.86 Previous best for llvm JIT (recorded in commit 8d5769f8): 21.86, difference 1.58%

Status for the tcc Just-In-Time Engine (for commit 8d5769f8): 🥇 New best performance! Current dhrystone MIPS for tcc JIT : 29.46 Previous best for tcc JIT (recorded in commit 8d5769f8): 29.46, difference 7.70%

This comment was created automatically, please do not change!

rafzi commented 2 years ago

we should also add this check for the function that creates segments from the config: https://github.com/tum-ei-eda/etiss/blob/master/src/SimpleMemSystem.cpp#L93

but that one should cause a FATALERROR since such a configuration would be nonsense.

wysiwyng commented 2 years ago

In addition to checking the memory_size, we also need to check the segment type. The conflicting segment is of type PT_LOPROC, only segments of type PT_LOAD are meant to be loaded into memory.

see: https://stackoverflow.com/questions/10871706/why-segments-in-elf-file-can-overlap http://refspecs.linuxbase.org/elf/gabi4+/ch5.pheader.html