Skip to content

Commit d495e1c

Browse files
authored
Merge pull request #11272 from gmilos/sr-5405-position-independent-executables-on-linux
Build position independent Linux binaries.
2 parents 4ff0707 + e5cc00b commit d495e1c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
15581558
Arguments.push_back(context.Args.MakeArgString(A->getValue()));
15591559
}
15601560

1561+
if (getTriple().getOS() == llvm::Triple::Linux) {
1562+
Arguments.push_back("-pie");
1563+
}
1564+
15611565
std::string Target = getTargetForLinker();
15621566
if (!Target.empty()) {
15631567
Arguments.push_back("-target");

utils/symbolicate-linux-fatal

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,10 @@ def create_lldb_target(binary, memmap):
5858
lldb_target = lldb_debugger.CreateTargetWithFileAndArch(
5959
binary, lldb.LLDB_ARCH_DEFAULT)
6060
module = lldb_target.GetModuleAtIndex(0)
61-
# lldb seems to treat main binary differently, slide offset must be zero
62-
lldb_target.SetModuleLoadAddress(module, 0)
6361
for dynlib_path in memmap:
64-
if binary not in dynlib_path:
65-
module = lldb_target.AddModule(
66-
dynlib_path, lldb.LLDB_ARCH_DEFAULT, None, None)
67-
lldb_target.SetModuleLoadAddress(module, memmap[dynlib_path])
62+
module = lldb_target.AddModule(
63+
dynlib_path, lldb.LLDB_ARCH_DEFAULT, None, None)
64+
lldb_target.SetModuleLoadAddress(module, memmap[dynlib_path])
6865
return lldb_target
6966

7067

0 commit comments

Comments
 (0)