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

Aarch64 be patches #985

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 16 additions & 4 deletions gum/arch-arm64/gumarm64writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1992,15 +1992,21 @@ gum_arm64_writer_commit_literals (GumArm64Writer * self)
if (r->width != GUM_LITERAL_64BIT)
continue;

/*
* Whilst instructions in aarch64 are always in little endian (even on
* big-endian systems), the data is in native endian. Thus we don't need
* to make use of the GINT64_FROM_LE and GINT64_TO_LE when accessing the
* "slot" below.
*/
for (slot = first_slot; slot != last_slot; slot++)
{
if (GINT64_FROM_LE (*slot) == r->val)
WorksButNotTested marked this conversation as resolved.
Show resolved Hide resolved
if (*slot == r->val)
break;
}

if (slot == last_slot)
{
*slot = GINT64_TO_LE (r->val);
Copy link
Member

Choose a reason for hiding this comment

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

(Like above.)

*slot = r->val;
last_slot = slot + 1;
}

Expand All @@ -2024,15 +2030,21 @@ gum_arm64_writer_commit_literals (GumArm64Writer * self)
if (r->width != GUM_LITERAL_32BIT)
continue;

/*
* Whilst instructions in aarch64 are always in little endian (even on
* big-endian systems), the data is in native endian. Thus we don't need
* to make use of the GINT64_FROM_LE and GINT64_TO_LE when accessing the
* "slot" below.
*/
for (slot = first_slot; slot != last_slot; slot++)
{
if (GINT32_FROM_LE (*slot) == r->val)
Copy link
Member

Choose a reason for hiding this comment

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

(Like above.)

if (*slot == r->val)
break;
}

if (slot == last_slot)
{
*slot = GINT32_TO_LE (r->val);
Copy link
Member

Choose a reason for hiding this comment

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

(Like above.)

*slot = r->val;
last_slot = slot + 1;
}

Expand Down
5 changes: 3 additions & 2 deletions gum/gumdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ typedef GumMipsCpuContext GumCpuContext;
* The only non-legacy big-endian configuration on 32-bit ARM systems is BE8.
* In this configuration, whilst the data is in big-endian, the code stream is
* still in little-endian. Since Capstone is disassembling the code stream, it
* should work in little-endian even on BE8 systems.
* should work in little-endian even on BE8 systems. On big-endian 64-bit ARM
* systems, the code stream is likewise in little-endian.
*/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN || defined (__arm__)
#if G_BYTE_ORDER == G_LITTLE_ENDIAN || defined (__arm__) || defined (__aarch64__)
Copy link
Member

Choose a reason for hiding this comment

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

Exceeds 80 cols.

# define GUM_DEFAULT_CS_ENDIAN CS_MODE_LITTLE_ENDIAN
#else
# define GUM_DEFAULT_CS_ENDIAN CS_MODE_BIG_ENDIAN
Expand Down
Loading