Skip to content

Build position independent Linux binaries. #11272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
Arguments.push_back(context.Args.MakeArgString(A->getValue()));
}

if (getTriple().getOS() == llvm::Triple::Linux) {
Arguments.push_back("-pie");
}

std::string Target = getTargetForLinker();
if (!Target.empty()) {
Arguments.push_back("-target");
Expand Down
9 changes: 3 additions & 6 deletions utils/symbolicate-linux-fatal
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ def create_lldb_target(binary, memmap):
lldb_target = lldb_debugger.CreateTargetWithFileAndArch(
binary, lldb.LLDB_ARCH_DEFAULT)
module = lldb_target.GetModuleAtIndex(0)
# lldb seems to treat main binary differently, slide offset must be zero
lldb_target.SetModuleLoadAddress(module, 0)
for dynlib_path in memmap:
if binary not in dynlib_path:
module = lldb_target.AddModule(
dynlib_path, lldb.LLDB_ARCH_DEFAULT, None, None)
lldb_target.SetModuleLoadAddress(module, memmap[dynlib_path])
module = lldb_target.AddModule(
dynlib_path, lldb.LLDB_ARCH_DEFAULT, None, None)
lldb_target.SetModuleLoadAddress(module, memmap[dynlib_path])
return lldb_target


Expand Down