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 <[email protected]>
> ---
>  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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#163883): 
https://lists.openembedded.org/g/openembedded-core/message/163883
Mute This Topic: https://lists.openembedded.org/mt/90171088/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to