aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-02-02 17:07:51 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-02-02 17:08:01 -0800
commita8c4d40b578378be3b12575d127d4c7bd9972f32 (patch)
treefa3a722b3b535806f0f535a4c81c30f97da6b7ba /bfd
parent0f8b5e560e43ca0148162d30b83411b2107b27e5 (diff)
downloadfsf-binutils-gdb-a8c4d40b578378be3b12575d127d4c7bd9972f32.zip
fsf-binutils-gdb-a8c4d40b578378be3b12575d127d4c7bd9972f32.tar.gz
fsf-binutils-gdb-a8c4d40b578378be3b12575d127d4c7bd9972f32.tar.bz2
ELF: Add support for unique section ID to assembler
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. bfd/ PR gas/25380 * bfd-in2.h: Regenerated. * ecoff.c (bfd_debug_section): Add section_id. * section.c (bfd_section): Add section_id. (SEC_ASSEMBLER_SECTION_ID): New. (BFD_FAKE_SECTION): Add section_id. binutils/ PR gas/25380 * objdump.c (sym_ok): Return FALSE if 2 sections are in the same file with different section pointers. gas/ PR gas/25380 * config/obj-elf.c (section_match): Removed. (get_section): Also match SEC_ASSEMBLER_SECTION_ID and section_id. (obj_elf_change_section): Replace info and group_name arguments with match_p. Also update the section ID and flags from match_p. (obj_elf_section): Handle "unique,N". Update call to obj_elf_change_section. * config/obj-elf.h (elf_section_match): New. (obj_elf_change_section): Updated. * config/tc-arm.c (start_unwind_section): Update call to obj_elf_change_section. * config/tc-ia64.c (obj_elf_vms_common): Likewise. * config/tc-microblaze.c (microblaze_s_data): Likewise. (microblaze_s_sdata): Likewise. (microblaze_s_rdata): Likewise. (microblaze_s_bss): Likewise. * config/tc-mips.c (s_change_section): Likewise. * config/tc-msp430.c (msp430_profiler): Likewise. * config/tc-rx.c (parse_rx_section): Likewise. * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise. * doc/as.texi: Document "unique,N" in .section directive. * testsuite/gas/elf/elf.exp: Run "unique,N" tests. * testsuite/gas/elf/section15.d: New file. * testsuite/gas/elf/section15.s: Likewise. * testsuite/gas/elf/section16.s: Likewise. * testsuite/gas/elf/section16a.d: Likewise. * testsuite/gas/elf/section16b.d: Likewise. * testsuite/gas/elf/section17.d: Likewise. * testsuite/gas/elf/section17.l: Likewise. * testsuite/gas/elf/section17.s: Likewise. * testsuite/gas/i386/unique.d: Likewise. * testsuite/gas/i386/unique.s: Likewise. * testsuite/gas/i386/x86-64-unique.d: Likewise. * testsuite/gas/i386/i386.exp: Run unique and x86-64-unique. ld/ PR gas/25380 * testsuite/ld-i386/pr22001-1c.S: Use "unique,N" in .section directives. * testsuite/ld-i386/tls-gd1.S: Likewise. * testsuite/ld-x86-64/pr21481b.S: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/bfd-in2.h12
-rw-r--r--bfd/ecoff.c6
-rw-r--r--bfd/section.c12
4 files changed, 33 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f252905..f8e7dfa 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-02 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gas/25380
+ * bfd-in2.h: Regenerated.
+ * ecoff.c (bfd_debug_section): Add section_id.
+ * section.c (bfd_section): Add section_id.
+ (SEC_ASSEMBLER_SECTION_ID): New.
+ (BFD_FAKE_SECTION): Add section_id.
+
2020-02-01 Nick Clifton <nickc@redhat.com>
* config.bfd: Move the c30-aout and tic30-aout targets onto the
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 8144b16..c890520 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -795,6 +795,10 @@ typedef struct bfd_section
/* A unique sequence number. */
unsigned int id;
+ /* A unique section number which can be used by assembler to
+ distinguish different sections with the same section name. */
+ unsigned int section_id;
+
/* Which section in the bfd; 0..n-1 as sections are created in a bfd. */
unsigned int index;
@@ -928,6 +932,10 @@ typedef struct bfd_section
else up the line will take care of it later. */
#define SEC_LINKER_CREATED 0x100000
+ /* This section contains a section ID to distinguish different
+ sections withe the same section name. */
+#define SEC_ASSEMBLER_SECTION_ID 0x100000
+
/* This section should not be subject to garbage collection.
Also set to inform the linker that this section should not be
listed in the link map as discarded. */
@@ -1329,8 +1337,8 @@ discarded_section (const asection *sec)
}
#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS) \
- /* name, id, index, next, prev, flags, user_set_vma, */ \
- { NAME, IDX, 0, NULL, NULL, FLAGS, 0, \
+ /* name, id, section_id, index, next, prev, flags, user_set_vma, */ \
+ { NAME, IDX, 0, 0, NULL, NULL, FLAGS, 0, \
\
/* linker_mark, linker_has_input, gc_mark, decompress_status, */ \
0, 0, 1, 0, \
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index f271362..050fd7b 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -52,8 +52,10 @@
/* This stuff is somewhat copied from coffcode.h. */
static asection bfd_debug_section =
{
- /* name, id, index, next, prev, flags, user_set_vma, */
- "*DEBUG*", 0, 0, NULL, NULL, 0, 0,
+ /* name, id, section_id, index, next, prev, flags, */
+ "*DEBUG*", 0, 0, 0, NULL, NULL, 0,
+ /* user_set_vma, */
+ 0,
/* linker_mark, linker_has_input, gc_mark, compress_status, */
0, 0, 1, 0,
/* segment_mark, sec_info_type, use_rela_p, */
diff --git a/bfd/section.c b/bfd/section.c
index d42c2b4..161ed33 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -154,6 +154,10 @@ CODE_FRAGMENT
. {* A unique sequence number. *}
. unsigned int id;
.
+. {* A unique section number which can be used by assembler to
+. distinguish different sections with the same section name. *}
+. unsigned int section_id;
+.
. {* Which section in the bfd; 0..n-1 as sections are created in a bfd. *}
. unsigned int index;
.
@@ -287,6 +291,10 @@ CODE_FRAGMENT
. else up the line will take care of it later. *}
.#define SEC_LINKER_CREATED 0x100000
.
+. {* This section contains a section ID to distinguish different
+. sections withe the same section name. *}
+.#define SEC_ASSEMBLER_SECTION_ID 0x100000
+.
. {* This section should not be subject to garbage collection.
. Also set to inform the linker that this section should not be
. listed in the link map as discarded. *}
@@ -688,8 +696,8 @@ CODE_FRAGMENT
.}
.
.#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS) \
-. {* name, id, index, next, prev, flags, user_set_vma, *} \
-. { NAME, IDX, 0, NULL, NULL, FLAGS, 0, \
+. {* name, id, section_id, index, next, prev, flags, user_set_vma, *} \
+. { NAME, IDX, 0, 0, NULL, NULL, FLAGS, 0, \
. \
. {* linker_mark, linker_has_input, gc_mark, decompress_status, *} \
. 0, 0, 1, 0, \