Fixes for running with undefined-behavior sanitizer
commit44ebecaaed17b55a4429ac137036c9894b0dd730
authorDouglas Katzman <dougk@google.com>
Fri, 20 Oct 2017 20:35:56 +0000 (20 16:35 -0400)
committerDouglas Katzman <dougk@google.com>
Fri, 20 Oct 2017 20:39:45 +0000 (20 16:39 -0400)
tree3a1399937f20a2af3fedf51a07acad27d1533b00
parent4bc48a90062da0033041a705cd6174757c20cd2f
Fixes for running with undefined-behavior sanitizer

- Terminate iteration of load_core_file() loop before remaining_len
  transitions to a "negative" (large positive) value.
  (It's an os_vm_size_t so this is flagged as causing wraparound on addition)

- Use memcpy() for all unaligned loads/stores.
  C compilers optimize that into a single instruction where possible.

- Spell 1 as 1U whenever it might get shifted leftward by 31 bits.

- Don't left-shift a negative number ever.
src/runtime/coreparse.c
src/runtime/hopscotch.c
src/runtime/immobile-space.c
src/runtime/runtime.h
src/runtime/unaligned.h [new file with mode: 0644]
src/runtime/x86-64-arch.c