]> git.proxmox.com Git - wasi-libc.git/commit
Make munmap() actually work. (#198)
authorwhitequark <whitequark@whitequark.org>
Tue, 26 May 2020 19:14:52 +0000 (19:14 +0000)
committerGitHub <noreply@github.com>
Tue, 26 May 2020 19:14:52 +0000 (12:14 -0700)
commit9b9d243bea9703f988528b95b6b5bf01b44fb75a
treea43365ae3f5f4de0996a8defaec7cd88ee1b9404
parent86550c37ab14962233f73413ea0e0c0e57d056d7
Make munmap() actually work. (#198)

Before this commit, he header of a mapped area, `struct map`, was
defined as follows:

    struct map {
        int prot;
        int flags;
        off_t offset;
        size_t length;
        char body[];
    };

Because the size and alignment of an `off_t` is 8 bytes, the entire
structure was padded to 24 bytes. However, the offset of `body` into
`struct map` was only 20 bytes. Therefore the code in mmap() and
munmap() did not agree on the offset from header to body.

This commit changes mmap() to skip the entire header, which is what
munmap() expects and what the size calculation uses.
libc-bottom-half/mman/mman.c