Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Page offset alignment #1

wants to merge 2 commits into from

2 participants


If the trampoline implementation isn't aligned to 16 bytes, things start to crash.


Admittedly I haven't swapped in my full memory of the subject, but IIRC my intention was to do this individually in the trampoline prefixes themselves:



To quote Robert Picardo, that may have been your intention, but it certainly wasn't the result. Or at least, it doesn't look like it was. All I know is that aligning the page offset stopped me from crashing hard on x86_64 any time a trampoline was called. Xcode 5.0.2, Mavericks SDK, both -O0 and -O2 same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +8 −4 Other Sources/
12 Other Sources/
@@ -177,8 +177,11 @@ main () {
local prefix_size=$(compute_asm_size)
+ # Align the prefix size to 16 bytes
+ local aligned_prefix_size=`perl -e "print ((${prefix_size} + 15) & ~15)"`
# Compute the size of the remaining code page.
- local page_avail=`expr $PAGE_SIZE - $prefix_size`
+ local page_avail=`expr $PAGE_SIZE - $aligned_prefix_size`
# Determine the trampoline size
@@ -191,7 +194,7 @@ main () {
# Compute the number of of available trampolines.
local trampoline_count=`expr $page_avail / $tramp_size`
- echo "Prefix size: ${prefix_size}"
+ echo "Prefix size: ${prefix_size} (${aligned_prefix_size})"
echo "Trampoline size: ${tramp_size}"
echo "Trampolines per page: ${trampoline_count}"
@@ -218,9 +221,10 @@ main () {
#include <PLBlockIMP/trampoline_table.h>
extern void *${PAGE_NAME};
+ extern pl_trampoline_table_config ${PAGE_NAME}_config;
pl_trampoline_table_config ${PAGE_NAME}_config = {
.trampoline_size = ${tramp_size},
- .page_offset = ${prefix_size},
+ .page_offset = ${aligned_prefix_size},
.trampoline_count = ${trampoline_count},
.template_page = &${PAGE_NAME}
@@ -228,4 +232,4 @@ EOF`
src "${config_src}"
Something went wrong with that request. Please try again.