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
This commit is contained in:
parent
4f9ed3156c
commit
44c9aa49ea
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355657
@ -228,11 +228,12 @@ map_object(int fd, const char *path, const struct stat *sb)
|
||||
data_addr = mapbase + (data_vaddr - base_vaddr);
|
||||
data_prot = convert_prot(segs[i]->p_flags);
|
||||
data_flags = convert_flags(segs[i]->p_flags) | MAP_FIXED;
|
||||
if (mmap(data_addr, data_vlimit - data_vaddr, data_prot,
|
||||
data_flags | MAP_PREFAULT_READ, fd, data_offset) == (caddr_t) -1) {
|
||||
_rtld_error("%s: mmap of data failed: %s", path,
|
||||
rtld_strerror(errno));
|
||||
goto error1;
|
||||
if (data_vlimit != data_vaddr &&
|
||||
mmap(data_addr, data_vlimit - data_vaddr, data_prot,
|
||||
data_flags | MAP_PREFAULT_READ, fd, data_offset) == MAP_FAILED) {
|
||||
_rtld_error("%s: mmap of data failed: %s", path,
|
||||
rtld_strerror(errno));
|
||||
goto error1;
|
||||
}
|
||||
|
||||
/* Do BSS setup */
|
||||
|
Loading…
Reference in New Issue
Block a user