Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error linking: In peer_lists.h: "multiple definition of peers'" and "multiple definition of blacklists'". #119

Open
dreirund opened this issue Sep 1, 2021 · 6 comments

Comments

@dreirund
Copy link

dreirund commented Sep 1, 2021

There are errors while linking, initially reported in the Arch Linux AUR package page:

[...]
[100%] Linking C executable meshd-nl80211
cd /tmp/authsae-git/src/authsae/linux && /usr/bin/cmake -E cmake_link_script CMakeFiles/meshd-nl80211.dir/link.txt --verbose=1
/usr/bin/cc -g0 -march=x86-64 -mtune=native -O3 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fomit-frame-pointer -fPIC -Wall  -O3 -DNDEBUG -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -rdynamic CMakeFiles/meshd-nl80211.dir/meshd-nl80211.c.o CMakeFiles/meshd-nl80211.dir/nl.c.o CMakeFiles/meshd-nl80211.dir/watch_ips.c.o CMakeFiles/meshd-nl80211.dir/service.c.o -o meshd-nl80211   -L/tmp/authsae-git/src/authsae  -Wl,-rpath,/tmp/authsae-git/src/authsae: -lconfig -lcrypto -lnl-3 -lnl-genl-3 -lnl-3 -lpthread ../libsae.a -lrt -lnl-genl-3 -lpthread -lrt -lconfig -lcrypto 
/usr/bin/ld: ../libsae.a(sae.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:9: multiple definition of `peers'; ../libsae.a(ampe.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:9: first defined here
/usr/bin/ld: ../libsae.a(sae.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:8: multiple definition of `blacklist'; ../libsae.a(ampe.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:8: first defined here
/usr/bin/ld: ../libsae.a(peers.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:9: multiple definition of `peers'; ../libsae.a(ampe.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:9: first defined here
/usr/bin/ld: ../libsae.a(peers.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:8: multiple definition of `blacklist'; ../libsae.a(ampe.c.o):/tmp/authsae-git/src/authsae/peer_lists.h:8: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [linux/CMakeFiles/meshd-nl80211.dir/build.make:151: linux/meshd-nl80211] Error 1
make[2]: Leaving directory '/tmp/authsae-git/src/authsae'
make[1]: *** [CMakeFiles/Makefile2:131: linux/CMakeFiles/meshd-nl80211.dir/all] Error 2
make[1]: Leaving directory '/tmp/authsae-git/src/authsae'
make: *** [Makefile:139: all] Error 2

Build is carried out with

sed -e 's|\-Werror||' -i CMakeLists.txt
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_LINUX_TARGETS=ON .
sed -i 's|/usr/etc/|/etc|' cmake_install.cmake
make

The removal of -Werror is needed, otherwise it would already bail out earlier with

[...]
[ 27%] Building C object linux/CMakeFiles/mon.dir/__/common.c.o
cd /tmp/authsae-git/src/authsae/linux && /usr/bin/cc  -I/tmp/authsae-git/src/authsae -I/usr/include/libnl3 -g0 -march=x86-64 -mtune=native -O3 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fomit-frame-pointer -fPIC -Wall -Werror -O3 -DNDEBUG   -g -MD -MT linux/CMakeFiles/mon.dir/__/common.c.o -MF CMakeFiles/mon.dir/__/common.c.o.d -o CMakeFiles/mon.dir/__/common.c.o -c /tmp/authsae-git/src/authsae/common.c
In file included from /usr/include/string.h:519,
                 from /tmp/authsae-git/src/authsae/linux/mon.c:45:
In function ‘strncpy’,
    inlined from ‘add_interface’ at /tmp/authsae-git/src/authsae/linux/mon.c:172:3,
    inlined from ‘add_interface’ at /tmp/authsae-git/src/authsae/linux/mon.c:157:13:
/usr/include/bits/string_fortified.h:95:10: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/authsae-git/src/authsae/linux/mon.c: In function ‘add_interface’:
/tmp/authsae-git/src/authsae/linux/mon.c:172:3: note: length computed here
  172 |   strncpy(inf->ifname, ptr, strlen(ptr));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [linux/CMakeFiles/mon.dir/build.make:79: linux/CMakeFiles/mon.dir/mon.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[...]
@elockman
Copy link

@dreirund did you ever resolve this issue?

I found that this error is not present with gcc v9.4, but is introduced in gcc v10 and v11.
TAILQ_HEAD() in the peer_lists.h header file creates a peers and blacklist variable in peers.c.o, ampe.c.o, and sae.c.o, so the linker complains.

@dreirund
Copy link
Author

@dreirund did you ever resolve this issue?

No, and I also know almost nothing about linkin, gcc, C/C++-code and related stuff, so I can only report but not bugfix.

@dreirund
Copy link
Author

I found that this error is not present with gcc v9.4, but is introduced in gcc v10 and v11

With gcc 9.5.0 I get the following error:

[...]
[  5%] Building C object CMakeFiles/sae.dir/sae.c.o
/usr/bin/gcc-9  -I/tmp/makepkg/build/authsae-git/src/authsae -g0 -march=x86-64 -mtune=native -O3 -flto -ffat-lto-objects -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fomit-frame-pointer -fPIC -Wall    -g -MD -MT CMakeFiles/sae.dir/sae.c.o -MF CMakeFiles/sae.dir/sae.c.o.d -o CMakeFiles/sae.dir/sae.c.o -c /tmp/makepkg/build/authsae-git/src/authsae/sae.c
/tmp/makepkg/build/authsae-git/src/authsae/sae.c:81:18: error: static declaration of ‘HMAC_CTX_new’ follows non-static declaration
   81 | static HMAC_CTX *HMAC_CTX_new(void) {
      |                  ^~~~~~~~~~~~
In file included from /tmp/makepkg/build/authsae-git/src/authsae/sae.c:42:
/usr/include/openssl/hmac.h:33:33: note: previous declaration of ‘HMAC_CTX_new’ was here
   33 | OSSL_DEPRECATEDIN_3_0 HMAC_CTX *HMAC_CTX_new(void);
      |                                 ^~~~~~~~~~~~
/tmp/makepkg/build/authsae-git/src/authsae/sae.c: In function ‘HMAC_CTX_new’:
/tmp/makepkg/build/authsae-git/src/authsae/sae.c:82:36: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX’ {aka ‘struct hmac_ctx_st’}
   82 |   return (HMAC_CTX *)calloc(sizeof(HMAC_CTX), 1);
      |                                    ^~~~~~~~
/tmp/makepkg/build/authsae-git/src/authsae/sae.c: At top level:
/tmp/makepkg/build/authsae-git/src/authsae/sae.c:85:13: error: static declaration of ‘HMAC_CTX_free’ follows non-static declaration
   85 | static void HMAC_CTX_free(HMAC_CTX *ctx) {
      |             ^~~~~~~~~~~~~
In file included from /tmp/makepkg/build/authsae-git/src/authsae/sae.c:42:
/usr/include/openssl/hmac.h:35:28: note: previous declaration of ‘HMAC_CTX_free’ was here
   35 | OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_free(HMAC_CTX *ctx);
      |                            ^~~~~~~~~~~~~
/tmp/makepkg/build/authsae-git/src/authsae/sae.c: In function ‘HMAC_CTX_free’:
/tmp/makepkg/build/authsae-git/src/authsae/sae.c:87:5: warning: implicit declaration of function ‘HMAC_CTX_cleanup’; did you mean ‘HMAC_CTX_free’? [-Wimplicit-function-declaration]
   87 |     HMAC_CTX_cleanup(ctx);
      |     ^~~~~~~~~~~~~~~~
      |     HMAC_CTX_free
/tmp/makepkg/build/authsae-git/src/authsae/sae.c: In function ‘prf’:
/tmp/makepkg/build/authsae-git/src/authsae/sae.c:171:5: warning: ‘HMAC_Init_ex’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
  171 |     HMAC_Init_ex(ctx, key, keylen, EVP_sha256(), NULL);
      |     ^~~~~~~~~~~~
[...]
make[2]: *** [CMakeFiles/sae.dir/build.make:177: CMakeFiles/sae.dir/sae.c.o] Error 1
make[2]: Leaving directory '/tmp/makepkg/build/authsae-git/src/authsae'
make[1]: *** [CMakeFiles/Makefile2:106: CMakeFiles/sae.dir/all] Error 2
make[1]: Leaving directory '/tmp/makepkg/build/authsae-git/src/authsae'
make: *** [Makefile:139: all] Error 2

And lot more warnings.

I get the samee error with 12.2.1 now. So some newer libraries (OpenSSL 3.x) might have broken other things, too?

Full make -j1 output: make.log (second run).

@dreirund
Copy link
Author

dreirund commented Mar 30, 2023

OK, with openssl-1.1 and gcc9 it builds (with warnings) :-). ↗ AUR package is updated. But the issue I leave open because it needs fixes in the code.

@elockman
Copy link

@dreirund you can try my fork if you'd like here.
I'd like to hear feedback if you have any issues pop up.

@dreirund
Copy link
Author

dreirund commented Apr 1, 2023

@dreirund you can try my fork if you'd like here. I'd like to hear feedback if you have any issues pop up.

It compiles and links for me with OpenSSL 3.0.8 and gcc 12.2.1. Thanks!

However, I cannot find anymore the official version number. In https://github.com/cozybit/authsae/, it could be retrieved via git describe --tags. In https://github.com/elockman/authsae, the above command does not retrieve anything, and I also could not find it within the source files (doing simple grep searches vor 1.3 and version and VERSION). Would be helpful to have the official version number carried on.

Also, writing in the README.md what your changes are about with respect to the original can be helpful for people who stumble upon different authsae-repositories.

Regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants