Skip to content

Cannot build on Big endian platform #24

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

Closed
vominh2012 opened this issue Jun 15, 2015 · 5 comments
Closed

Cannot build on Big endian platform #24

vominh2012 opened this issue Jun 15, 2015 · 5 comments
Assignees

Comments

@vominh2012
Copy link

When I build on PowerPC 64 this error happen
[ 23%] Building CXX object lib/Transforms/Obfuscation/CMakeFiles/LLVMObfuscation.dir/BogusControlFlow.cpp.o
In file included from /home/llvm-obfuscator/obfuscator/include/llvm/Transforms/Obfuscation/Substitution.h:26:0,
from /home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/Substitution.cpp:15:
/home/u0015999/llvm-obfuscator/obfuscator/include/llvm/CryptoUtils.h:80:2: error: #error "Unknown endianness of the compilation platform, check this header aes_encrypt.h"
#error
^
In file included from /home/llvm-obfuscator/obfuscator/include/llvm/Transforms/Obfuscation/BogusControlFlow.h:37:0,
from /home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/BogusControlFlow.cpp:93:
/home/llvm-obfuscator/obfuscator/include/llvm/CryptoUtils.h:80:2: error: #error "Unknown endianness of the compilation platform, check this header aes_encrypt.h"
#error
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘unsigned int llvm::CryptoUtils::scramble32(unsigned int, const char_)’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:545:20: error: ‘LOAD32H’ was not declared in this scope
LOAD32H(tmpA, key);
^
/home//llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘void llvm::CryptoUtils::inc_ctr()’:
/home/u0015999/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:658:25: error: ‘LOAD64H’ was not declared in this scope
LOAD64H(iseed, ctr + 8);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:660:26: error: ‘STORE64H’ was not declared in this scope
STORE64H(ctr + 8, iseed);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘uint32_t llvm::CryptoUtils::get_uint32_t()’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:735:19: error: ‘LOAD32H’ was not declared in this scope
LOAD32H(ret, tmp);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘uint64_t llvm::CryptoUtils::get_uint64_t()’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:748:19: error: ‘LOAD64H’ was not declared in this scope
LOAD64H(ret, tmp);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘void llvm::CryptoUtils::aes_compute_ks(uint32_t_, const char_)’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:787:19: error: ‘LOAD32H’ was not declared in this scope
LOAD32H(ks[0], k);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘void llvm::CryptoUtils::aes_encrypt(char_, const char_, const uint32_t_)’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:819:25: error: ‘LOAD32H’ was not declared in this scope
LOAD32H(state0, in + 0);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:868:27: error: ‘STORE32H’ was not declared in this scope
STORE32H(out + 0, state0);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In static member function ‘static int llvm::CryptoUtils::sha256_compress(llvm::CryptoUtils::sha256_state_, unsigned char_)’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:921:32: error: ‘LOAD32H’ was not declared in this scope
LOAD32H(W[i], buf + (4 * i));
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp: In member function ‘int llvm::CryptoUtils::sha256_done(llvm::CryptoUtils::sha256_state_, unsigned char_)’:
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:1064:36: error: ‘STORE64H’ was not declared in this scope
STORE64H(md->buf + 56, md->length);
^
/home/llvm-obfuscator/obfuscator/lib/Transforms/Obfuscation/CryptoUtils.cpp:1069:41: error: ‘STORE32H’ was not declared in this scope
STORE32H(out + (4 * i), md->state[i]);

@pyknite pyknite assigned pyknite and cryptopathe and unassigned pyknite and cryptopathe Jun 16, 2015
@pyknite
Copy link
Collaborator

pyknite commented Jun 16, 2015

There is a bug in the endings detection... We are working on it

@vominh2012
Copy link
Author

I have pull request for this already. you can review and consider for merge it

@cryptopathe
Copy link
Collaborator

Pull request merged.

@XiaoR
Copy link

XiaoR commented Mar 20, 2018

When I build on ARM 64 this error happen, I'm on the llvm-4.0 branch

In file included from /home/ubuntu/obfuscator/include/llvm/Transforms/Obfuscation/BogusControlFlow.h:37:0,
from /home/ubuntu/obfuscator/lib/Transforms/IPO/PassManagerBuilder.cpp:42:
/home/ubuntu/obfuscator/include/llvm/CryptoUtils.h:84:2: error: #error "Unknown endianness of the compilation platform, check this header aes_encrypt.h"

@LostBenjamin
Copy link

Errors also occur when I built on ARM 32 with llvm-3.4 branch:

In file included from /root/obfuscator/include/llvm/Transforms/Obfuscation/Flattening.h:27:0,
from /root/obfuscator/lib/Transforms/Obfuscation/CgfFunction.cpp:1:
/root/obfuscator/include/llvm/PrngAESCtr.h:80:2: error: #error "Unknown endianness of the compilation platform, check this header aes_encrypt.h"
#error "Unknown endianness of the compilation platform, check this header aes_encrypt.h"

hudjefa referenced this issue in hudjefa/obfuscator-llvm Feb 14, 2022
The Select insn in BPF is expensive as BPF backend
needs to resolve with conditionals.  This patch set
the getCmpSelInstrCost() to SCEVCheapExpansionBudget
for Select insn to prevent some Select insn related
optimizations.

This change is motivated during bcc code review for
   iovisor/bcc#3270
where IndVarSimplifyPass eventually caused generating
the following asm code:
  ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
      14:       16 05 40 00 00 00 00 00 if w5 == 0 goto +64 <LBB0_6>
      15:       bc 51 00 00 00 00 00 00 w1 = w5
      16:       04 01 00 00 ff ff ff ff w1 += -1
      17:       67 05 00 00 20 00 00 00 r5 <<= 32
      18:       77 05 00 00 20 00 00 00 r5 >>= 32
      19:       a6 01 01 00 05 00 00 00 if w1 < 5 goto +1 <LBB0_4>
      20:       b7 05 00 00 06 00 00 00 r5 = 6
  00000000000000a8 <LBB0_4>:
      21:       b7 02 00 00 00 00 00 00 r2 = 0
      22:       b7 01 00 00 00 00 00 00 r1 = 0
  ;       for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) {
      23:       7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1
      24:       7b 5a c0 ff 00 00 00 00 *(u64 *)(r10 - 64) = r5
Note that insn heroims#15 has w1 = w5 and w1 is refined later but r5(w5) is
eventually saved on stack at insn heroims#24 for later use. This cause
later verifier failures.

With this change, IndVarSimplifyPass won't do the above
transformation any more.

Differential Revision: https://reviews.llvm.org/D97479

(cherry picked from commit 1959ead525b8830cc8a345f45e1c3ef9902d3229)
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

5 participants