static bool _bfd_elf_fix_symbol_flags
(struct elf_link_hash_entry *, struct elf_info_failed *);
+/* Return false if linker should avoid caching relocation information
+ and symbol tables of input files in memory. */
+
+static bool
+_bfd_elf_link_keep_memory (struct bfd_link_info *info)
+{
+#ifdef USE_MMAP
+ /* Don't cache symbol nor relocation tables if they are mapped in.
+ NB: Since the --no-keep-memory linker option causes:
+
+ https://sourceware.org/bugzilla/show_bug.cgi?id=31458
+
+ this is opt-in by each backend. */
+ const struct elf_backend_data *bed
+ = get_elf_backend_data (info->output_bfd);
+ if (bed->use_mmap)
+ return false;
+#endif
+ bfd *abfd;
+ bfd_size_type size;
+
+ if (!info->keep_memory)
+ return false;
+
+ if (info->max_cache_size == (bfd_size_type) -1)
+ return true;
+
+ abfd = info->input_bfds;
+ size = info->cache_size;
+ do
+ {
+ if (size >= info->max_cache_size)
+ {
+ /* Over the limit. Reduce the memory usage. */
+ info->keep_memory = false;
+ return false;
+ }
+ if (!abfd)
+ break;
+ size += abfd->alloc_size;
+ abfd = abfd->link.next;
+ }
+ while (1);
+
+ return true;
+}
+
asection *
_bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
unsigned long r_symndx,
|| bfd_is_abs_section (o->output_section))
continue;
- internal_relocs = _bfd_elf_link_info_read_relocs (abfd, info,
- o, NULL,
- NULL,
- _bfd_link_keep_memory (info));
+ internal_relocs = _bfd_elf_link_info_read_relocs
+ (abfd, info, o, NULL, NULL,
+ _bfd_elf_link_keep_memory (info));
if (internal_relocs == NULL)
return false;
&& (s->flags & SEC_DEBUGGING) != 0))
continue;
- internal_relocs = _bfd_elf_link_info_read_relocs (abfd, info,
- s, NULL,
- NULL,
- _bfd_link_keep_memory (info));
+ internal_relocs = _bfd_elf_link_info_read_relocs
+ (abfd, info, s, NULL, NULL,
+ _bfd_elf_link_keep_memory (info));
if (internal_relocs == NULL)
goto error_free_vers;
info->callbacks->einfo (_("%P%X: can not read symbols: %E\n"));
return false;
}
- if (_bfd_link_keep_memory (info) )
+ if (_bfd_elf_link_keep_memory (info) )
{
symtab_hdr->contents = (bfd_byte *) cookie->locsyms;
info->cache_size += (cookie->locsymcount
}
else
{
- cookie->rels = _bfd_elf_link_info_read_relocs (abfd, info, sec,
- NULL, NULL,
- _bfd_link_keep_memory (info));
+ cookie->rels = _bfd_elf_link_info_read_relocs
+ (abfd, info, sec, NULL, NULL,
+ _bfd_elf_link_keep_memory (info));
if (cookie->rels == NULL)
return false;
cookie->rel = cookie->rels;
{
return (struct bfd_link_hash_entry *) _bfd_ptr_bfd_null_error (sec->owner);
}
-
-/* Return false if linker should avoid caching relocation infomation
- and symbol tables of input files in memory. */
-
-bool
-_bfd_link_keep_memory (struct bfd_link_info * info)
-{
- bfd *abfd;
- bfd_size_type size;
-
- if (!info->keep_memory)
- return false;
-
- if (info->max_cache_size == (bfd_size_type) -1)
- return true;
-
- abfd = info->input_bfds;
- size = info->cache_size;
- do
- {
- if (size >= info->max_cache_size)
- {
- /* Over the limit. Reduce the memory usage. */
- info->keep_memory = false;
- return false;
- }
- if (!abfd)
- break;
- size += abfd->alloc_size;
- abfd = abfd->link.next;
- }
- while (1);
-
- return true;
-}