Bug #4959
closedcompletely discarded merged string sections will corrupt output objects
100%
Description
If an input object contains a mergable string table of 0 size (not even containing the NUL string), we'll produce an output object with a corrupt string table, or trip an assert:
Assertion failed: shdr->sh_info == SYMTAB_LOC_CNT(ofl), file ../common/update.c, line 1959, function update_osym
This seems to be because this input section deserves to be discarded (and would be), but the new merged section we create for it will have size 1 (because it will always contain the NUL string) and thus will partially persist.
We certainly should not be producing merged sections if there are no input strings.
It is likely we also should not be getting nearly so muddled in the case where we do (we should likely be producing just a useless output section, not one that corrupts the string table).
In the test case I have, unfortunately, the string table corrupt causes us to have two output sections named ".comment", which makes following the debug output from the link-editor challenging.