Hi Oleg ! Compiling newer versions of dropbear for the Elphel 353 firmware using the crisv32 compiler was failing with "bignum invalid" errors.
Last time I had to remove some "useless" code from dropbear in order to compile it successfuly. This time instead I patched the crisv32 assembler with the attached cris-dist patch, according to http://mhonarc.axis.se/dev-etrax/msg09904.html (see attached html) To recompile the cris-dist package successfully we just had to setup a virtual machine with VirtualBox, installing a minimal Debian wheezy (base system only) using debian-7.9.0-amd64-netinst.iso image, followed with only apt-get install build-essential then added the following line patch -p0 < ../cris-dist-1.64-bignum.patch to http://wiki.elphel.com/index.php?title=Elphel_Software_Kit_for_Ubuntu#Downloading_and_unpacking_gcc-cris For dropber, only an additional CLOCK_MONOTONIC=1 definition was needed in order to compile the latest release (see attached dropbear patch) Concerning cris-dist, it should be easy for the Elphel PPA maintainer to update the package on https://launchpad.net/~elphel/+archive/ubuntu/ppa (adding the bignum patch and rebuild the binary package) If anybody need it in the meanwhile I can send a link by mail for the cris-dist deb package I built using checkinstall/Makefile/tar ... Best to you, Luc
--- binutils/gas/expr.c.orig 2002-02-01 20:06:05.000000000 +0100 +++ binutils/gas/expr.c 2016-05-21 19:55:35.007401999 +0200 @@ -37,6 +37,7 @@ #ifdef BFD64 static valueT generic_bignum_to_int64 PARAMS ((void)); #endif +static void bignum_negate PARAMS ((expressionS *)); static void integer_constant PARAMS ((int radix, expressionS * expressionP)); static void mri_char_constant PARAMS ((expressionS *)); static void current_location PARAMS ((expressionS *)); @@ -756,6 +757,40 @@ } } +/* In: An expressionP for a bignum to negate. + + Out: A negated expressionP. + && exp->X_add_number == 0 + && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big +*/ + +static void +bignum_negate (exp) + expressionS *exp; +{ + int i; + unsigned long carry; + + /* Negate the bignum: one's complement each digit and add 1. */ + carry = 1; + for (i = 0; i < exp->X_add_number; i++) + { + unsigned long next; + + next = (((~(generic_bignum[i] & LITTLENUM_MASK)) + & LITTLENUM_MASK) + + carry); + generic_bignum[i] = next & LITTLENUM_MASK; + carry = next >> LITTLENUM_NUMBER_OF_BITS; + } + + if (carry > 0) + { + generic_bignum[exp->X_add_number] = carry; + exp->X_add_number ++; + } +} + /* In: Input_line_pointer points to 1st char of operand, which may be a space. @@ -1082,14 +1117,24 @@ else if (expressionP->X_op != O_illegal && expressionP->X_op != O_absent) { - expressionP->X_add_symbol = make_expr_symbol (expressionP); if (c == '-') - expressionP->X_op = O_uminus; + { + if (expressionP->X_op == O_big + && expressionP->X_add_number > 0) + bignum_negate(expressionP); + else + expressionP->X_op = O_uminus; + } else if (c == '~' || c == '"') expressionP->X_op = O_bit_not; else expressionP->X_op = O_logical_not; - expressionP->X_add_number = 0; + + if (expressionP->X_op != O_big) + { + expressionP->X_add_number = 0; + expressionP->X_add_symbol = make_expr_symbol (expressionP); + } } else as_warn (_("Unary operator %c ignored because bad operand follows"),
--- Makefile.orig 2016-05-22 16:50:46.139401999 +0200 +++ Makefile 2016-05-22 16:50:59.047401999 +0200 @@ -20,7 +20,7 @@ ifeq (1, 1) LIBTOM_DEPS=$(STATIC_LTC) $(STATIC_LTM) -CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/ +CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/ -DCLOCK_MONOTONIC=1 LIBTOM_LIBS=$(STATIC_LTC) $(STATIC_LTM) endifTitle: "bignum invalid" error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"bignum invalid" error
- To: <dev-etrax@xxxxxxxx>
- Subject: "bignum invalid" error
- From: "Radioactivity srl - Roberto Roberti" <r.roberti@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Mar 2012 16:57:09 +0100
- Delivered-to: dev-et...@xxxxxxx.com
- Sender: owner-dev-etrax@xxxxxxxx
- Thread-index: Ac0JDZqg9ipIbgTdRRaPrbF1BHeU5Q==
Hi all. I hope this could be useful for you. While installing the SDK 2.20-RC2 for ETRAX 100 LX from tarball, I enabled the Openswan package; the "make" of Openswan ended with a lot of these the errors: /tmp/ccKdfed7.s: Assembler messages: /tmp/ccKdfed7.s:106: Error: bignum invalid Looking into the assembler code, I found that the "wrong" lines was related to a static initialization of a 64-bits variables array; the assembler produced the error on the occurrence of a negative value. For example, initializing an u_int64_t variable with the value 0xb5c0fbcfec4d3b2fULL produce this line of assembler code: .quad -5349999486874862801 It seems that the above syntax isn't accepted by the assembler. Digging on the web, I found that many people encountered this trouble, and in one site (http://lists.freebsd.org/pipermail/freebsd-amd64/2004-March/000886.html) I found the solution, which is to patch the file expr.c under binutils/gas in the cmpiler SDK (I used the release 1.64). Once patched the file and rebuilt the compiler, the generation of Openswan was successful, so I expect not to have this trouble in other packages also. Below you see the output of the "diff" between the original file and the patched: --- expr.c.ori 2002-02-01 20:06:05.000000000 +0100 +++ expr.c 2012-03-21 17:36:29.000000000 +0100 @@ -37,6 +37,7 @@ #ifdef BFD64 static valueT generic_bignum_to_int64 PARAMS ((void)); #endif +static void bignum_negate PARAMS ((expressionS *)); static void integer_constant PARAMS ((int radix, expressionS * expressionP)); static void mri_char_constant PARAMS ((expressionS *)); static void current_location PARAMS ((expressionS *)); @@ -756,6 +757,40 @@ } } +/* In: An expressionP for a bignum to negate. + + Out: A negated expressionP. + && exp->X_add_number == 0 + && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big +*/ + +static void +bignum_negate (exp) + expressionS *exp; +{ + int i; + unsigned long carry; + + /* Negate the bignum: one's complement each digit and add 1. */ + carry = 1; + for (i = 0; i < exp->X_add_number; i++) + { + unsigned long next; + + next = (((~(generic_bignum[i] & LITTLENUM_MASK)) + & LITTLENUM_MASK) + + carry); + generic_bignum[i] = next & LITTLENUM_MASK; + carry = next >> LITTLENUM_NUMBER_OF_BITS; + } + + if (carry > 0) + { + generic_bignum[exp->X_add_number] = carry; + exp->X_add_number ++; + } +} + /* In: Input_line_pointer points to 1st char of operand, which may be a space. @@ -1082,14 +1117,24 @@ else if (expressionP->X_op != O_illegal && expressionP->X_op != O_absent) { - expressionP->X_add_symbol = make_expr_symbol (expressionP); if (c == '-') - expressionP->X_op = O_uminus; + { + if (expressionP->X_op == O_big + && expressionP->X_add_number > 0) + bignum_negate(expressionP); + else + expressionP->X_op = O_uminus; + } else if (c == '~' || c == '"') expressionP->X_op = O_bit_not; else expressionP->X_op = O_logical_not; - expressionP->X_add_number = 0; + + if (expressionP->X_op != O_big) + { + expressionP->X_add_number = 0; + expressionP->X_add_symbol = make_expr_symbol (expressionP); + } } else as_warn (_("Unary operator %c ignored because bad operand follows"), Best regards Roberto Roberti Radio Activity srl Via Ponte Nuovo 8 20128 Milano MI Tel.: +39 0236 514 205 Fax: +39 0236 514 312 www.radioactivity-tlc.it
- Prev by Date: Re: Sync Serial and SPI
- Next by Date: change runlevel at boot
- Previous by thread: Re: Sync Serial and SPI
- Next by thread: change runlevel at boot
- Index(es):
_______________________________________________ Support-list mailing list Support-list@support.elphel.com http://support.elphel.com/mailman/listinfo/support-list_support.elphel.com