This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] ELF: Add support for unique section ID to assembler
On Sun, Feb 2, 2020 at 5:10 PM Fangrui Song <i@maskray.me> wrote:
>
>
> On 2020-02-02, H.J. Lu wrote:
> >On Sun, Feb 2, 2020@4:22 PM Alan Modra <amodra@gmail.com> wrote:
> >>
> >> On Sun, Feb 02, 2020@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.
>
> Thanks for the patch! Looks good.
>
> + sections withe the same section name. */
>
> Typo. withe -> with
Oops. Fixed with this.
Thanks.
--
H.J.
From ef4627fabaebd4f4a2bc2c5e92c95d747f388d78 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 2 Feb 2020 17:14:12 -0800
Subject: [PATCH] section.c: Fix typo in comments (withe -> with)
* bfd-in2.h: Regenerated.
* section.c (SEC_ASSEMBLER_SECTION_ID): Fix a typo in comments.
---
bfd/ChangeLog | 5 +++++
bfd/bfd-in2.h | 2 +-
bfd/section.c | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f8e7dfaf94..f758f65034 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-02 H.J. Lu <hongjiu.lu@intel.com>
+
+ * bfd-in2.h: Regenerated.
+ * section.c (SEC_ASSEMBLER_SECTION_ID): Fix a typo in comments.
+
2020-02-02 H.J. Lu <hongjiu.lu@intel.com>
PR gas/25380
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index c890520ccb..09a5a39ff5 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -933,7 +933,7 @@ typedef struct bfd_section
#define SEC_LINKER_CREATED 0x100000
/* This section contains a section ID to distinguish different
- sections withe the same section name. */
+ sections with the same section name. */
#define SEC_ASSEMBLER_SECTION_ID 0x100000
/* This section should not be subject to garbage collection.
diff --git a/bfd/section.c b/bfd/section.c
index 161ed33edc..0c15a0d646 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -292,7 +292,7 @@ CODE_FRAGMENT
.#define SEC_LINKER_CREATED 0x100000
.
. {* This section contains a section ID to distinguish different
-. sections withe the same section name. *}
+. sections with the same section name. *}
.#define SEC_ASSEMBLER_SECTION_ID 0x100000
.
. {* This section should not be subject to garbage collection.
--
2.24.1