mips交叉编译pppd-2.4.6

(1)pppd源码下载: 本文使用pppd-2.4.6版本Index of /pub/pppicon-default.png?t=M5H6https://download.samba.org/pub/ppp/

(2)编译使用的是glibc2.29版本

gcc version 7.2.0 (Ingenic Linux-Release5.1.3-Default(xburst2(fp64)+glibc2.29) 2022.06-15 17:54:43)

之前使用glibc2.26编译都是正常了,这次使用glibc2.29报了下面的两处错误:

① 链接时找不到setkey encrypt这两个函数

pppcrypt.o: In function `DesSetkey':
/home_d/wjshi/ppp-2.4.6/pppd/pppcrypt.c:132: undefined reference to `setkey'
pppcrypt.o: In function `DesEncrypt':
/home_d/wjshi/ppp-2.4.6/pppd/pppcrypt.c:147: undefined reference to `encrypt'
pppcrypt.o: In function `DesDecrypt':
/home_d/wjshi/ppp-2.4.6/pppd/pppcrypt.c:163: undefined reference to `encrypt'

最开始以为程序没有链接到libcrypt.so动态库,后来发现Makefile有指定链接这个库。

使用nm命令查看了libcrypt.so库,发现符号变成了setkey@GLIBC_2.0,所以提示找不到

在glibc2.29中,之所以找不到setkey、encrypt函数,是因为最新的glibc认为setkey这一系列的函数存在高危漏洞,具体可以参考:Carlos O'Donell - The GNU C Library version 2.28 is now available

* The obsolete functions encrypt, encrypt_r, setkey, setkey_r, cbc_crypt,
  ecb_crypt, and des_setparity are no longer available to newly linked
  binaries, and the headers <rpc/des_crypt.h> and <rpc/rpc_des.h> are no
  longer installed.  These functions encrypted and decrypted data with the
  DES block cipher, which is no longer considered secure.  Software that
  still uses these functions should switch to a modern cryptography library,
  such as libgcrypt.

将下面的汇编放到使用setky、encrypt函数之前,这样ld会链接setkey@GLIBC_2.0和encrypt@GLIBC_2.0,再次编译即可。

#define __libcrypt_version_reference(symbol, version) \
  __asm__ (".symver " #symbol ", " #symbol "@" #version)

extern void setkey (const char *); 
extern void encrypt (const char *, int);
__libcrypt_version_reference (setkey, GLIBC_2.0);
__libcrypt_version_reference (encrypt, GLIBC_2.0);

② 提示socket相关的结构体重定义

/opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/netinet/in.h:211:8: note: originally defined here
 struct in6_addr
        ^~~~~~~~
In file included from /opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/linux/if_pppol2tp.h:20:0,
                 from /opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/linux/if_pppox.h:26,
                 from plugin.c:52:
/opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6'
 struct sockaddr_in6 {
        ^~~~~~~~~~~~
In file included from pppoe.h:47:0,
                 from plugin.c:29:
/opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/sys/socket.h:79:17: note: originally defined here
 typedef union { __SOCKADDR_ALLTYPES
                 ^
In file included from /opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/linux/if_pppol2tp.h:20:0,
                 from /opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/linux/if_pppox.h:26,
                 from plugin.c:52:
/opt/mips-gcc720-glibc229/mips-linux-gnu/libc/usr/include/linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq'
 struct ipv6_mreq {
        ^~~~~~~~~

修改pppd/plugins/rp-pppoe/pppoe.h头文件,将 <netinet/in.h> 替换为 <linux/in.h>

 

 再次重新编译即可。

编译pppd很简单,共两步:

① ./configure --prefix=$(pwd)/_install

② make CC=mips-linux-gnu-gcc -j8; make install

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值