Skip to content

3.0 double word stack align #551

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
merged 2 commits into from
Jan 25, 2018
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
2 changes: 1 addition & 1 deletion extmod/modure.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
}

mp_obj_t retval = mp_obj_new_list(0, NULL);
const char* caps[caps_num];
const char **caps = alloca(caps_num * sizeof(char*));
while (true) {
// cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char
memset((char**)caps, 0, caps_num * sizeof(char*));
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/samd21x18-bootloader-crystalless.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/samd21x18-bootloader.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/samd51x19-bootloader.ld
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/samd51x20-bootloader.ld
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MEMORY
}

/* top end of the stack */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 4;
/* stack must be double-word (8 byte) aligned */
_estack = ORIGIN(RAM) + LENGTH(RAM) - 8;
_bootloader_dbl_tap = _estack;

/* define output sections */
Expand Down
5 changes: 2 additions & 3 deletions py/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,10 +1428,9 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) {
mp_load_method_maybe(module, MP_QSTR___name__, dest);
size_t pkg_name_len;
const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len);

const uint dot_name_len = pkg_name_len + 1 + qstr_len(name);
// Previously dot_name was created using alloca(), but that caused run-time crashes on M4 due to
// stack corruption (compiler bug, it appears), so use an array instead.
char dot_name[dot_name_len];
char *dot_name = alloca(dot_name_len);
memcpy(dot_name, pkg_name, pkg_name_len);
dot_name[pkg_name_len] = '.';
memcpy(dot_name + pkg_name_len + 1, qstr_str(name), qstr_len(name));
Expand Down