Mark Wielaard <[email protected]> writes:

> Hi,
>
> The code supported direct unaligned accesses of various types when
> ALLOW_UNALIGNED was defined (only for i386 and x86_64). This is
> normally undefined behavior and has bitten us in the past when some
> optimization (e.g. when data was accesses through sse vectors) used
> some instructions that required aligned access. It also made some of
> the code harder to analyze. And it required disabling when running
> under the undefined sanitizer.
>
> In practise Elf file images are properly aligned, so a lot of this
> code was never run. Also the code that already handled unaligned code
> by first using memcpy to put it into a properly aligned buffer
> produced identialy code.
>
> So simplify the code a bit by removing the ALLOW_UNALIGNED cases.  I
> tried to do it is small bits and pieces to make the patches easier to
> review. They should all build and pass make check (the get_shnum and
> file_read_elf one should come before the phdr and shdr changes and the
> config one should be last).
>
>  [PATCH 01/10] elflint: Drop ALLOW_UNALIGNED code, use memcpy for
>                         reading section groups.
>  [PATCH 02/10] libelf: Drop ALLOW_UNALIGNED condition in elf_getarsym
>  [PATCH 03/10] libelf: Drop ALLOW_UNALIGNED condition in get_shnum
>  [PATCH 04/10] libelf: Drop ALLOW_UNALIGNED condition in file_read_elf
>  [PATCH 05/10] libelf: Drop ALLOW_UNALIGNED condition in elf_getshdrstrndx
>  [PATCH 06/10] libelf: Drop ALLOW_UNALIGNED condition in getphdr
>  [PATCH 07/10] libelf: Drop ALLOW_UNALIGNED condition in getshdr
>  [PATCH 08/10] libcpu: Use memcpy for all unaligned read in memory-access.h
>  [PATCH 09/10] libdw: Use memcpy for all unaligned read in memory-access.h
>  [PATCH 10/10] config: Drop ALLOW_UNALIGNED and CHECK_UNDEFINED from
>                        configure eu-config.h
>
> This also fixes one wrong alignement check in elf_getarsym.
>
> Note that the libcpu and libdw memory-access.h changes might look
> identical, but they handle endianess differences differently (one
> based on the Elf Dbg endianess, to other on the machine definition
> endianess).

For the series:

Reviewed-by: Sam James <[email protected]>

>
> Cheers,
>
> Mark

Attachment: signature.asc
Description: PGP signature

Reply via email to