From ddecdb58b032b77f4519fccdb1b57df9eebb5ce0 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Mon, 15 Feb 2016 15:59:58 -0700 Subject: [PATCH 1/3] configure: if the libc is lacking argp, use libargp This is a squash of the following patches from the yocto recipe for rng-tools v6.6. see here: https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-support/rng-tools/rng-tools?id=ca3a3be312a76426d4bcde8066f6ffcd50a6777e Original commit messages: 0001-If-the-libc-is-lacking-argp-use-libargp.patch On glibc systems, argp is provided by libc. However, on uclibc and other systems which lack argp in their C library, argp might be provided by a stand alone library, libargp. This patch adds tests to the build system to find who provides argp. X-Gentoo-Bug: 292191 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=292191 Reported-by: Ed Wildgoose Signed-off-by: Anthony G. Basile Signed-off-by: Christopher Larson 0002-Add-argument-to-control-the-libargp-dependency.patch This ensures that the builds are always deterministic. If the argument isn't passed, the default behavior is to use libargp if the libc doesn't have argp. Signed-off-by: Christopher Larson Signed-off-by: Hongxu Jia Signed-off-by: Nicola Lunghi <25422924+nicola-lunghi@users.noreply.github.com> --- configure.ac | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/configure.ac b/configure.ac index 5d4f270..3989102 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,13 @@ AC_ARG_WITH([pkcs11], [with_pkcs11=check] ) +AC_ARG_WITH([libargp], + AS_HELP_STRING([--without-libargp], + [Disable libargp support. Systems whose libc lacks argp can use libargp instead. (Default: check if libc lacks argp)]), + [with_libargp=$withval], + [with_libargp=check] +) + dnl Make sure anyone changing configure.ac/Makefile.am has a clue AM_MAINTAINER_MODE AM_PROG_AS @@ -153,6 +160,38 @@ AS_IF( ] ) +dnl Determine if we need libargp: either user requested, or libc has no argp +AS_IF( + [test "x$with_libargp" != "xyes"], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include ], + [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] + )], + [need_libargp=no], + [need_libargp=yes + if test "x$with_libargp" = "xno"; then + AC_MSG_FAILURE([libargp disabled and libc does not have argp]) + fi] + ) + ], + [need_libargp=yes], +) + +dnl Check for libargp +AS_IF( + [test "x$need_libargp" = "xyes"], + [ + AC_CHECK_LIB( + [argp], + [argp_parse], + [LIBS="$LIBS -largp"], + [AC_MSG_FAILURE([libargp not found])] + ) + ] +) + dnl ----------------- dnl Configure options dnl ----------------- From c58dd184c87b326999f62e6de0842a30897cf57c Mon Sep 17 00:00:00 2001 From: "Francisco Blas Izquierdo Riera (klondike)" Date: Mon, 22 Oct 2018 15:29:36 +0800 Subject: [PATCH 2/3] Fix assemby textrels on rdrand_asm.S on PIC x86 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch updates the fixes in the assembly in rdrand_asm.S in sys-apps/rng-tools-5 so it won't generate textrels on PIC systems. The main fixes are in the use of leal in SETPTR for such systems, the rest is the usual PIC support stuff. This should fix Gentoo bug #469962 and help fix #518210 This patch is released under the GPLv2 or a higher version license as is the original file as long as the author and the tester are credited. Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=469962 Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=518210 Signed-off-by: Francisco Blas Izquierdo Riera (klondike) Reported-by: cilly Reported-by: Manuel RĂ¼ger Tested-by: Anthony Basile --- rdrand_asm.S | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/rdrand_asm.S b/rdrand_asm.S index b5d260a..7811cf2 100644 --- a/rdrand_asm.S +++ b/rdrand_asm.S @@ -2,6 +2,7 @@ * Copyright (c) 2011-2014, Intel Corporation * Authors: Fenghua Yu , * H. Peter Anvin + * PIC code by: Francisco Blas Izquierdo Riera (klondike) * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -172,7 +173,19 @@ ENTRY(x86_rdseed_or_rdrand_bytes) jmp 4b ENDPROC(x86_rdseed_or_rdrand_bytes) +#if defined(__PIC__) +#define INIT_PIC() \ + pushl %ebx ; \ + call __x86.get_pc_thunk.bx ; \ + addl $_GLOBAL_OFFSET_TABLE_, %ebx +#define END_PIC() \ + popl %ebx +#define SETPTR(var,ptr) leal (var)@GOTOFF(%ebx),ptr +#else +#define INIT_PIC() +#define END_PIC() #define SETPTR(var,ptr) movl $(var),ptr +#endif #define PTR0 %eax #define PTR1 %edx #define PTR2 %ecx @@ -188,6 +201,7 @@ ENTRY(x86_aes_mangle) movl 8(%ebp), %eax movl 12(%ebp), %edx push %esi + INIT_PIC() #endif movl $512, CTR3 /* Number of rounds */ @@ -278,6 +292,7 @@ offset = offset + 16 movdqa %xmm7, (7*16)(PTR1) #ifdef __i386__ + END_PIC() pop %esi pop %ebp #endif @@ -292,6 +307,7 @@ ENTRY(x86_aes_expand_key) push %ebp mov %esp, %ebp movl 8(%ebp), %eax + INIT_PIC() #endif SETPTR(aes_round_keys, PTR1) @@ -321,6 +337,7 @@ ENTRY(x86_aes_expand_key) call 1f #ifdef __i386__ + END_PIC() pop %ebp #endif ret @@ -341,6 +358,16 @@ ENTRY(x86_aes_expand_key) ENDPROC(x86_aes_expand_key) +#if defined(__i386__) && defined(__PIC__) + .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat + .globl __x86.get_pc_thunk.bx + .hidden __x86.get_pc_thunk.bx + .type __x86.get_pc_thunk.bx, @function +__x86.get_pc_thunk.bx: + movl (%esp), %ebx + ret +#endif + .bss .balign 64 aes_round_keys: From 93cf98c9a5670fa5f2ae46fb92b9f253b9140f10 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 22 Oct 2018 15:27:41 +0800 Subject: [PATCH 3/3] Fix underquoted m4 entry. This causes a failure if gcrypt isn't present: | configure: libgcrypt support disabled | ../rng-tools-5/configure: line 4345: ac_fn_c_try_link: command not found | configure: error: in `/media/build1/poky/build/tmp/work/i586-poky-linux/rng-tools/5-r0/build': Signed-off-by: Hongxu Jia --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 3989102..8f6c993 100644 --- a/configure.ac +++ b/configure.ac @@ -142,7 +142,7 @@ AS_IF( [test "x$with_libgcrypt" != "xno"], [ AC_CHECK_HEADER([gcrypt.h], - AC_CHECK_LIB( + [AC_CHECK_LIB( [gcrypt], [gcry_check_version], , [ @@ -151,7 +151,7 @@ AS_IF( AC_MSG_NOTICE([libgcrypt support disabled]) fi ] - ), + )], [if test "x$with_libgcrypt" != "xcheck"; then AC_MSG_FAILURE([libgcrypt headers not found]); else AC_MSG_NOTICE([libgcrypt support disabled])