* unexelf.c: Fix some 32-bit integer problems, notably when debugging.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 6 May 2013 04:52:00 +0000 (21:52 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 6 May 2013 04:52:00 +0000 (21:52 -0700)
commit5ee94506f6ee4f5142bfeabc9409f95e370d38e3
tree929f38ea53bd29b1b3141a5d09bfcafa0bb1e8f7
parentdc4a2ee0efe25b03973ea5feb5de9e46560a8127
* unexelf.c: Fix some 32-bit integer problems, notably when debugging.

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.
src/ChangeLog
src/unexelf.c