LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 19960 - syntax for coff associative sections is ambiguous
Summary: syntax for coff associative sections is ambiguous
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: MC (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-05 16:00 PDT by Rafael Ávila de Espíndola
Modified: 2014-06-06 14:32 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2014-06-05 16:00:17 PDT
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.
Comment 1 Reid Kleckner 2014-06-05 17:17:55 PDT
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.
Comment 2 Rafael Ávila de Espíndola 2014-06-06 11:53:21 PDT
(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.
Comment 3 Reid Kleckner 2014-06-06 12:00:53 PDT
(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.
Comment 4 Rafael Ávila de Espíndola 2014-06-06 14:32:14 PDT
Fixed in r210367.