musl/ldso
Rich Felker 68a5a23abc fix dynamic linker mapping/clearing bss in first/only LOAD segment
writable load segments can have size-in-memory larger than their size
in the ELF file, representing bss or equivalent. the initial partial
page has to be zero-filled, and additional anonymous pages have to be
mapped such that accesses don't failt with SIGBUS.

map_library skips redundant MAP_FIXED mapping of the initial
(lowest-address) segment when processing LOAD segments since it was
already mapped when reserving the virtual address range, but in doing
so, inadvertently also skipped the code to fill/map bss. typical
executable and library files have two or more LOAD segments, and the
first one is text/rodata (non-writable) and thus has no bss, but it is
syntactically valid for an ELF program/library to put its writable
segment first, or to have only one segment (everything writable). the
binutils bfd-based linker has been observed to create such programs in
the presence of unusual sections or linker scripts.

fix by moving only the mmap_fixed operation under the conditional
rather than skipping the remainder of the loop body. add a check to
avoid bss processing in the case where the segment is not writable;
this should not happen, but if it does, the change would be a crashing
regression without this check.
2018-06-26 12:22:29 -04:00
..
dlstart.c fix regression in SH/FDPIC dynamic linker 2016-02-18 04:13:05 +00:00
dynlink.c fix dynamic linker mapping/clearing bss in first/only LOAD segment 2018-06-26 12:22:29 -04:00