This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] riscv: Cache the max alignment of output sections
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 10 Oct 2017 05:04:43 -0000
- Subject: [binutils-gdb] riscv: Cache the max alignment of output sections
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fc3c534364ca6d6de4f0dbcaf347ec85f5e2f8ff
commit fc3c534364ca6d6de4f0dbcaf347ec85f5e2f8ff
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Oct 9 22:03:42 2017 -0700
riscv: Cache the max alignment of output sections
Cache the max alignment of output sections instead of scanning all
output sections for each input section, which can take a very long
time if there are millions of input/output sections.
PR ld/22274
* elfnn-riscv.c (riscv_elf_link_hash_table): Add max_alignment.
(riscv_elf_link_hash_table_create): Initialize max_alignment to
(bfd_vma) -1.
(_bfd_riscv_relax_section): Cache the max alignment of output
sections if possible.
Diff:
---
bfd/ChangeLog | 9 +++++++++
bfd/elfnn-riscv.c | 16 +++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e6bd06f..f988812 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2017-10-09 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/22274
+ * elfnn-riscv.c (riscv_elf_link_hash_table): Add max_alignment.
+ (riscv_elf_link_hash_table_create): Initialize max_alignment to
+ (bfd_vma) -1.
+ (_bfd_riscv_relax_section): Cache the max alignment of output
+ sections if possible.
+
2017-10-10 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_before_check_relocs): Set sec_type for
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index b4d7b9b..52c461d 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -127,6 +127,9 @@ struct riscv_elf_link_hash_table
/* Small local sym to section mapping cache. */
struct sym_cache sym_cache;
+
+ /* The max alignment of output sections. */
+ bfd_vma max_alignment;
};
@@ -274,6 +277,7 @@ riscv_elf_link_hash_table_create (bfd *abfd)
return NULL;
}
+ ret->max_alignment = (bfd_vma) -1;
return &ret->elf.root;
}
@@ -3070,7 +3074,17 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec,
info->keep_memory)))
goto fail;
- max_alignment = _bfd_riscv_get_max_alignment (sec);
+ if (htab)
+ {
+ max_alignment = htab->max_alignment;
+ if (max_alignment == (bfd_vma) -1)
+ {
+ max_alignment = _bfd_riscv_get_max_alignment (sec);
+ htab->max_alignment = max_alignment;
+ }
+ }
+ else
+ max_alignment = _bfd_riscv_get_max_alignment (sec);
/* Examine and consider relaxing each reloc. */
for (i = 0; i < sec->reloc_count; i++)