Skip to content

Commit

Permalink
Merge pull request #32 from parca-dev/update-binary
Browse files Browse the repository at this point in the history
Fix Segfault and Update toy JIT binary for x86
  • Loading branch information
kakkoyun authored Feb 28, 2024
2 parents a92cebd + 4fa90bf commit 39b3c04
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ func (Build) Go() error {
errs = errors.Join(errs, err)
}
}
for _, vr := range cppBuildVariantsArm64 {
if err := buildCpp(host, vr.src, vr.name, vr.flags...); err != nil {
errs = errors.Join(errs, err)
}
}
for _, vr := range cppBuildVariantsX86 {
if err := buildCpp(host, vr.src, vr.name, vr.flags...); err != nil {
errs = errors.Join(errs, err)
}
}

return errs
}
Expand Down Expand Up @@ -315,6 +325,16 @@ func (Build) Cpp() error {
errs = errors.Join(errs, err)
}
}
for _, vr := range cppBuildVariantsArm64 {
if err := buildCpp(host, vr.src, vr.name, vr.flags...); err != nil {
errs = errors.Join(errs, err)
}
}
for _, vr := range cppBuildVariantsX86 {
if err := buildCpp(host, vr.src, vr.name, vr.flags...); err != nil {
errs = errors.Join(errs, err)
}
}

return errs
}
Expand Down
Binary file modified out/amd64/basic-cpp-jit
Binary file not shown.
Binary file modified out/amd64/basic-cpp-jit-no-fp
Binary file not shown.
3 changes: 2 additions & 1 deletion src/basic-cpp-jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ int main() {
unsigned long long jit2_last_addr = (unsigned long long)mem;

// We are done writing code, let's not make it writable anymore.
mprotect(mem_start, jit_size, PROT_EXEC);
// Note: The 'PROT_READ' is necessary when compiling with Zig, else it segfaults.
mprotect(mem_start, jit_size, PROT_READ | PROT_EXEC);

// Write perfmap so perf can symbolize the jitted functions.
//
Expand Down

0 comments on commit 39b3c04

Please sign in to comment.