[PATCH v4 3/6] elf: Use mmap to map in read-only sections
Alan Modra
amodra@gmail.com
Fri Mar 8 00:40:05 GMT 2024
On Wed, Mar 06, 2024 at 03:23:58PM -0800, H.J. Lu wrote:
> Add _bfd_mmap_readonly_tracked and _bfd_mmap_readonly_untracked to mmap
> in reado-only sections with size >= 4 * page size.
These are better names than in the original patch, but I'm thinking
that _bfd_mmap_persistent, _bfd_mmap_temporary and
_bfd_munmap_temporary or some variation on that might better reflect
their use.
> (setup_group): Call _bfd_mmap_readonly_tracked instead of
> _bfd_alloc_and_read to map in the group section as read-only
> and allocate the memory for internal use separately.
I doubt you will usually get to the minimum mmap size for SHT_GROUP
sections. So this change will often require a malloc'd buffer for
section contents. (The internal buffer is always at least as large as
the section contents. The current code uses the same buffer for both
external section contents and the internal representation.) So I
think it is better to continue to use _bfd_alloc_and_read here.
Other than that, this is OK.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list