Skip to content
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

Fix stack organization #268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions libreflect/src/stack_setup.c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you observing any strange behavior before making these changes? If so, what were you experiencing?
Could you provide a PoC of an unexpected result you had and how this fix is solving the problem?
This will really help us understand what is going on.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void load_program_info(size_t *auxv, ElfW(Ehdr) *exe, ElfW(Ehdr) *interp)
int ii;
size_t exe_loc = (size_t) exe, interp_loc = (size_t) interp;

for (ii = 0; auxv[ii]; ii += 2) {
for (ii = 0; auxv[ii] || auxv[ii + 1]; ii += 2) {
switch (auxv[ii]) {
case AT_BASE:
auxv[ii + 1] = interp_loc;
Expand Down Expand Up @@ -96,16 +96,16 @@ void stack_setup(size_t *stack_base, int argc, char **argv, char **env, size_t *
dprint(" 0x%08zx\n", stack_base[1 + ii]);

for (ii = 0; env[ii]; ii++) {
stack_base[1 + argc + ii] = (size_t)env[ii];
dprint(" 0x%08zx\n", stack_base[1 + argc + ii]);
stack_base[2 + argc + ii] = (size_t)env[ii];
dprint(" 0x%08zx\n", stack_base[2 + argc + ii]);
}
stack_base[1 + argc + ii] = 0;
dprint(" 0x%08zx\n", stack_base[1 + argc + ii]);
stack_base[3 + argc + ii] = 0;
dprint(" 0x%08zx\n", stack_base[3 + argc + ii]);

auxv_base = stack_base + 1 + argc + ii + 1;
auxv_base = stack_base + 1 + argc + ii + 3;

if(auxv) {
for (ii = 0; auxv[ii]; ii++) {
for (ii = 0; auxv[ii] || auxv[ii + 1]; ii++) {
auxv_base[ii] = auxv[ii];
}
auxv_base[ii] = AT_NULL;
Expand Down
Loading