Skip to content

Conversation

@TravisEz13
Copy link
Member

@TravisEz13 TravisEz13 commented Oct 11, 2017

This should fix #4975

# Can't use add_compile_options with 2.8.11
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fstack-protector-strong -fpie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fstack-protector-strong -fpie -DFORTIFY_SOURCE=2")
Copy link
Member

Choose a reason for hiding this comment

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

Based on the documentation, FORTIFY_SOURCE=2 isn't enabled unless you also use -O2 optimizations

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved.

@TravisEz13 TravisEz13 closed this Oct 11, 2017
@TravisEz13 TravisEz13 reopened this Oct 11, 2017
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fstack-protector-strong -fpie -DFORTIFY_SOURCE=2 -O2")

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro,-z,now")
Copy link
Member

Choose a reason for hiding this comment

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

Will CMAKE_SYSTEM_NAME ever be set to 'Windows'?
Can you please share some resources where I can find what each of those options is for?

Copy link
Member

Choose a reason for hiding this comment

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

This component isn't built for Windows. The Windows flags should go in ...\src\powershell-native\coreclr_defs.cmake.

Copy link
Member

Choose a reason for hiding this comment

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

This Windows section should be removed

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the windows case.

The docs are here:
https://cmake.org/cmake/help/v3.4/variable/CMAKE_HOST_SYSTEM_NAME.html#variable:CMAKE_HOST_SYSTEM_NAME
and
https://cmake.org/cmake/help/v3.4/variable/CMAKE_SYSTEM_NAME.html

BTW, we use this when compiling for ARM, set(CMAKE_SYSTEM_NAME Linux).

Copy link
Member

Choose a reason for hiding this comment

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

@TravisEz13 Thanks. I'm actually interested in the options like -Wl,-z,relro,-z,now, and would like to know what they mean. I quickly search them bug didn't find anything very useful.

It will be great if you can provide some pointers. And better, put the link in CMakeLists.txt as comments.

Copy link
Member

Choose a reason for hiding this comment

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

What about the other aspect of my comment? Are there corresponding flags that we can or should use with MSBuild when compiling pwrshplugin.dll?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have another work item to run the scan that would detect these type of issues. I just merged a change to the build to give me the data to run the scan. I should have it done Monday.

@mirichmo mirichmo self-assigned this Oct 12, 2017
@TravisEz13
Copy link
Member Author

@daxian-dbw Can you update your review?

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

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

It would be great if you add comments about some links that has information about the options used here, like -Wl,-z,relro,-z,now

@daxian-dbw daxian-dbw merged commit db6aec0 into PowerShell:master Oct 18, 2017
@TravisEz13 TravisEz13 deleted the strlenFixes branch October 18, 2017 17:12
@TravisEz13
Copy link
Member Author

I'll likely be making more changes. I'll include the detail where the tools give me them.

@TravisEz13 TravisEz13 mentioned this pull request Oct 25, 2017
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

Successfully merging this pull request may close these issues.

Remove use for strlen from native code

4 participants