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

Wrong bit field order on ARM #63

Open
LubosD opened this issue Sep 17, 2018 · 1 comment
Open

Wrong bit field order on ARM #63

LubosD opened this issue Sep 17, 2018 · 1 comment

Comments

@LubosD
Copy link

LubosD commented Sep 17, 2018

I've just spent a few hours figuring out why jbig2enc compiled for Android/arm produces output that cannot be decoded...

In jbig2structs.h there's a comment saying:

// GCC packs bit fields in a different order on big endian machines

The problem is Android has its own definition of _BIG_ENDIAN coming from here:

/tmp/my-android-toolchain/bin/../sysroot/usr/include/sys/endian.h:33:9: note: previous definition is here
#define _BIG_ENDIAN     4321

Which makes your code assume it's being compiled for a big endian platform.

@Mark-Joy
Copy link

Mark-Joy commented Jul 28, 2021

Thank you!!
This is exactly what happened to my build!
I use Termux on my android phone which uses clang as the default compiler. According to this answer https://stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine/2100391#2100391, I run on terminal:

λ [~] $ gcc -E -dM - < /dev/null |grep ENDIAN
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__ 1
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __ORDER_PDP_ENDIAN__ 3412
λ [~] $

My ARM is little endian with __LITTLE_ENDIAN__ flag defined. There are BIG_ENDIAN _BIG_ENDIAN and __BIG_ENDIAN defined in /sysroot/usr/include/sys/endian.h, but there is no __BIG_ENDIAN__

So a quick fix in my case would be replacing all entries: #ifndef _BIG_ENDIAN with #ifndef __BIG_ENDIAN__
in src/jbig2structs.h and src/jbig2segments.h

Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 27, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 29, 2021
Mark-Joy pushed a commit to Mark-Joy/jbig2enc that referenced this issue Nov 7, 2023
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