From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Sundeep KOKKONDA <sundeep.kokkonda@gmail.com>,
openembedded-core@lists.openembedded.org
Cc: rwmacleod@gmail.com, umesh.kalappa0@gmail.com
Subject: Re: [OE-core] [master] meta: scripts - relocation script adapted to support big-endian machines
Date: Fri, 01 Apr 2022 10:49:33 +0100 [thread overview]
Message-ID: <20442eb12ce2cf12e9fb83e3600a290a07bc0997.camel@linuxfoundation.org> (raw)
In-Reply-To: <20220401042007.2949717-1-sundeep.kokkonda@gmail.com>
On Fri, 2022-04-01 at 09:50 +0530, Sundeep KOKKONDA wrote:
> relocate_sdk.py was developed for little-endian architures and when tries
> to install SDK for big-endian machines errors like below will be shown.
>
> The changes made in the script to support big-endian architecture.
>
> Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@gmail.com>
> ---
> scripts/relocate_sdk.py | 45 ++++++++++++++++++++++++++++++++---------
> 1 file changed, 35 insertions(+), 10 deletions(-)
> mode change 100755 => 100644 scripts/relocate_sdk.py
>
> diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py
> old mode 100755
> new mode 100644
> index 8c0fdb986a..513b9343d3
> --- a/scripts/relocate_sdk.py
> +++ b/scripts/relocate_sdk.py
> @@ -30,9 +30,10 @@ else:
> old_prefix = re.compile(b("##DEFAULT_INSTALL_DIR##"))
>
> def get_arch():
> + global ei_data
> f.seek(0)
> e_ident =f.read(16)
> - ei_mag0,ei_mag1_3,ei_class = struct.unpack("<B3sB11x", e_ident)
> + ei_mag0,ei_mag1_3,ei_class,ei_data,ei_version = struct.unpack("<B3sBBB9x", e_ident)
>
> if (ei_mag0 != 0x7f and ei_mag1_3 != "ELF") or ei_class == 0:
> return 0
> @@ -51,11 +52,17 @@ def parse_elf_header():
>
> if arch == 32:
> # 32bit
> - hdr_fmt = "<HHILLLIHHHHHH"
> + if ei_data == 1: # ei_data = 1, little endian
> + hdr_fmt = "<HHILLLIHHHHHH"
> + else: # ei_data = 0, big endian
> + hdr_fmt = ">HHILLLIHHHHHH"
> hdr_size = 52
> else:
> # 64bit
> - hdr_fmt = "<HHIQQQIHHHHHH"
> + if ei_data == 1:
> + hdr_fmt = "<HHIQQQIHHHHHH"
> + else:
> + hdr_fmt = ">HHIQQQIHHHHHH"
> hdr_size = 64
I think we can make the change a bit neater, maybe putting ">" or "<" into the
global variable and then doing something like:
hdr_fmt = endian_prefix + "HHIQQQIHHHHHH"
?
Cheers,
Richard
next prev parent reply other threads:[~2022-04-01 9:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 4:20 [master] meta: scripts - relocation script adapted to support big-endian machines Sundeep KOKKONDA
2022-04-01 9:49 ` Richard Purdie [this message]
2022-04-05 10:00 ` Sundeep KOKKONDA
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20442eb12ce2cf12e9fb83e3600a290a07bc0997.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
--cc=rwmacleod@gmail.com \
--cc=sundeep.kokkonda@gmail.com \
--cc=umesh.kalappa0@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox