Skip to content

Commit

Permalink
Fix flags in lfi-compile for x86
Browse files Browse the repository at this point in the history
  • Loading branch information
zyedidia committed Jun 12, 2024
1 parent a25ef12 commit 91c51a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion lfi-compile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,22 @@ func compile(cmdargs []string) {
return
}

flags = append(flags, "-Wl,--lto-emit-asm", "-Wl,-plugin-opt=--aarch64-enable-compress-jump-tables=false")
mllvmAArch64 := []string{
"-Wl,-plugin-opt=--aarch64-enable-compress-jump-tables=false",
}
mllvmAmd64 := []string{
"-Wl,-plugin-opt=--reserve-r14",
"-Wl,-plugin-opt=--reserve-r15",
"-Wl,-plugin-opt=--align-labels=16",
}

mllvm := mllvmAArch64
if runtime.GOARCH == "amd64" {
mllvm = mllvmAmd64
}

flags = append(flags, "-Wl,--lto-emit-asm")
flags = append(flags, mllvm...)
run(compiler, flags...)
inputs = []string{out}
out = oldout
Expand Down
2 changes: 1 addition & 1 deletion lfi-leg/lfi-amd64-baseline.leg
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ lfigen()
fprintf(output, ".p2align %d\n", log_bundle);
curbundle = size;
}
} else if (strncmp(op->text, ".p2align 4", strlen(".p2align 4")) == 0) {
} else if (strncmp(op->text, ".p2align", strlen(".p2align")) == 0) {
curbundle = 0;
}
fprintf(output, "%s", op->text);
Expand Down
2 changes: 1 addition & 1 deletion lfi-leg/lfi-amd64.leg
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ lfigen()
fprintf(output, ".p2align %d\n", log_bundle);
curbundle = size;
}
} else if (strncmp(op->text, ".p2align 4", strlen(".p2align 4")) == 0) {
} else if (strncmp(op->text, ".p2align", strlen(".p2align")) == 0) {
curbundle = 0;
}
// if (op->label) {
Expand Down

0 comments on commit 91c51a8

Please sign in to comment.