When creating an associative section the syntax looks like .section name,flags,associative assoc_name, comdat_sym the problem is that we can have multiple sections named assoc_name. A general but fairly disruptive change would be to have something like %foo = .section .... where %foo would be token that can be used to refer to the section. A less general but simpler option would be so do the reference with .section name,flags,associative assoc_name, assoc_comdat, comdat_sym but given that assoc_comdat is in a section, we could also simplify this to .section name,flags,associative assoc_comdat, comdat_sym and in the object writer map the assoc_comdat to the assoc section number.
I think you can go further. The comdat_sym of an associative section is meaningless. Recall that in the object file, the comdat_sym is completely implicit: it's merely the first symbol in the table that references the section. It's possible to have a section that contains no symbols, and hence has no comdat symbol. Therefore, why not parse the comdat symbol, but have it mean something else for associative sections. The comdat symbol is looked up, and its section number is emitted into the Number field. We did some experiments with obj2yaml and the MSVC tools and this works.
(In reply to comment #1) > I think you can go further. The comdat_sym of an associative section is > meaningless. Recall that in the object file, the comdat_sym is completely > implicit: it's merely the first symbol in the table that references the > section. It's possible to have a section that contains no symbols, and > hence has no comdat symbol. Therefore, why not parse the comdat symbol, but > have it mean something else for associative sections. The comdat symbol is > looked up, and its section number is emitted into the Number field. > > We did some experiments with obj2yaml and the MSVC tools and this works. Something like .section .foo,"bw",discard, "sym" .section .bar,"rd",associative, "sym" where .bar gets associated with .foo? I like it. Giving it a try.
(In reply to comment #2) > Something like > > .section .foo,"bw",discard, "sym" > .section .bar,"rd",associative, "sym" > > where .bar gets associated with .foo? > > I like it. Giving it a try. Yep! So long as sym is defined in this instance of .foo, things work out.
Fixed in r210367.