龍芯3A4000的linux系統下node14.17.5執行出現Floating point exception(浮點數異常)問題解決

竿钓蝉發表於2024-11-27

因專案需要在龍芯下使用node14.17.5執行構建任務,在使用原始碼編譯安裝後,執行時出現Floating point exception(浮點數異常)問題。

經除錯發現,其是在使用openssl載入ECC相關證書時使用mips64彙編程式碼時導致的。

在分析相關程式碼後,將deps下的openssl中的bn_div.c檔案的16行進行修改,重新編譯即可執行。

修改前程式碼片段如下:

/*
 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <assert.h>
#include <openssl/bn.h>
#include "internal/cryptlib.h"
#include "bn_local.h"

/* The old slow way */
#if 0
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
           BN_CTX *ctx)
{

修改後程式碼片段如下:

/*
 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <assert.h>
#include <openssl/bn.h>
#include "internal/cryptlib.h"
#include "bn_local.h"

/* The old slow way */
#if 1
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
           BN_CTX *ctx)
{

相關文章