binutils-gdb/libctf
Nick Alcock 7cee18263c libctf: endianness fixes
Testing of the first code to generate CTF_K_SLICEs on big-endian
revealed a bunch of new problems in this area.  Most importantly, the
trick we did earlier to avoid wasting two bytes on padding in the
ctf_slice_t is best avoided: because it leads to the whole file after
that point no longer being naturally aligned, all multibyte accesses
from then on must use memmove() to avoid unaligned access on platforms
where that is fatal.  In future, this is planned, but for now we are
still doing direct access in many places, so we must revert to making
ctf_slice_t properly aligned for storage in an array.

Rather than wasting bytes on padding, we boost the size of cts_offset
and cts_bits.  This is still a waste of space (we cannot have offsets or
bits in bitfields > 256) but it cannot be avoided for now, and slices
are not so common that this will be a serious problem.

A possibly-worse endianness problem fixed at the same time involves
a codepath used only for foreign-endian, uncompressed CTF files, where
we were not copying the actual CTF data into the buffer, leading to
libctf reading only zeroes (or, possibly, uninitialized garbage).

Finally, when we read in a CTF file, we copy the header and work from
the copy.  We were flipping the endianness of the header copy, and of
the body of the file buffer, but not of the header in the file buffer
itself: so if we write the file back out again we end up with an
unreadable frankenfile with header and body of different endiannesses.
Fix by flipping both copies of the header.

include/
	* ctf.h (ctf_slice_t): Make cts_offset and cts_bits unsigned
	short, so following structures are properly aligned.

libctf/
	* ctf-open.c (get_vbytes_common): Return the new slice size.
	(ctf_bufopen): Flip the endianness of the CTF-section header copy.
	Remember to copy in the CTF data when opening an uncompressed
	foreign-endian CTF file.  Prune useless variable manipulation.
2019-06-21 13:04:02 +01:00
..
aclocal.m4 libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ChangeLog libctf: endianness fixes 2019-06-21 13:04:02 +01:00
config.h.in libctf: work on platforms without O_CLOEXEC. 2019-06-04 17:05:08 +01:00
configure Regenerate with approved autotools version 2019-06-14 10:30:35 +09:30
configure.ac libctf: work on platforms without O_CLOEXEC. 2019-06-04 17:05:08 +01:00
ctf-archive.c libctf: mark various args as unused in the !HAVE_MMAP case 2019-06-07 13:46:38 +01:00
ctf-create.c libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-decl.c
ctf-decls.h libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-dump.c libctf: explicitly cast more size_t types used in printf()s 2019-06-07 13:46:38 +01:00
ctf-endian.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-error.c
ctf-hash.c
ctf-impl.h libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-labels.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-lookup.c libctf: avoid strndup 2019-06-07 13:46:39 +01:00
ctf-open-bfd.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-open.c libctf: endianness fixes 2019-06-21 13:04:02 +01:00
ctf-qsort_r.c libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
ctf-subr.c libctf: drop mmap()-based CTF data allocator 2019-06-21 13:04:02 +01:00
ctf-types.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
ctf-util.c libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00
elf.h
Makefile.am libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
Makefile.in libctf: look for BSD versus GNU qsort_r signatures 2019-06-04 17:05:08 +01:00
swap.h libctf: fix a number of build problems found on Solaris and NetBSD 2019-05-31 11:10:51 +02:00