From: Alan Modra Date: Wed, 15 Jan 2025 12:51:32 +0000 (+1030) Subject: Tidy elf_mmap_section_contents X-Git-Tag: binutils-2_44~103 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb9ea706c5f845b6e245029a17f0ab8fc6fde739;p=thirdparty%2Fbinutils-gdb.git Tidy elf_mmap_section_contents It is simpler to clear the buffer pointer in the caller than pass a param that controls clearing. * elf.c (elf_mmap_section_contents): Remove final_link param. (_bfd_elf_mmap_section_contents): Instead set *buf to NULL here. (_bfd_elf_link_mmap_section_contents): Adjust. --- diff --git a/bfd/elf.c b/bfd/elf.c index d37f16e974b..1f2b82bfe92 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -14202,12 +14202,10 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec) return result; } -/* Mmap in section contents. If FINAL_LINK is false, set *BUF to NULL - before calling bfd_get_full_section_contents. */ +/* Mmap in section contents. */ static bool -elf_mmap_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **buf, - bool final_link) +elf_mmap_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **buf) { #ifdef USE_MMAP const struct elf_backend_data *bed = get_elf_backend_data (abfd); @@ -14232,17 +14230,11 @@ elf_mmap_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **buf, abort (); sec->mmapped_p = 1; - /* Never use the preallocated buffer if mmapp is used. */ + /* We can't use the final link preallocated buffer for mmap. */ *buf = NULL; } } #endif - /* NB: When this is called from elf_link_input_bfd, FINAL_LINK is - true. If FINAL_LINK is false, *BUF is set to the preallocated - buffer if USE_MMAP is undefined and *BUF is set to NULL if - USE_MMAP is defined. */ - if (!final_link) - *buf = NULL; bool ret = bfd_get_full_section_contents (abfd, sec, buf); if (ret && sec->mmapped_p) *buf = sec->contents; @@ -14254,7 +14246,8 @@ elf_mmap_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **buf, bool _bfd_elf_mmap_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **buf) { - return elf_mmap_section_contents (abfd, sec, buf, false); + *buf = NULL; + return elf_mmap_section_contents (abfd, sec, buf); } /* Mmap in the full section contents for the final link. */ @@ -14263,7 +14256,7 @@ bool _bfd_elf_link_mmap_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **buf) { - return elf_mmap_section_contents (abfd, sec, buf, true); + return elf_mmap_section_contents (abfd, sec, buf); } /* Munmap section contents. */