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 heap test binaries build #1087

Merged
merged 2 commits into from Aug 23, 2022
Merged

Fix heap test binaries build #1087

merged 2 commits into from Aug 23, 2022

Conversation

disconnect3d
Copy link
Member

It turns out we never build the heap test binaries with their expected build flags. Instead, we always build and used the binaries build by wildcard rules in makefile: %.out: %.c

Ugh... and now I think some tests on CI will fail because we may not be able to load the binaries or have their dependencies? Let's see.

@disconnect3d
Copy link
Member Author

Yeah..:

$ gdb /home/dc/pwndbg/tests/binaries/heap_bugs.out
pwndbg: loaded 200 commands. Type pwndbg [filter] for a list.
pwndbg: created $rebase, $ida gdb functions (can be used with print/break)
Reading symbols from /home/dc/pwndbg/tests/binaries/heap_bugs.out...
------- tip of the day (disable with set show-tips off) -------
Use the canary command to see all stack canary/cookie values on the stack (based on the *usual* stack canary value initialized by glibc)
pwndbg> r
Starting program: /home/dc/pwndbg/tests/binaries/heap_bugs.out 
/bin/bash: line 1: /home/dc/pwndbg/tests/binaries/heap_bugs.out: No such file or directory
During startup program exited with code 127.
pwndbg> 

@disconnect3d
Copy link
Member Author

And here's my local reason why it crashes:

user@user:~/pwndbg/tests/binaries$ /home/user/pwndbg/tests/binaries/heap_bins.out
/home/user/pwndbg/tests/binaries/heap_bins.out: /home/user/pwndbg/tests/binaries/glibcs/2.33/libc.so.6: version `GLIBC_2.34' not found (required by /home/user/pwndbg/tests/binaries/heap_bins.out)

Apparently gcc/clang sucks? I mean, u can't force libc symbol version during compilation.

Or.. at least I have tried. I have also tried patchelf with clear symbol versions etc. as suggested in https://stackoverflow.com/questions/2856438/how-can-i-link-to-a-specific-glibc-version

But it still does not work fully as some other symbols (in other sections) are left there with the newer (2.34) glibc version.

So what can we do? Apparently if we compile with ZIG's programming language compiler, it works? O_o

I mean, sth like this: zig cc <rpath flags> <dynamic interp flag> -target native-native-gnu.2.33 -lc test.c. Adding this in next commit.

@disconnect3d disconnect3d force-pushed the fix-heap-test-binaries-build branch 2 times, most recently from f703436 to eb84ef2 Compare August 23, 2022 01:43
@disconnect3d disconnect3d merged commit d111c8d into dev Aug 23, 2022
@disconnect3d disconnect3d deleted the fix-heap-test-binaries-build branch August 23, 2022 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant