Skip to content

PIE not enabled? #3213

Description

@iquiw

Summary

zls seems not a PIE even with -Dpie=true. I suppose exe.pie needs to be true.

Steps

  1. Build zls with pie option.
    $ zig build -Dpie=true
  2. Check the executable by file.
    $ file zig-out/bin/zls
    zig-out/bin/zls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped

There is no pie output after LSB.

Possible fix

With the following patch, zls seems to be a PIE.

--- a/build.zig
+++ b/build.zig
@@ -217,6 +217,7 @@ pub fn build(b: *Build) !void {
             .use_llvm = use_llvm,
             .use_lld = use_llvm,
         });
+        exe.pie = pie;
         b.installArtifact(exe);
     }
$ zig build -Dpie=true
$ file zig-out/bin/zls
zig-out/bin/zls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped

There is pie output after LSB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions