File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 699699 'cflags' : [ '-fPIC' ],
700700 'ldflags' : [ '-fPIC' ],
701701 }],
702+ # Link executables as PIE so that ASLR randomizes the executable
703+ # image too. Every object in a PIE must be built with `-fPIC` or
704+ # `-fPIE`. PIE flags should not apply to shared library objects,
705+ # like addons. `--fully-static` uses `-static-pie`, see configure.py.
706+ [ 'OS=="linux" and configuring_node' , {
707+ 'target_conditions' : [
708+ ['_type=="executable"' , {
709+ 'ldflags' : [ '-pie' ],
710+ }],
711+ ],
712+ 'conditions' : [
713+ # Use `-fPIE` unless the condition above uses `-fPIC`.
714+ [ 'node_shared!="true" and node_enable_v8debughelper!="true"' , {
715+ 'cflags' : [ '-fPIE' ],
716+ }],
717+ ],
718+ }],
702719 ],
703720 }],
704721 [ 'OS in "aix os400"' , {
Original file line number Diff line number Diff line change @@ -2538,7 +2538,12 @@ def configure_static(o):
25382538 return
25392539
25402540 if options .fully_static :
2541- o ['libraries' ] += ['-static' ]
2541+ if flavor == 'linux' :
2542+ # `-static` drops the `-pie` from common.gypi, e.g. clang:
2543+ # https://github.com/llvm/llvm-project/blob/68b03cf380e61c86aa59f94a10e8ce2d4c10cbb0/clang/lib/Driver/ToolChains/Gnu.cpp#L351-L366
2544+ o ['libraries' ] += ['-static-pie' ]
2545+ else :
2546+ o ['libraries' ] += ['-static' ]
25422547 elif options .partly_static :
25432548 o ['libraries' ] += ['-static-libgcc' , '-static-libstdc++' ]
25442549 if options .enable_asan :
You can’t perform that action at this time.
0 commit comments