This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Some extensions to the .section directive for ELF and COFF
- From: Alan Modra <amodra at gmail dot com>
- To: Rafael Espíndola <rafael dot espindola at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>, Eric Christopher <echristo at gmail dot com>, nickc at redhat dot com, Richard Sandiford <rsandifo at linux dot vnet dot ibm dot com>, Reid Kleckner <rnk at google dot com>
- Date: Thu, 26 Mar 2015 12:26:31 +1030
- Subject: Re: Some extensions to the .section directive for ELF and COFF
- Authentication-results: sourceware.org; auth=none
- References: <CAG3jReLKTfN_o1x7_jpMDVzMHemmx9K9P4-yU4qNLm2xtPpd+Q at mail dot gmail dot com>
On Wed, Mar 25, 2015 at 01:03:57PM -0400, Rafael Espíndola wrote:
> The solutions was to make the COFF .section look a bit more like the ELF one:
>
> .section foo, "dr", discard, "Symbol1"
> .section foo, "dr", discard, "Symbol2"
>
> creates two sections named foo with different comdat symbols. This is
> currently used by LLVM on windows as it matches the behavior of cl.
>
> The issue with the ELF one was similar: We need different section
> names unless the comdats are different. This in turn requires the
> compiler to be creative with section names when using
> -ffunction-section -fdata-sections and those can get quite big.
>
> The extension was to add an optional ",unique":
>
> -----------------------------------------
> .section .text,"ax",@progbits,unique
> .section .text,"ax",@progbits,unique
> -----------------------------------------
>
> Creates two sections named ".text".
Sounds reasonable, but, having changed from one of these sections, how
do you change back into the right one? Hmm, I guess .pushsection
.popsection will work, and .previous, but plain .text won't. Oh well,
I guess that's not a really big problem, but something that assembly
programmers will need to consider.
I suspect having two .text sections will run into other issues lurking
in gas.. For example, section symbols for these sections, ARM and
IA64 unwind sections for .text, obj-ecoff.c:tc_frob_file_before_fix,
and probably more.
--
Alan Modra
Australia Development Lab, IBM