forked from facebook/buck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C/C++: add a static PIC link style for binaries
Summary: This adds a new static PIC link style for C/C++ binaries which compile all linked objects with PIC. This can be used as a base to generate PIEs (https://securityblog.redhat.com/2012/11/28/position-independent-executables-pie/) or standalone statically linked shared libs. Test Plan: added unittests
- Loading branch information
Showing
14 changed files
with
222 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/com/facebook/buck/cxx/testdata/static_pic_link_style/BUCK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cxx_library( | ||
name = 'foo', | ||
headers = [ | ||
'foo.h', | ||
], | ||
srcs = [ | ||
'foo.cpp', | ||
], | ||
) | ||
|
||
cxx_binary( | ||
name = 'bar', | ||
link_style = 'static_pic', | ||
srcs = [ | ||
'bar.cpp', | ||
], | ||
deps = [ | ||
':foo', | ||
], | ||
) |
9 changes: 9 additions & 0 deletions
9
test/com/facebook/buck/cxx/testdata/static_pic_link_style/bar.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <iostream> | ||
|
||
#include "foo.h" | ||
|
||
int main() { | ||
std::cout << foo << std::endl; | ||
std::cout << foo() << std::endl; | ||
return 0; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/com/facebook/buck/cxx/testdata/static_pic_link_style/foo.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int foo() { | ||
return 5; | ||
} |
Oops, something went wrong.