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

Multiple labels bug #206

Closed
Qiu233 opened this issue Aug 2, 2018 · 2 comments
Closed

Multiple labels bug #206

Qiu233 opened this issue Aug 2, 2018 · 2 comments

Comments

@Qiu233
Copy link

Qiu233 commented Aug 2, 2018

I tried to compile code:
a:
jmp a
and then I got correct bytes with the jmp jumps to a.

But for this:
a:
b:
jmp a
I got bytes "E9 04 04 04 04"
why?
I think they are equalvalent.

I had more test and found that it occurs when more than one label is existed.
I mean every "jmp" will get "E9 04 04 04 04".

@kobalicek
Copy link
Member

Hello, can you share the code to reproduce the bug? When you see 04040404 it means the jump has not been relocated (the 04 just means that the relocation is 4 bytes long, you can also see 01 in short jumps).

@Qiu233
Copy link
Author

Qiu233 commented Aug 10, 2018

sorry for my late
Here's the code:

int main()
{

CodeInfo codeinfo(ArchInfo::kTypeX86, 0, 0);
CodeHolder code;
code.init(codeinfo);
X86Assembler a(&code);
AsmParser p(&a);
p.parse("a:\nb:\njmp a");
code.sync();

auto & buffer = code.getSectionEntry(0)->getBuffer();
auto v = buffer.getData();
size_t len = buffer.getLength();
cout << buffer.getLength() << endl;
for (size_t i = 0; i < len; i++)
{
	printf("%.2x\n", v[i]);
}
return 0;

}

Its output:
e9
04
04
04
04

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