I'm working on some IIoT related packages in my COPR where I have a dynamic library linking to a static library and getting the following error:
[ 18%] Linking C shared library libneuron-base.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/neuron-base.dir/link.txt --verbose=1
/usr/bin/gcc -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -Wextra -g -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -Wextra -g -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope -fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/neuron-2.0.1/.package_note-emqx-neuron-2.0.1-1.fc37.x86_64.ld -shared -Wl,-soname,libneuron-base.so -o libneuron-base.so "CMakeFiles/neuron-base.dir/src/types.c.o" "CMakeFiles/neuron-base.dir/src/base/tag_table.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_tag.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_datatag_table.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_tag_group_config.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_plugin_common.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_data_expr.c.o" "CMakeFiles/neuron-base.dir/src/base/tag_class.c.o" "CMakeFiles/neuron-base.dir/src/connection/tcp_client.c.o" "CMakeFiles/neuron-base.dir/src/connection/tcp_server.c.o" "CMakeFiles/neuron-base.dir/src/connection/connection.c.o" "CMakeFiles/neuron-base.dir/src/connection/mqtt_client_intf.c.o" "CMakeFiles/neuron-base.dir/src/event/event_linux.c.o" "CMakeFiles/neuron-base.dir/src/event/event_unix.c.o" "CMakeFiles/neuron-base.dir/src/utils/atomic_data.c.o" "CMakeFiles/neuron-base.dir/src/utils/idhash.c.o" "CMakeFiles/neuron-base.dir/src/utils/hash_table.c.o" "CMakeFiles/neuron-base.dir/src/utils/panic.c.o" "CMakeFiles/neuron-base.dir/src/utils/log.c.o" "CMakeFiles/neuron-base.dir/src/utils/json.c.o" "CMakeFiles/neuron-base.dir/src/utils/neu_jwt.c.o" "CMakeFiles/neuron-base.dir/src/utils/file.c.o" "CMakeFiles/neuron-base.dir/src/utils/base64.c.o" "CMakeFiles/neuron-base.dir/src/config.c.o" "CMakeFiles/neuron-base.dir/src/connection/mqtt_c_client.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_error.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_fn.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_group_config.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_license.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_log.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_login.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_mqtt.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_node.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_plugin.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_rw.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_tag.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_tty.c.o" -L/usr/local/lib -Wl,-rpath,./:/usr/local/lib: -lzlog extern/vector/libvector-static.a extern/libcsptr/libcsptr.a -ljansson -lcrypto -lssl -lmqttc -lyaml -ljwt
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libmqttc.a(mqtt.c.o): warning: relocation against `mqtt_fixed_header_rules' in read-only section `.text'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libmqttc.a(mqtt.c.o): relocation R_X86_64_PC32 against symbol `mqtt_fixed_header_rules' can not be used when making a shared object; recompile with -fPIC
/usr/bin/cmake -E cmake_link_script CMakeFiles/neuron-base.dir/link.txt --verbose=1
/usr/bin/gcc -fPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -Wextra -g -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -Wextra -g -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope -fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/neuron-2.0.1/.package_note-emqx-neuron-2.0.1-1.fc37.x86_64.ld -shared -Wl,-soname,libneuron-base.so -o libneuron-base.so "CMakeFiles/neuron-base.dir/src/types.c.o" "CMakeFiles/neuron-base.dir/src/base/tag_table.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_tag.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_datatag_table.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_tag_group_config.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_plugin_common.c.o" "CMakeFiles/neuron-base.dir/src/base/neu_data_expr.c.o" "CMakeFiles/neuron-base.dir/src/base/tag_class.c.o" "CMakeFiles/neuron-base.dir/src/connection/tcp_client.c.o" "CMakeFiles/neuron-base.dir/src/connection/tcp_server.c.o" "CMakeFiles/neuron-base.dir/src/connection/connection.c.o" "CMakeFiles/neuron-base.dir/src/connection/mqtt_client_intf.c.o" "CMakeFiles/neuron-base.dir/src/event/event_linux.c.o" "CMakeFiles/neuron-base.dir/src/event/event_unix.c.o" "CMakeFiles/neuron-base.dir/src/utils/atomic_data.c.o" "CMakeFiles/neuron-base.dir/src/utils/idhash.c.o" "CMakeFiles/neuron-base.dir/src/utils/hash_table.c.o" "CMakeFiles/neuron-base.dir/src/utils/panic.c.o" "CMakeFiles/neuron-base.dir/src/utils/log.c.o" "CMakeFiles/neuron-base.dir/src/utils/json.c.o" "CMakeFiles/neuron-base.dir/src/utils/neu_jwt.c.o" "CMakeFiles/neuron-base.dir/src/utils/file.c.o" "CMakeFiles/neuron-base.dir/src/utils/base64.c.o" "CMakeFiles/neuron-base.dir/src/config.c.o" "CMakeFiles/neuron-base.dir/src/connection/mqtt_c_client.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_error.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_fn.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_group_config.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_license.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_log.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_login.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_mqtt.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_node.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_plugin.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_rw.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_tag.c.o" "CMakeFiles/neuron-base.dir/src/parser/neu_json_tty.c.o" -L/usr/local/lib -Wl,-rpath,./:/usr/local/lib: -lzlog extern/vector/libvector-static.a extern/libcsptr/libcsptr.a -ljansson -lcrypto -lssl -lmqttc -lyaml -ljwt
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libmqttc.a(mqtt.c.o): warning: relocation against `mqtt_fixed_header_rules' in read-only section `.text'
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libmqttc.a(mqtt.c.o): relocation R_X86_64_PC32 against symbol `mqtt_fixed_header_rules' can not be used when making a shared object; recompile with -fPIC
I added the following to the libmqttc library and verified -fPIC -pie is in the build flags[1] per the recommendation from the hardening page[2] but the error remains.
Any ideas?
Thanks,
Richard
_______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure