Bug 16279 - Need a way to create two COFF sections with the same name but different comdats
Summary: Need a way to create two COFF sections with the same name but different comdats
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-01 15:15 UTC by Rafael Ávila de Espíndola
Modified: 2014-05-21 18:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2013-12-01 15:15:07 UTC
On ELF one can easily create two sections with the same name in different comdats:

---------------------------------------------
.section	foo,"axG",@progbits,f,comdat
.globl f
f:
  ret

.section	foo,"axG",@progbits,g,comdat
.globl g
g:
  ret
---------------------------------------------

on COFF that is not possible since the .section directive doesn't include the comdat information (that is part of the .linkonce directive). This means that a compiler using gas needs to produce unique names, producing more complex .obj files than the ones produced by msvc, which, for example, have all c++ inline functions in sections named .text.

The assembler included in LLVM solved this by allowing the information normally passed to .linkonce to be passed to .section itself:
http://llvm.org/docs/Extensions.html#section-directive