aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-03-03 08:44:01 -0800
committerH.J. Lu <hjl.tools@gmail.com>2024-04-03 09:11:03 -0700
commitc6291d749aece753ae8dcba0a5baff2fe9598541 (patch)
tree27b0044bd8d5574abfd069e7c62ac704f75efe62 /bfd/libbfd.h
parent584b30e4b3538a64d38bc1da9cfa09fc9355378a (diff)
downloadgdb-c6291d749aece753ae8dcba0a5baff2fe9598541.zip
gdb-c6291d749aece753ae8dcba0a5baff2fe9598541.tar.gz
gdb-c6291d749aece753ae8dcba0a5baff2fe9598541.tar.bz2
elf: Use mmap to map in symbol and relocation tables
Add _bfd_mmap_read_temporary to mmap in symbol tables and relocations whose sizes >= 4 * page size. For the final link, allocate an external relocation buffer of 4 * page size to avoid using mmap and munmap on smaller relocation sections. Since _bfd_mmap_read_temporary allocates buffer as needed, its callers don't need to. When mmap is used to map in all ELF sections, data to link the 3.5GB clang executable in LLVM 17 debug build on Linux/x86-64 with 32GB RAM is: stdio mmap improvement user 84.79 85.27 -0.5% system 10.95 9.09 17% total 97.91 94.90 3% page faults 4837944 4033778 17% and data to link the 275M cc1plus executable in GCC 14 stage 1 build is: user 5.31 5.33 -0.4% system 0.86 0.76 12% total 6.19 6.13 1% page faults 361273 322491 11% * elf.c (bfd_elf_get_elf_syms): Don't allocate buffer for external symbol table. Replace bfd_read with _bfd_mmap_read_temporary. * elflink.c (elf_link_read_relocs_from_section): Add 2 arguments to return mmap memory address and size. (_bfd_elf_link_info_read_relocs): Don't allocate buffer for external relocation information. Replace bfd_read with _bfd_mmap_read_temporary. (bfd_elf_final_link): Cache external relocations up to _bfd_minimum_mmap_size bytes when mmap is used. * libbfd.c (_bfd_mmap_read_temporary): New. * libbfd-in.h (_bfd_mmap_read_temporary): Likewise. * libbfd.h: Regenerated.
Diffstat (limited to 'bfd/libbfd.h')
-rw-r--r--bfd/libbfd.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 0caf0f3..0676f46 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -911,6 +911,9 @@ extern void _bfd_munmap_readonly_temporary
#define _bfd_munmap_readonly_temporary(ptr, rsize) free (ptr)
#endif
+extern bool _bfd_mmap_read_temporary
+ (void **, size_t *, void **, bfd *, bool) ATTRIBUTE_HIDDEN;
+
static inline void *
_bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{