Shankar Easwaran
2013-Oct-30 04:52 UTC
[LLVMdev] [lld] Handling ELF section groups/.gnu.linkonce sections.
Hi Nick, I am trying to implement support for handling section groups in lld. There are two ways of figuring out section groups with ELF. a) Sections with SHF_GROUP property b) .gnu.linkonce sections (the signature identified by the name of the section) -- This was the method to coalesce similiar constants. Section Groups(SHF_GROUP) is the preferred way on ELF but .gnu.linkonce sections is also used. We would need to support both occurences in ELF files with lld. _*Problem*_ Currently the SymbolTable assumes that an atom is going to be replaced by one another atom, but in the case of a section group, a whole group can be coalesced depending on whether the group with the same signature was previously seen. _*Example*_ For simplicity I am considering two section groups A and B (that have the same signature). Say A contains atoms A1, A2, A3, and the section group B contains atoms A1", A2", A3" To complicate things, groups A can contain fewer atoms than group B(currently supported on ELF!) -- This happens in environments where the user tried to compile object files and forgot to compile the rest of the object files. _*Problem*_ Its easier to only set the _replaceAtoms[A] = B and the Resolver could just remove B in this case. Inorder to remove all the atoms in Group B, B and all its layout-after references need to be iterated. The problem is still the _replacedAtoms map that needs to be set before all the atoms in B can be coalesced. _*Solution*_ A way to accomplish this could be to A) Use the in-group reference along with the layout-after reference. The in-group reference for atoms in the group B are going to contain B as the root of the group. B) Another way is that we could have a Atom attribute coalescedAway() which would be set for all atoms that we want to remove. This would also need in-group references. I am ok with either of the methods (A) or (B) but inclined towards (B). Thanks Shankar Easwaran -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131029/ad5eb811/attachment.html>
Nick Kledzik
2013-Oct-30 05:53 UTC
[LLVMdev] [lld] Handling ELF section groups/.gnu.linkonce sections.
On Oct 29, 2013, at 9:52 PM, Shankar Easwaran wrote:> I am trying to implement support for handling section groups in lld. > > There are two ways of figuring out section groups with ELF. > > a) Sections with SHF_GROUP property > b) .gnu.linkonce sections (the signature identified by the name of the section) -- This was the method to coalesce similiar constants. > > Section Groups(SHF_GROUP) is the preferred way on ELF but .gnu.linkonce sections is also used. > > We would need to support both occurences in ELF files with lld. > > Problem > > Currently the SymbolTable assumes that an atom is going to be replaced by one another atom, but in the case of a section group, a whole group can be coalesced depending on whether the group with the same signature was previously seen. > > Example > > For simplicity I am considering two section groups A and B (that have the same signature). > > Say A contains atoms A1, A2, A3, and the section group B contains atoms A1", A2", A3" > > To complicate things, groups A can contain fewer atoms than group B(currently supported on ELF!) -- This happens in environments where the user tried to compile object files and forgot to compile the rest of the object files. > > Problem > Its easier to only set the _replaceAtoms[A] = B and the Resolver could just remove B in this case. > > Inorder to remove all the atoms in Group B, B and all its layout-after references need to be iterated. The problem is still the _replacedAtoms map that needs to be set before all the atoms in B can be coalesced. > > Solution > A way to accomplish this could be to > > A) Use the in-group reference along with the layout-after reference. The in-group reference for atoms in the group B are going to contain B as the root of the group. > > B) Another way is that we could have a Atom attribute coalescedAway() which would be set for all atoms that we want to remove. This would also need in-group references. > > I am ok with either of the methods (A) or (B) but inclined towards (B).I was thinking both A & B. That is how I do it with the darwin linker. When a group is parsed, the signature atom has a "group" reference for all the other atoms in the group. When the Resolver replaces one atom with another, it looks to see if the atom has any group references, and if so, marks all those atoms as coalesced away. -Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131029/4d1f9ce7/attachment.html>
Shankar Easwaran
2013-Oct-30 16:13 UTC
[LLVMdev] [lld] Handling ELF section groups/.gnu.linkonce sections.
On 10/30/2013 12:53 AM, Nick Kledzik wrote:> On Oct 29, 2013, at 9:52 PM, Shankar Easwaran wrote: >> I am trying to implement support for handling section groups in lld. >> >> There are two ways of figuring out section groups with ELF. >> >> a) Sections with SHF_GROUP property >> b) .gnu.linkonce sections (the signature identified by the name of the section) -- This was the method to coalesce similiar constants. >> >> Section Groups(SHF_GROUP) is the preferred way on ELF but .gnu.linkonce sections is also used. >> >> We would need to support both occurences in ELF files with lld. >> >> Problem >> >> Currently the SymbolTable assumes that an atom is going to be replaced by one another atom, but in the case of a section group, a whole group can be coalesced depending on whether the group with the same signature was previously seen. >> >> Example >> >> For simplicity I am considering two section groups A and B (that have the same signature). >> >> Say A contains atoms A1, A2, A3, and the section group B contains atoms A1", A2", A3" >> >> To complicate things, groups A can contain fewer atoms than group B(currently supported on ELF!) -- This happens in environments where the user tried to compile object files and forgot to compile the rest of the object files. >> >> Problem >> Its easier to only set the _replaceAtoms[A] = B and the Resolver could just remove B in this case. >> >> Inorder to remove all the atoms in Group B, B and all its layout-after references need to be iterated. The problem is still the _replacedAtoms map that needs to be set before all the atoms in B can be coalesced. >> >> Solution >> A way to accomplish this could be to >> >> A) Use the in-group reference along with the layout-after reference. The in-group reference for atoms in the group B are going to contain B as the root of the group. >> >> B) Another way is that we could have a Atom attribute coalescedAway() which would be set for all atoms that we want to remove. This would also need in-group references. >> >> I am ok with either of the methods (A) or (B) but inclined towards (B). > I was thinking both A & B. That is how I do it with the darwin linker. When a group is parsed, the signature atom has a "group" reference for all the other atoms in the group. When the Resolver replaces one atom with another, it looks to see if the atom has any group references, and if so, marks all those atoms as coalesced away.Thanks Nick, I think the coalesce attribute of the atom should not be preserved in the native file right, as this is only a derived attribute after reading the ELF files, isnt it ? Thanks Shankar Easwaran -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
Possibly Parallel Threads
- [LLVMdev] [lld] Handling ELF section groups/.gnu.linkonce sections.
- [LLVMdev] [lld] Handling ELF section groups/.gnu.linkonce sections.
- [LLVMdev] [lld] supporting gnu linkonce sections in core linking
- [LLVMdev] Handling ELF groups.
- [LLVMdev] Handling ELF groups.