mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-07-15 15:35:36 -04:00
b9fd0eee50b028e4752595a8cc293bf2c331b1b9
There are various places in the code that check whether mmapped structures are correctly aligned (or ALLOW_UNALIGNED is set). Some of these checks are asserts. Like the one in elf(32|64)_getshdr. We should not get into that part of the code if the shdr scn structure was cached in elf_begin because it was mmapped in and properly aligned. These asserts could trigger because in elf_begin.c file_read_elf () all alignment checks were combined. So even though only one of the ehdr, shdr or phdr structures were not properly aligned all structures would be copied. Also the phdr structure was not even read in elf_begin, so the alignment check was unnecessary. This patch splits the alignment checks and reading of ehdr and shdr structures into separate code paths. It also drops the phdr alignment checks in elf_begin. Those phdr checks are done in elf(32|64)_getphdr already. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Fundamental design decision: - the sizes of external and internal types are assumed to be the same. This leaves byte ordering aside. While assuming this the code can be greatly simplified and speed increases. Since no change violating this assumption is in sight this is believed to be a worthwhile optimization. - the ABI of the backend modules is not guaranteed. Really, no guarantee whatsoever. We are enforcing this in the code. The modules and their users must match. No third-party EBL module are supported or allowed. The only reason there are separate modules is to not have the code for all architectures in all the binaries. - although the public libraries (libasm, libdw) have a stable API and are backwards ABI compatible they, and the elfutils tools, do depend on each others internals, and on internals of libelf to provide their interfaces. So they should always be upgraded in lockstep when packaging the tools and libraries separately. For one example of how to do that, see the config/elfutils.spec.
Description
Languages
C
70.8%
Shell
22.6%
C++
3.3%
Makefile
1.4%
M4
1%
Other
0.8%