[PATCH] ELF: Add support for unique section ID to assembler
H.J. Lu
hjl.tools@gmail.com
Mon Feb 3 01:05:00 GMT 2020
On Sun, Feb 2, 2020 at 4:22 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Feb 02, 2020 at 09:50:54AM -0800, H.J. Lu wrote:
> > Clang's integrated assembler supports multiple section with the same
> > name:
> >
> > .section .text,"ax",@progbits,unique,1
> > nop
> > .section .text,"ax",@progbits,unique,2
> > nop
> >
> > "unique,N" assigns the number, N, as the section ID, to a section. The
> > valid values of the section ID are between 0 and 4294967295. It can be
> > used to distinguish different sections with the same section name.
> >
> > This is useful with -fno-unique-section-names -ffunction-sections.
> > -ffunction-sections by default generates .text.foo, .text.bar, etc.
> > Using the same string can save lots of space in .strtab.
> >
> > This patch adds section_id to bfd_section and reuses the linker
> > internal bit in BFD section flags, SEC_LINKER_CREATED, for assmebler
> > internal use to mark valid section_id. It also updates objdump to
> > compare section pointers if 2 sections comes from the same file since
> > 2 different sections can have the same section name.
>
> Looks OK to me.
>
This is the patch I am checking in. I updated documentation with
iff --git a/gas/doc/as.texi b/gas/doc/as.texi
index fa155096159..152bbfdd009 100644
--- a/gas/doc/as.texi
+++ b/gas/doc/as.texi
@@ -6709,6 +6709,18 @@ this directive. If that section used @code{G}, then the
new section will use
@code{G} with those same @var{GroupName} and @var{linkage} fields implicitly.
If not, then the @code{?} symbol has no effect.
+The optional @var{unique,@code{<number>}} argument must come last. It
+assigns @var{@code{<number>}} as a unique section ID to distinguish
+different sections with the same section name like these:
+
+@smallexample
+.section @var{name},"@var{flags}",@@@var{type},@var{unique,@code{<number>}}
+.section @var{name},"@var{flags}"G,@@@var{type},@var{GroupName},[@var{linkage}]
,@var{unique,@code{<number>}}
+.section @var{name},"@var{flags}"MG,@@@var{type},@var{entsize},@var{GroupName}[
,@var{linkage}],@var{unique,@code{<number>}}
+@end smallexample
+
+The valid values of @var{@code{<number>}} are between 0 and 4294967295.
+
If no flags are specified, the default flags depend upon the section name. If
the section name is not recognized, the default will be for the section to have
none of the above flags: it will not be allocated in memory, nor writable, nor
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ELF-Add-support-for-unique-section-ID-to-assembler.patch
Type: text/x-patch
Size: 40141 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200203/531adf6d/attachment.bin>
More information about the Binutils
mailing list