Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
09ea9dc7
Commit
09ea9dc7
authored
May 30, 2018
by
yonghong-song
Committed by
GitHub
May 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1784 from iovisor/yhs_dev
let rewriter add code to define CONFIG_CC_STACKPROTECTOR
parents
b50c7251
bace5f24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.cc
+21
-0
src/cc/frontends/clang/b_frontend_action.h
src/cc/frontends/clang/b_frontend_action.h
+1
-0
No files found.
src/cc/frontends/clang/b_frontend_action.cc
View file @
09ea9dc7
...
@@ -1057,7 +1057,28 @@ bool BFrontendAction::is_rewritable_ext_func(FunctionDecl *D) {
...
@@ -1057,7 +1057,28 @@ bool BFrontendAction::is_rewritable_ext_func(FunctionDecl *D) {
(
file_name
.
empty
()
||
file_name
==
main_path_
));
(
file_name
.
empty
()
||
file_name
==
main_path_
));
}
}
void
BFrontendAction
::
DoMiscWorkAround
()
{
// In 4.16 and later, CONFIG_CC_STACKPROTECTOR is moved out of Kconfig and into
// Makefile. It will be set depending on CONFIG_CC_STACKPROTECTOR_{AUTO|REGULAR|STRONG}.
// CONFIG_CC_STACKPROTECTOR is still used in various places, e.g., struct task_struct,
// to guard certain fields. The workaround here intends to define
// CONFIG_CC_STACKPROTECTOR properly based on other configs, so it relieved any bpf
// program (using task_struct, etc.) of patching the below code.
rewriter_
->
getEditBuffer
(
rewriter_
->
getSourceMgr
().
getMainFileID
()).
InsertText
(
0
,
"#if !defined(CONFIG_CC_STACKPROTECTOR)
\n
"
"#if defined(CONFIG_CC_STACKPROTECTOR_AUTO)
\\\n
"
" || defined(CONFIG_CC_STACKPROTECTOR_REGULAR)
\\\n
"
" || defined(CONFIG_CC_STACKPROTECTOR_STRONG)
\n
"
"#define CONFIG_CC_STACKPROTECTOR
\n
"
"#endif
\n
"
"#endif
\n
"
,
false
);
}
void
BFrontendAction
::
EndSourceFileAction
()
{
void
BFrontendAction
::
EndSourceFileAction
()
{
// Additional misc rewrites
DoMiscWorkAround
();
if
(
flags_
&
DEBUG_PREPROCESSOR
)
if
(
flags_
&
DEBUG_PREPROCESSOR
)
rewriter_
->
getEditBuffer
(
rewriter_
->
getSourceMgr
().
getMainFileID
()).
write
(
llvm
::
errs
());
rewriter_
->
getEditBuffer
(
rewriter_
->
getSourceMgr
().
getMainFileID
()).
write
(
llvm
::
errs
());
if
(
flags_
&
DEBUG_SOURCE
)
{
if
(
flags_
&
DEBUG_SOURCE
)
{
...
...
src/cc/frontends/clang/b_frontend_action.h
View file @
09ea9dc7
...
@@ -150,6 +150,7 @@ class BFrontendAction : public clang::ASTFrontendAction {
...
@@ -150,6 +150,7 @@ class BFrontendAction : public clang::ASTFrontendAction {
TableStorage
&
table_storage
()
const
{
return
ts_
;
}
TableStorage
&
table_storage
()
const
{
return
ts_
;
}
std
::
string
id
()
const
{
return
id_
;
}
std
::
string
id
()
const
{
return
id_
;
}
bool
is_rewritable_ext_func
(
clang
::
FunctionDecl
*
D
);
bool
is_rewritable_ext_func
(
clang
::
FunctionDecl
*
D
);
void
DoMiscWorkAround
();
private:
private:
llvm
::
raw_ostream
&
os_
;
llvm
::
raw_ostream
&
os_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment