erl: use next_reloc for the paired symbol index, and stop dropping the last export - #925
Merged
Merged
Conversation
…e last export erl.c line 856 read reloc.r_info instead of next_reloc.r_info, so next_sym_n always equalled sym_n and the section-address comparison guarding HI16/LO16 pairing was unconditionally true. build-exports.sh wrote t[NR] and then iterated i < NR twice, so whichever symbol sorted last got neither a forward declaration nor an export_list[] entry. Reported in ps2dev#924.
Member
Member
|
Lgtm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defects 1 and 2 from #924. Three lines, both verified at source on
d317f8f0.erl.cline 856 fetchednext_relocand then readreloc.r_infofor the symbol index, sonext_sym_nalways equalledsym_nand thesec[sym[sym_n].st_shndx].sh_addr == sec[sym[next_sym_n].st_shndx].sh_addrterm at line 883 was unconditionally true. The HI16/LO16 pairing guard did nothing.build-exports.shstoredt[NR]and iteratedi < NRin both loops, so the last symbol got neither a forward declaration nor anexport_list[]entry.Correcting one thing I said in #924 while I was here: I claimed the
sort -non line 6 makes every key compare as 0 so the order is the input order, and that the dropped symbol is therefore unstable. That is wrong. GNU sort falls back to a whole-line comparison when the keys tie, sosort -non identifiers gives the same order as plainsort-printf 'zeta\nalpha\nmike\nbravo\n' | sort -nyieldsalpha bravo mike zeta, and onlysort -n -spreserves input order. So the drop is deterministic: it is always the lexically last symbol. That makes the bug more findable rather than less, and I have left thesort -nalone here since it is not doing any harm.Defects 3 and 4 are untouched. For 4 I have your ruling that the buildsystem name is the intended one and will follow it.