File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/OpenTelemetry.AutoInstrumentation.Native Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -130,8 +130,16 @@ if (ISMACOS)
130130 add_compile_options (-fstack-check)
131131elseif (ISLINUX)
132132 add_compile_options (-stdlib=libstdc++ -DLINUX -Wno-pragmas)
133- # Enable additional hardening on Linux
134- add_compile_options (-D_FORTIFY_SOURCE=2)
133+ # Enable additional hardening on modern versions of Linux
134+ # Require glibc 2.27+ for _FORTIFY_SOURCE=2
135+ execute_process (COMMAND ldd --version OUTPUT_VARIABLE LDD_VERSION)
136+ if (LDD_VERSION MATCHES "([0-9]+)\\ .([0-9]+)" )
137+ set (GLIBC_MAJOR ${CMAKE_MATCH_1} )
138+ set (GLIBC_MINOR ${CMAKE_MATCH_2} )
139+ if ((GLIBC_MAJOR EQUAL 2 AND GLIBC_MINOR GREATER 26) OR GLIBC_MAJOR GREATER 2)
140+ add_compile_options (-D_FORTIFY_SOURCE=2)
141+ endif ()
142+ endif ()
135143 if (ISAMD64 AND HAS_FCF_PROTECTION)
136144 # CET (Control-flow Enforcement Technology) for x86_64
137145 add_compile_options (-fcf-protection=full)
You can’t perform that action at this time.
0 commit comments