Previously our relocations we rewrote were broken for that case.
We emited incorrect addend and broken relocation info field
because did not produce section symbol for mergeable synthetic sections.
Also helps to simplify D40026.
Differential D40070
[ELF] - Don't emit broken relocations for SHF_MERGE sections when --emit-relocs is used. grimar on Nov 15 2017, 3:05 AM. Authored by
Details
Previously our relocations we rewrote were broken for that case. Also helps to simplify D40026.
Diff Detail Event Timeline
Comment Actions So, synthetic sections have no relocations, right? But mergeable synthetic section is an exception. I don't see any problem with my comment. Comment Actions Right.
No. Mergeable synthetic sections also have no relocations. We have synthetic section .debug_str, for example. And .debug_info that uses it. Comment Actions Then it contradicts with the other comment in the same function. // Create one STT_SECTION symbol for each output section we might // have a relocation with. Comment Actions Sorry, but I see no issue in this comment, probably my english is not good enough to see mistake in wording here. Comment Actions Aah, I'd think the comment is actually ambiguous. I was thinking of a section that a relocation is applied to, but it can also be read as it is talking about a section that a relocation's symbol belongs to, and the latter interpretation is correct. Let's update that comment too. I think something like "Create a section symbol for each output section so that we can represent relocations that point to the section. If we know that no relocation is referring to a section (that happens if the section is a synthetic one), we don't create a section symbol for that section" should work. Comment Actions Sounds good for me, thanks ! So second comment will remain the same right ? (or do you prefer something different) // We do not create symbol for synthetic sections because do not have // relocations that might use it, but SHF_MERGE sections is an exception // used for --emit-relocs. After applying merging optimisation we want to // rewrite relocations and need section symbol for synthetic mergeable // sections to refer to. Comment Actions Yes, that comment is okay, but since we are updating the first comment, and the comment has already mentioned synthetic sections, we can simplify it. I'd write "Unlike other synthetic sections, mergeable output sections contain data copied from input sections, and there may be a relocation pointing to its contents if -r or -emit-reloc are given." Given that, LGTM. Thanks! |
Synthetic sections don't have any relocations except mergeable sections. Mergeable output sections may have relocations because mergeable input sections may have relocations.