• Paul Eggert's avatar
    * unexelf.c: Fix some 32-bit integer problems, notably when debugging. · 5ee94506
    Paul Eggert authored
    Include <limits.h>, <stdbool.h>, <intprops.h>, <verify.h>.
    Verify that ElfW (Half) fits in int.
    (fatal): Use same signature as lisp.h.
    (UNEXELF_DEBUG): New macro, replacing DEBUG, so that people can
    configure and build with -DUNEXELF_DEBUG without worrying about
    other modules that use DEBUG.
    (DEBUG_LOG) [UNEXELF_DEBUG]: New macro.  All debug code that prints
    possibly-wide integers now uses it instead of plain fprintf.
    (entry_address): New function, which avoids problems with 32-bit
    overflow on 64-bit hosts.
    (OLD_SECTION_H, NEW_SECTION_H, NEW_PROGRAM_H): Use it.
    (round_up): Don't assume the remainder fits in int.
    (find_section): Use bool for boolean.  Simplify debug code.
    (unexec): Don't assume file sizes fit in int or size_t.
    Omit unnecessary trailing newline in 'fatal' format.
    Use strerror rather than outputting decimal error number.
    Remove unused code when emacs is not defined;
    this file relies on Emacs now.
    Don't assume e_phnum and e_shnum are positive.
    5ee94506
ChangeLog 933 KB