[Buildroot] [PATCH 1/1] package/libnss: fix build on ARM big endian

Thomas Petazzoni thomas.petazzoni at bootlin.com
Sun Aug 8 20:22:52 UTC 2021


On Sat,  7 Aug 2021 23:32:54 +0200
Fabrice Fontaine <fontaine.fabrice at gmail.com> wrote:

> Fix the follownig build failure on ARM big endian raised since bump to
> version 3.68 in commit 0a73b9b962421ce7a72c88e5f5bbd8849f21b041:
> 
> Linux2.6_aarch64_aarch64_be-linux-gnu-gcc_glibc_PTH_64_DBG.OBJ/Linux_SINGLE_SHLIB/sha256-armv8.o: In function `SHA256_Compress_Native':
> sha256-armv8.c:(.text.SHA256_Compress_Native+0x0): multiple definition of `SHA256_Compress_Native'
> Linux2.6_aarch64_aarch64_be-linux-gnu-gcc_glibc_PTH_64_DBG.OBJ/Linux_SINGLE_SHLIB/sha512.o:sha512.c:(.text.SHA256_Compress_Native+0x0): first defined here
> Linux2.6_aarch64_aarch64_be-linux-gnu-gcc_glibc_PTH_64_DBG.OBJ/Linux_SINGLE_SHLIB/sha256-armv8.o: In function `SHA256_Update_Native':
> sha256-armv8.c:(.text.SHA256_Update_Native+0x0): multiple definition of `SHA256_Update_Native'
> Linux2.6_aarch64_aarch64_be-linux-gnu-gcc_glibc_PTH_64_DBG.OBJ/Linux_SINGLE_SHLIB/sha512.o:sha512.c:(.text.SHA256_Update_Native+0x0): first defined here
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/237aba0c16a34fec1b0fe50fe08cace438eda1bf
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>
> ---
>  ...2.c-fix-SHA256-redefinition-on-ARM-b.patch | 47 +++++++++++++++++++
>  1 file changed, 47 insertions(+)
>  create mode 100644 package/libnss/0001-lib-freebl-sha512.c-fix-SHA256-redefinition-on-ARM-b.patch

I have applied to master. Giulio: I saw your comments, and we will
definitely be interested in hearing upstream's feedback.

However, what happens seems pretty clear: on Aarch64 (little endian or
big endian), sha256-armv8.c gets compiled, and it defines a function
called SHA256_Compress_Native(). This sha256-armv8.c code is included
inside a USE_HW_SHA2 conditional, so it is only compiled in if
USE_HW_SHA2 is defined.

sha512.c, which is architecture-independent generic code, also
implements a function called SHA256_Compress_Native(). It only defines
it when !USE_HW_SHA2, to not conflict with architecture-optimized
variants... but due to the bug it also defines it when !LITTLE_ENDIAN.
This doesn't make sense because there is nothing that prevents the
sha256-armv8.c code from being compiled in big-endian Aarch64, and this
issue was introduced when someone optimized the sha256 code for x86, as
pointed by Fabrice.

So I believe Fabrice's solution is OK, but of course, upstream will
confirm (or not).

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


More information about the buildroot mailing list