HomeFreeBSD

rtld: do not try to mmap a zero-sized PT_LOAD

Description

rtld: do not try to mmap a zero-sized PT_LOAD

When a PT_LOAD segment has a zero p_filesz, skip the data mmap, as mmapping
zero bytes from a file is an error.

A PT_LOAD with zero p_filesz is legal (but somewhat uncommon due to segment
merging in modern linkers, as it is more efficient to merge .data and .bss
by just extending p_memsz in the previous segment, assuming compatible
page protection.)

This was seen on ports/graphics/glew on a powerpc64 ELFv2 experimental
build.

Submitted by: Alfredo Dal'Ava Junior <alfredo.junior@eldorado.org.br>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D22634

Details

Provenance
bdragonAuthored on
Reviewer
kib
Differential Revision
D22634: rtld: do not try to mmap a zero-sized PT_LOAD
Parents
rS355656: [PowerPC] Fix SPE floating point environment manipulation
Branches
Unknown
Tags
Unknown