Skip to content

Build with ASLR/DEP support by default - #349

Closed
emberian wants to merge 3 commits into
glfw:masterfrom
emberian:issue/199
Closed

emberian wants to merge 3 commits into
glfw:masterfrom
emberian:issue/199

Conversation

@emberian

@emberian emberian commented Sep 6, 2014

Copy link
Copy Markdown

Can be disabled with GLFW_FORCE_NOFPIC=YES. This can be important on 32-bit
systems, where position independant code is more expensive. On 64-bit systems,
there is no meaningful performance impact.

Closes #199

Can be disabled with GLFW_FORCE_NOFPIC=YES. This can be important on 32-bit
systems, where position independant code is more expensive. On 64-bit systems,
there is no meaningful performance impact.

Closes #199
@emberian

emberian commented Sep 6, 2014

Copy link
Copy Markdown
Author

Note that this doesn't do anything for msvc/mingw. Not sure how to handle those systems. @thestinger?

@thestinger

Copy link
Copy Markdown

Windows doesn't have position independent code, it has to rewrite code via a relocation table in order to move it to another location. Windows executables and DLLs should be built with --dynamicbase (ASLR compatible), --nxcompat (DEP compatible) and with the next binutils --high-entropy-va (64-bit ASLR compatible). Static libraries don't need to do anything. If one DLL isn't marked properly, you lose those exploit mitigations.

@emberian emberian changed the title Build with -fPIC by default Build with ASLR/DEP support by default Sep 6, 2014
@elmindreda elmindreda self-assigned this Sep 6, 2014
@brendanzab

Copy link
Copy Markdown

This is great! Thanks!

@elmindreda elmindreda added this to the 3.1 milestone Sep 11, 2014
@elmindreda

Copy link
Copy Markdown
Member

@thestinger Are those MinGW flags necessary for Rust?

@thestinger

Copy link
Copy Markdown

Rust will work fine without the NXCOMPAT, DYNAMICBASE and HIGHENTROPYVA flags. The flags indicate that a library / executable is compatible with the feature and an executable using any library not marked compatible loses the exploit mitigations. Visual Studio flips those flags on by default but MinGW/MinGW-w64 use bad defaults which makes it the problem of every single application / library. There's no drawback to setting them so there's no need for a way to disable it since if the executable and every other library isn't marked compatible it will have no impact.

@elmindreda

Copy link
Copy Markdown
Member

@thestinger You accidentally a word.

@elmindreda elmindreda closed this in fb90d5b Oct 7, 2014
Scorpiour pushed a commit to Scorpiour/glfw that referenced this pull request May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature suggestions and PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add -fPIC to CMakeLists.txt

4 participants