Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 安全编译选项
add_compile_options(-fstack-protector-strong -D_FORTITY_SOURCE=1)
add_link_options(-z noexecstack -pie -fPIC)
add_link_options(-z noexecstack -fPIC)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This compilation parameter is required for security purposes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the architecture for this parameter cannot be found, isolation is recommended.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-pie is specifically used for generating executables; since this is merely a shared library, there is no need to use this parameter.

Refer:https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html?hl=zh-CN

--pie

Produce a dynamically linked position independent executable on targets that support it. For predictable results, you must also specify the same set of options used for compilation (-fpie, -fPIE, or model suboptions) when you specify this linker option.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters for fpic do seem incorrect; it's recommended to remove this unnecessary parameter. pie is indeed necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# 设置安装路径
include(GNUInstallDirs)
Expand Down