Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
04f2cf7e
Commit
04f2cf7e
authored
Feb 07, 2016
by
Matthias Braun
Browse files
ia32: Simplify bemit_relocation_callback()
parent
233382ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/be/ia32/ia32_encode.c
View file @
04f2cf7e
...
...
@@ -1414,22 +1414,23 @@ static unsigned enc_relocation_callback(char *const buffer,
ir_entity
*
const
entity
,
int32_t
const
offset
)
{
if
(
be_kind
==
IA32_RELOCATION_RELJUMP
)
{
int32_t
*
dest
=
(
int32_t
*
)
buffer
;
*
dest
=
offset
;
return
4
;
uint32_t
value
;
if
(
entity
==
NULL
)
{
assert
(
be_kind
==
IA32_RELOCATION_RELJUMP
);
value
=
(
uint32_t
)
offset
;
}
else
{
intptr_t
const
entity_addr
=
(
intptr_t
)
be_jit_get_entity_addr
(
entity
);
if
(
entity_addr
==
(
intptr_t
)
-
1
)
panic
(
"Could not resolve address of entity %+F"
,
entity
);
intptr_t
addr
=
entity_addr
+
offset
;
if
(
be_kind
==
X86_IMM_PCREL
)
addr
-=
(
intptr_t
)
buffer
;
value
=
(
uint32_t
)
addr
;
if
((
intptr_t
)
value
!=
addr
)
panic
(
"Overflow in relocation"
);
}
uint32_t
const
entity_addr
=
(
uint32_t
)(
intptr_t
)
be_jit_get_entity_addr
(
entity
);
if
(
entity_addr
==
~
0u
)
panic
(
"Could not resolve address of entity %+F"
,
entity
);
uint32_t
addr
=
entity_addr
+
offset
;
if
(
be_kind
==
X86_IMM_PCREL
)
addr
-=
(
uint32_t
)(
intptr_t
)
buffer
;
uint32_t
*
dest
=
(
uint32_t
*
)
buffer
;
*
dest
=
addr
;
memcpy
(
buffer
,
&
value
,
4
);
return
4
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment