nimble-code / Cobra

An interactive (fast) static source code analyzer
136 stars 30 forks source link

Can't link Cobra - multiple sysmbol defintions of tokrange and t_id #28

Closed DHSimonson closed 2 years ago

DHSimonson commented 2 years ago

[root@perft src]# make install_linux cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_prim.o cobra_prim.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_prep.o cobra_prep.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_heap.o cobra_heap.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_lib.o cobra_lib.c yacc -o cobra_eval.c cobra_eval.y cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_eval.o cobra_eval.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_fcg.o cobra_fcg.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_lex.o cobra_lex.c yacc -d -p xx -o cobra_prog.c cobra_prog.y yacc: 8 shift/reduce conflicts. cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_prog.o cobra_prog.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_sym.o cobra_sym.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_cfg.o cobra_cfg.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_te.o cobra_te.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_links.o cobra_links.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_array.o cobra_array.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_list.o cobra_list.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -c -o cobra_json.o cobra_json.c cc -I. -Wall -O2 -pedantic -Werror -Wshadow -std=c99 -DYY_NO_INPUT -o cobra cobra_prim.o cobra_prep.o cobra_heap.o cobra_lib.o cobra_eval.o cobra_fcg.o cobra_lex.o cobra_prog.o cobra_sym.o cobra_cfg.o cobra_te.o cobra_links.o cobra_array.o cobra_list.o cobra_json.o -pthread ar -r c.ar cobra_lex.o cobra_prep.o cobra_prim.o cobra_heap.o cobra_links.o cobra_json.o ar: creating c.ar cp c.ar ../src_app cp ../doc/cobra.1 /usr/local/share/man/man1 cp ../doc/cwe.1 /usr/local/share/man/man1 cp ../doc/find_taint.1 /usr/local/share/man/man1 cp -f cobra ../bin_linux cp -f ../gui/ ../bin_linux cd ../src_app; make clean install_linux make[1]: Entering directory '/opt/ncode/Cobra/src_app' rm -f .exe *.o cwe abstract scope_check binop cfg deref fct_param_counts flatten float ident_check ident_length ifelseif igrep lf misra2004 nomacros nr_cases rule23_rule31 switch_default find_taint cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe.o cwe.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_util.o cwe_util.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_119.o cwe_119.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_120.o cwe_120.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_131.o cwe_131.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_134.o cwe_134.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_170.o cwe_170.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_197.o cwe_197.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_468.o cwe_468.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_805.o cwe_805.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_416.o cwe_416.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -c -o cwe_457.o cwe_457.c cc -Wall -pedantic -Werror -Wshadow -O2 -DYY_NO_INPUT -I. -std=c99 -o cwe cwe.o cwe_util.o cwe_119.o cwe_120.o cwe_131.o cwe_134.o cwe_170.o cwe_197.o cwe_468.o cwe_805.o cwe_416.o cwe_457.o c.ar -pthread /opt/rh/gcc-toolset-10/root/usr/bin/ld: c.ar(cobra_prep.o):(.bss+0x20): multiple definition of t_id'; cwe_util.o:(.bss+0x0): first defined here /opt/rh/gcc-toolset-10/root/usr/bin/ld: c.ar(cobra_prep.o):(.bss+0x0): multiple definition oftokrange'; cwe_util.o:(.bss+0x8): first defined here collect2: error: ld returned 1 exit status make[1]: [makefile:45: cwe] Error 1 make[1]: Leaving directory '/opt/ncode/Cobra/src_app' make: [makefile:64: install_linux] Error 2 [root@perft src]#

Compiler version: [root@perft src]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/rh/gcc-toolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/gcc-toolset-10/root/usr --mandir=/opt/rh/gcc-toolset-10/root/usr/share/man --infodir=/opt/rh/gcc-toolset-10/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-10.3.1-20210422/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.3.1 20210422 (Red Hat 10.3.1-1) (GCC) [root@perft src]#

OS Version [root@perft src]# cat /proc/version Linux version 4.18.0-348.7.1.el8_5.x86_64 (mockbuild@dal1-prod-builder001.bld.equ.rockylinux.org) (gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC)) #1 SMP Tue Dec 21 19:02:23 UTC 2021 [root@perft src]#

I changed the makefile to put the man pages in /use/local/share/man, but made no other changes to makefiles or source

Both issues look like look like clashes between src/cobra_prep.c and src_app/cwe_util.c and src_app/scope_check.c. I changed the definitions at the top of src_app/cwe_util.c to externs, as well as the tokrange definition in src_app/scope_check.c, and now everything links. Please let me know if there's something more I can do to help.

nimble-code commented 2 years ago

Interesting -- my version of gcc (9.3.0) doesn't catch this, but yes, it should be extern. I've fixed it and uploaded a new version of cwe_util.c Thanks for catching this!