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

struct.error: unpack requires a buffer of 8 bytes in extract ground truth extractBB.py #20

Open
NobinPegasus opened this issue Nov 11, 2022 · 5 comments

Comments

@NobinPegasus
Copy link

NobinPegasus commented Nov 11, 2022

When using the extract ground truth: python3 ../../extract_gt/extractBB.py -b test_switch -m test_switch.gt -o /tmp/gtBlock_test_switch.pb
It gives the following error. How to fix it?

INFO:Found Gaps#0 in section .text, between 0x400530 - 0x4005d0, size: 160
INFO:Found Gaps#1 in section .text, between 0x400770 - 0x4007e2
INFO:Find the gap(0x400530 - 0x4005d0) behind basic block 0x400500, size is 48, padding is 5
INFO:Find the gap(0x400770 - 0x4007e2) behind basic block 0x40075d, size is 19, padding is 10
INFO:fi1: 0x400671, entry number is 14, its parent is 0x400669
INFO:Jump table base is 0x0
INFO:The begin Addr is 0x400671
INFO:Now instruction is from 0x400669 to 0x4
INFO:Now instruction is from 0x40066d to 0x8
INFO:Now instruction is from 0x400675 to 0x2
INFO:[indirect instruction] 0x400675: jmp rcx
ERROR:Table base 0x0 not in fixups, please check!
INFO:entry size is 0x8
Traceback (most recent call last):
File "/gt_x86/x86-sok/extract_gt/extractBB.py", line 1976, in
dumpGroundTruth(essInfo, module, outFile, options.binary, options.split)
File "/gt_x86/x86-sok/extract_gt/extractBB.py", line 1216, in dumpGroundTruth
jumpTable = scanJumpTable(essInfo, binary)
File "/gt_x86/x86-sok/extract_gt/extractBB.py", line 1129, in scanJumpTable
successors = readTableEntries(table_base, fi.numJTEntries, tbl_size, binary, entry_added_base)
File "/gt_x86/x86-sok/extract_gt/extractBB.py", line 991, in readTableEntries
entryContent = struct.unpack(unpackStr, entry)
struct.error: unpack requires a buffer of 8 bytes

I was using the test_switch file.
I am using the docker image provided in the repo hompage

@bin2415
Copy link
Collaborator

bin2415 commented Nov 12, 2022

Hello, I can't reproduce your problem. Could you help to share the test_switch binary?

@NobinPegasus
Copy link
Author

Github don't allow to share binary file.
How can I share that?

@NobinPegasus
Copy link
Author

@bin2415
Copy link
Collaborator

bin2415 commented Nov 12, 2022

The size of the jump table is not correct. Could you please list the steps of building the binary?

@NobinPegasus
Copy link
Author

I just used the way you mentioned in the exampled guide.

Below are the given command I ran to build the binary and get the error

root@5e8606df7f20:/gt_x86/test# source ../gcc64.rc

root@5e8606df7f20:/gt_x86/test# export CFLAGS="-O0 $CFLAGS"

root@5e8606df7f20:/gt_x86/test# $CC $CFLAGS -o test_switch test_switch.c

root@5e8606df7f20:/gt_x86/test#  objcopy --dump-section .rand=test_switch.gt.gz test_switch && gzip -d test_switch.gt.gz

root@5e8606df7f20:/gt_x86/test# python3 ../../extract_gt/extractBB.py -b test_switch -m test_switch.gt -o /tmp/gtBlock_test_switch.pb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants