• Dmitry Safonov's avatar
    compel/tests: add sections table & string section tests · 3c966037
    Dmitry Safonov authored
    Now it has 4 new tests:
    ok 4 - section table start oob (64-bit ELF)
    ok 5 - too many sections in table (64-bit ELF)
    ok 6 - strings section's header oob of section table (64-bit ELF)
    ok 7 - strings section oob (64-bit ELF)
    
    I.e, if we forget to test string section's header oob with the next diff:
    >--- a/compel/handle-elf.c
    >+++ b/compel/handle-elf.c
    >@@ -122,7 +122,7 @@ static const char *get_strings_section(Ehdr_t *hdr, uintptr_t mem,
    >                pr_err("String section @%#zx size %#lx is out of [%#zx, %#zx)\n",
    >                        addr, (unsigned long)secstrings_hdr->sh_size,
    >                        mem, mem + size);
    >-               return NULL;
    >+               return (void*)addr;
    >        }
    >
    >        return (void*)addr;
    
    It will yell with:
    ok 1 - zero ELF header (64-bit ELF)
    ...
    not ok 6 - strings section's header oob of section table (64-bit ELF), expected -4 but ret is -1
    ...
    not ok 12 - strings section's header oob of section table (32-bit ELF), expected -4 but ret is -1
    
    Should be more useful when I add relocations tests after all.
    (but this seems for me useful too).
    
    Cc: Cyrill Gorcunov <gorcunov@openvz.org>
    Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
    Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
    3c966037
Name
Last commit
Last update
..
arch Loading commit data...
include Loading commit data...
Makefile Loading commit data...
handle-elf-32.c Loading commit data...
handle-elf.c Loading commit data...
main.c Loading commit data...