mkdcdisc crashes on macOS for some ELF files
Some builds of my projects, particularly when using LTO, end up with ELFs that have a LOAD header for the .bss segment. I don't know if this is valid or a toolchain bug or what, but it happens. When mkdcdisc tries to write a bin from these ELF files, it crashes because it tries to touch element 0 of a zero-length vector (I believe).
The particular error triggered is:
assertion __n < size() failed: vector[] index out of bounds
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 mkdcdisc 0x10490f824 */vector:1443: assertion __n < size() failed: vector[] index out of bounds
+ 0 [inlined]
1 mkdcdisc 0x10490f824 std::__1::vector<char, std::__1::allocator<char>>::operator[][abi:fe190102](unsigned long) const + 60 (vector:1443)
2 mkdcdisc 0x10490f0a0 elfparser::Segment::write_data_to(char*, unsigned long) const + 56 (elf_parser.hpp:74)
3 mkdcdisc 0x10490ec68 elfparser::Parser::fill_bin(std::__1::vector<char, std::__1::allocator<char>>&) + 1164 (elf_parser.cpp:104)
4 mkdcdisc 0x1048eefe4 load_elf_file(std::__1::__fs::filesystem::path const&, std::__1::vector<char, std::__1::allocator<char>>&) + 348 (main.cpp:240)
5 mkdcdisc 0x1048f4e78 gather_files(std::__1::__fs::filesystem::path const&) + 292 (main.cpp:290)
6 mkdcdisc 0x1048f4554 main + 1012 (main.cpp:1021)
7 dyld 0x199b56b98 start + 6076
Edited by jnmartin84