Git Product home page Git Product logo

libebc's Introduction

LibEBC

Build Status

Library and tool for retrieving embedded bitcode from binaries end libraries. It supports all types of objects files (Mach-O, ELF, COFF, ...) as well as Mach-O universal binaries, and static and dynamic libraries.

EBC Util

ebcutil is a stand-alone command line tool for extracting embedded bitcode.

Information about the binary is printed as well as metadata that is stored together with the bitcode files. For universal Mach-O binaries this includes linker flags and used dylibs. Objects not created by Apple LLVM contain only the command line options passed to the clang frontend.

The bitcode files are created in the current working directory. They can be processed by any tool accepting bitcode or you can use llvm-dis to convert them into human-readable LLVM assembly language.

Example of a Mach-O universal binary (fat binary):

$ file fat.o
fat.o: Mach-O universal binary with 2 architectures
fat.o (for architecture i386):    Mach-O executable i386
fat.o (for architecture x86_64):  Mach-O 64-bit executable x86_64

$ ebcutil fat.o
Mach-O 32-bit i386
  File name: fat.o
       Arch: x86
       UUID: 16B4EDD1-4B58-35FB-849F-0CA0647D6C1C
     Dylibs: {SDKPATH}/usr/lib/libSystem.B.dylib
  Link opts: -execute -macosx_version_min 10.11.0 -e _main -executable_path build/i386.o
    Bitcode: 2399E7B1-F4B6-4D55-916B-2EDAA799816E
    Bitcode: B3DEAEF5-4F4C-4FF1-95F0-7B5FDD2575F8
Mach-O 64-bit x86-64
  File name: fat.o
       Arch: x86_64
       UUID: F6323CD5-E0DD-3E99-9D4A-B36B5A8E3E36
     Dylibs: {SDKPATH}/usr/lib/libSystem.B.dylib
  Link opts: -execute -macosx_version_min 10.11.0 -e _main -executable_path build/x86_64.o
    Bitcode: DC97B259-9C3C-40D9-803C-8A841FB11DE3
    Bitcode: 7CC7D4AF-8750-4370-9D65-07CEBD720286

Example of an ELF shared library:

$ file lib.so
lib.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

$ ebcutil lib.so
ELF32-arm-little
  File name: lib.so
       Arch: arm
       UUID: 00000000-0000-0000-0000-000000000000
    Bitcode: 565E3FBE-5B28-4428-B31B-3B3420CDA43A
        Clang: -triple thumbv7-none-linux-android -S -fembed-bitcode=all -disable-llvm-optzns ...
    Bitcode: C4C34416-D5A2-40BB-A85A-88380E4A1375
        Clang: -triple thumbv7-none-linux-android -S -fembed-bitcode=all -disable-llvm-optzns ...

Apple embeds more than just bitcode in the LLVM section. Example of a Mach-O with an embedded Mach-O and embedded Xar:

$ file macho
macho: Mach-O 64-bit executable x86_64

$ ebcutil macho
Mach-O 64-bit x86-64
  File name: ASMExample
       Arch: x86_64
       UUID: 0A046594-A616-3CE3-9622-FF6D031BCA93
     Dylibs: {SDKPATH}/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation ...
  Link opts: -execute -macosx_version_min 10.12.0 -e _main -executable_path ...
    Bitcode: 663A7A0C-1D29-4469-A68E-391BB16DD21A
      MachO: BC282643-364A-46A5-9690-F8226DB9F7DC
        Xar: C10CA2C2-EA04-4C71-AA17-9272DE85E0FD

You can also use ebcutil to check whether a given binary or library contains bitcode. It prints the first object encountered without bitcode and exits with a non-zero exit status.

$ ebcutil nobitcode.o
Error: No bitcode section in nobitcode.o

Build

This project uses CMake as its build system. It has the following dependencies:

  • CMake 3.0 or later.
  • LibXML2
  • LibXar (optional, but required for Apple's embedded bitcode)
  • LLVM 3.9 or LLVM 4.0
$ git clone https://github.com/JDevlieghere/LibEBC.git && cd LibEBC
$ mkdir build && cd build
$ cmake ..
$ cmake --build .

libebc's People

Contributors

dennisfrett avatar dzan avatar jdevlieghere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libebc's Issues

Could not open xar archive

./ebcutil XXSDK.framework/XXSDK
Mach-O arm
File name: XXSDK
Arch: armv7
UUID: FF59DECE-BB3A-3433-8875-9234D3167487
Dylibs: Link opts:
Could not open xar archive
[1] 29650 segmentation fault ./ebcutil

Compile Fails on MacOS 10.13.1

Compile Fails on MacOS 10.13.1, here is the cmake log:

$ cmake ..
-- The C compiler identification is AppleClang 9.0.0.9000038
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building without sanitizers
CMake Error at /usr/local/Cellar/cmake/3.9.3_1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES) (found version "2.9.4")
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.9.3_1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.9.3_1/share/cmake/Modules/FindLibXml2.cmake:56 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  lib/CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/York/Downloads/LibEBC/build/CMakeFiles/CMakeOutput.log".

Here is the CMakeOutput.log

Undefined symbols _iconv

Hi @JDevlieghere

I have followed the build steps in the README. cmake .. works fine. When I run cmake --build . I get the following:

[ 53%] Built target ebc
[ 57%] Linking CXX executable ebctest
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_xmlIconvWrapper in libxml2.a(encoding.o)
"_iconv_close", referenced from:
_xmlFindCharEncodingHandler in libxml2.a(encoding.o)
_xmlCharEncCloseFunc in libxml2.a(encoding.o)
"_iconv_open", referenced from:
_xmlFindCharEncodingHandler in libxml2.a(encoding.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/ebctest] Error 1
make[1]: *** [test/CMakeFiles/ebctest.dir/all] Error 2
make: *** [all] Error 2

But iconv appears to be installed:

which iconv
/usr/local/bin/iconv

Have I not done something correctly here? I appreciate any help you can offer!

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.