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

[Mobile] terminating with uncaught exception of type Ort::Exception: ONNX format model is not supported in this build #18271

Closed
w11m opened this issue Nov 3, 2023 · 14 comments
Labels
platform:mobile issues related to ONNX Runtime mobile; typically submitted using template

Comments

@w11m
Copy link

w11m commented Nov 3, 2023

Describe the issue

I am currently working on a project where I tried with a pre-built shared library, specifically onnxruntime-android-1.12.1 and onnxruntime-mobile-1.12.1, to facilitate the loading of two distinct ONNX models (.onnx files).

These models are described as follows:
Model A:
ONNX Opset Import Version: 16
Model B:
ONNX Opset Import Version: 11

Issue Description:
My challenge arises when attempting to load Model B using the following code snippet:
session = make_unique<Ort::Session>(env.modelBpath.c_str(), sessionOptions);
but For model B i cannot load it, shows "terminating with uncaught exception of type Ort::Exception: ONNX format model is not supported in this build."

Unfortunately, this code results in an unhandled exception with the message:
"ONNX format model is not supported in this build," for Model B."

Troubleshooting Steps Taken:
I have made an attempt to convert Model B to ONNX Opset Import Version 16 using the following Python code:

from onnx import version_converter
converted_model = version_converter.convert_version(model, 16)

However, even after this conversion, I am still encountering the same error when trying to load Model B.

Environment Information:

ONNX Version: 1.12.0
onnx-graphsurgeon Version: 0.3.27
onnxruntime Version: 1.13.1
onnxruntime-tools Version: 1.7.0

I would greatly appreciate any guidance or information that can help me in diagnosing and resolving this issue. Thank you in advance for your assistance.

To reproduce

As below

Urgency

No response

Platform

Android

OS Version

13

ONNX Runtime Installation

Released Package

Compiler Version (if 'Built from Source')

No response

Package Name (if 'Released Package')

onnxruntime-android

ONNX Runtime Version or Commit ID

1.12.1

ONNX Runtime API

C++/C

Architecture

ARM64

Execution Provider

Default CPU, Other / Unknown

Execution Provider Library Version

No response

@w11m w11m added the platform:mobile issues related to ONNX Runtime mobile; typically submitted using template label Nov 3, 2023
@skottmckay
Copy link
Contributor

You use either onnxruntime-android-1.12.1 or onnxruntime-mobile-1.12.1 not both.

onnxruntime-mobile-1.12.1 is a reduced size build that only supports ORT format models and a limited range of opsets and operators.

onnxruntime-android-1.12.1 supports ONNX and ORT format models and all the opsets that were implemented when the package was created.

Based on the error it sounds like the onnxruntime library from the mobile package is being selected hence the issues loading the model.

Is there a reason not to use the latest release of 1.16? 1.12 is somewhat old.

@w11m
Copy link
Author

w11m commented Nov 8, 2023

@skottmckay I apologize for my previous wording error.
I have verified that attempting to use only one shared libraries while testing.

The reason I am currently using onnxruntime-android-1.12.1 is because it is the version compatible with my model A.
When I attempt to use model A with opset version 16 and onnxruntime-android-1.16.1, I encounter the following error:

The given version [16] is not supported, only version 1 to 12 is supported in this build.

I obtained the pre-built onnxruntime-android-1.16.1 library from the following repository:
https://mvnrepository.com/artifact/com.microsoft.onnxruntime/onnxruntime-android

If you are aware of any potential methods that could cause this error to occur, or any method that I can convert the onnx opset version, please let me know. Thanks

@w11m w11m closed this as completed Nov 8, 2023
@w11m w11m reopened this Nov 8, 2023
@skottmckay
Copy link
Contributor

That error doesn't quite make sense if your app is only using the 1.16.1 onnxruntime-android package.

The error message means the header file being used is from ORT 1.16 as it is requesting v16 of the API, but the actual shared library doesn't know about that version which suggest you actually have linked against v1.12.1 libonnxruntime in the app.

I'd suggest you make sure you're only referencing onnxruntime-android v1.16.1 and that the libonnxruntime.so included in the app comes from that package. There may be old build artifacts being accidentally included so a clean build might also help.

FWIW The error message doesn't actually exist in the 1.16 shared library as the wording was changed.

1.12:

fprintf(stderr, "The given version [%u] is not supported, only version 1 to %u is supported in this build.\n",
version, ORT_API_VERSION);

1.16:

fprintf(stderr,
"The requested API version [%u] is not available, only API versions [1, %u] are supported in this build."
" Current ORT Version is: %s\n",
version, ORT_API_VERSION, ORT_VERSION);

@w11m
Copy link
Author

w11m commented Nov 8, 2023

Thanks for the infomation, I'll re-check all the build environment and include file again.

@w11m
Copy link
Author

w11m commented Nov 9, 2023

@skottmckay Thank you for point out the problem
After rebuilding my environment and using the 1.16.1 library, theres no error log with 1.12.1 anymore
I encountered a new issue.

Despite replacing the .so file and header file, the C++ code was not updated, facing the error

cannot locate symbol "OrtGetApiBase" referenced by OOOOOO

Here is part of the code I'm using

#include "ModelA.h"
#include <onnxruntime/onnxruntime_cxx_api.h>
#include <codecvt>
#include <fstream>
#include <iostream>
#include <locale>
#include <opencv2/opencv.hpp>
#include <vector>
#include <list>

template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
    return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

struct ModelA{
	Ort::Env env{ ORT_LOGGING_LEVEL_WARNING, "test" };
	Ort::SessionOptions sessionOptions[2];
	std::unique_ptr<Ort::Session> sessionPre, sessionSam;
	std::vector<int64_t> inputShapePre, outputShapePre;
	Ort::MemoryInfo memoryInfo{ Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault) };
	bool bModelLoaded = false;
	std::vector<float> outputTensorValuesPre;

Without modifying the CMakeList.txt, the build succeeds when using onnxruntime-android-1.12.1:shardLIB and Header.

However, when using version 1.16.1, I encounter build errors.
Could there be any additional modifications required for compatibility with version 1.16.1 that i missed out.

@w11m
Copy link
Author

w11m commented Nov 14, 2023

readelf -a libonnxruntime.so readelf of libonnxruntime.so (1.16.2) from https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-android/1.16.2/

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           arm64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          14627976 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         28
  Section header string table index: 27

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0  0  0
  [ 1] .note.android.ident NOTE            0000000000000238 000238 000098 00   A  0  0  4
  [ 2] .note.gnu.build-id NOTE            00000000000002d0 0002d0 000024 00   A  0  0  4
  [ 3] .dynsym           DYNSYM          00000000000002f8 0002f8 001350 18   A  9  1  8
  [ 4] .gnu.version      VERSYM          0000000000001648 001648 00019c 02   A  3  0  2
  [ 5] .gnu.version_d    VERDEF          00000000000017e4 0017e4 000038 00   A  9  2  4
  [ 6] .gnu.version_r    VERNEED         000000000000181c 00181c 000060 00   A  9  3  4
  [ 7] .gnu.hash         GNU_HASH        0000000000001880 001880 000028 00   A  3  0  8
  [ 8] .hash             HASH            00000000000018a8 0018a8 000678 04   A  3  0  4
  [ 9] .dynstr           STRTAB          0000000000001f20 001f20 0008aa 00   A  0  0  1
  [10] .rela.dyn         RELA            00000000000027d0 0027d0 0e8cf8 18   A  3  0  8
  [11] .rela.plt         RELA            00000000000eb4c8 0eb4c8 0012d8 18  AI  3 23  8
  [12] .gcc_except_table PROGBITS        00000000000ec7a0 0ec7a0 086ec4 00   A  0  0  4
  [13] .rodata           PROGBITS        0000000000173670 173670 111468 00 AMS  0  0 16
  [14] .eh_frame_hdr     PROGBITS        0000000000284ad8 284ad8 036644 00   A  0  0  4
  [15] .eh_frame         PROGBITS        00000000002bb120 2bb120 0f232c 00   A  0  0  8
  [16] .text             PROGBITS        00000000003ad460 3ad460 9eecec 00  AX  0  0 32
  [17] .plt              PROGBITS        0000000000d9c150 d9c150 000cb0 00  AX  0  0 16
  [18] .data.rel.ro      PROGBITS        0000000000d9de00 d9ce00 04dd10 00  WA  0  0  8
  [19] .fini_array       FINI_ARRAY      0000000000debb10 deab10 000010 00  WA  0  0  8
  [20] .init_array       INIT_ARRAY      0000000000debb20 deab20 000080 00  WA  0  0  8
  [21] .dynamic          DYNAMIC         0000000000debba0 deaba0 000200 10  WA  9  0  8
  [22] .got              PROGBITS        0000000000debda0 deada0 0073f8 00  WA  0  0  8
  [23] .got.plt          PROGBITS        0000000000df3198 df2198 000660 00  WA  0  0  8
  [24] .data             PROGBITS        0000000000df47f8 df27f8 000ac0 00  WA  0  0  8
  [25] .bss              NOBITS          0000000000df52c0 df32b8 00a610 00  WA  0  0 16
  [26] .comment          PROGBITS        0000000000000000 df32b8 0000b1 01  MS  0  0  1
  [27] .shstrtab         STRTAB          0000000000000000 df3369 00011e 00      0  0  1
Key:
  (W)rite, (A)lloc, e(X)ecute, (M)erge, (S)trings, (I)nfo
  (L)ink order, (O)S, (G)roup, (T)LS, (C)ompressed, x=unknown

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz MemSiz  Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x001f8 0x001f8 R   0x8
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0xd9ce00 0xd9ce00 R E 0x1000
  LOAD           0xd9ce00 0x0000000000d9de00 0x0000000000d9de00 0x559f8 0x559f8 RW  0x1000
  LOAD           0xdf27f8 0x0000000000df47f8 0x0000000000df47f8 0x00ac0 0x0b0d8 RW  0x1000
  DYNAMIC        0xdeaba0 0x0000000000debba0 0x0000000000debba0 0x00200 0x00200 RW  0x8
  GNU_RELRO      0xd9ce00 0x0000000000d9de00 0x0000000000d9de00 0x559f8 0x56200 R   0x1
  GNU_EH_FRAME   0x284ad8 0x0000000000284ad8 0x0000000000284ad8 0x36644 0x36644 R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x00000 0x00000 RW  0
  NOTE           0x000238 0x0000000000000238 0x0000000000000238 0x000bc 0x000bc R   0x4

 Section to Segment mapping:
  Segment Sections...
   00
   01     .note.android.ident .note.gnu.build-id .dynsym .gnu.version .gnu.version_d .gnu.version_r .gnu.hash .hash .dynstr .rela.dyn .rela.plt .gcc_except_table .rodata .eh_frame_hdr .eh_frame .text .plt
   02     .data.rel.ro .fini_array .init_array .dynamic .got .got.plt
   03     .data
   04     .dynamic
   05     .data.rel.ro .fini_array .init_array .dynamic .got .got.plt
   06     .eh_frame_hdr
   07
   08     .note.android.ident .note.gnu.build-id

Dynamic section at offset 0xdeaba0 contains 32 entries:
  Tag                Type                 Name/Value
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so]
 0x0000000000000001 (NEEDED)             Shared library: [liblog.so]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x000000000000000e (SONAME)             Library soname: [libonnxruntime.so]
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW
 0x0000000000000007 (RELA)               0x27d0
 0x0000000000000008 (RELASZ)             953592 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffff9 (RELACOUNT)          39728
 0x0000000000000017 (JMPREL)             0xeb4c8
 0x0000000000000002 (PLTRELSZ)           4824 (bytes)
 0x0000000000000003 (PLTGOT)             0xdf3198
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000006 (SYMTAB)             0x2f8
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000005 (STRTAB)             0x1f20
 0x000000000000000a (STRSZ)              2218 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x1880
 0x0000000000000004 (HASH)               0x18a8
 0x0000000000000019 (INIT_ARRAY)         0xdebb20
 0x000000000000001b (INIT_ARRAYSZ)       128 (bytes)
 0x000000000000001a (FINI_ARRAY)         0xdebb10
 0x000000000000001c (FINI_ARRAYSZ)       16 (bytes)
 0x000000006ffffff0 (VERSYM)             0x1648
 0x000000006ffffffc (VERDEF)             0x17e4
 0x000000006ffffffd (VERDEFNUM)          2
 0x000000006ffffffe (VERNEED)            0x181c
 0x000000006fffffff (VERNEEDNUM)         3
 0x0000000000000000 (NULL)               0x0

Symbol table '.dynsym' contains 206 entries:
   Num:            Value  Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_finalize
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcmp
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen
     6: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset
     8: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND __sF
     9: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fprintf
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memchr
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcmp
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __strlen_chk
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strncmp
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND localtime_r
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strftime
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fclose
    17: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fseeko
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ftello
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fwrite
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fflush
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memmove
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fread
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fopen
    24: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fseek
    25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND localeconv
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoull
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoll
    29: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtod
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __vsnprintf_chk
    31: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __system_property_get
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlopen
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlsym
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlerror
    35: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND atoi
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __memcpy_chk
    40: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND expf
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND exp
    42: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log1pf
    43: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tanh
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND logf
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc
    48: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fmodf
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sinf
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sin
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND cosf
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tanf
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND asinf
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND acosf
    55: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND atanf
    56: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sinhf
    57: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND coshf
    58: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND asinhf
    59: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND acoshf
    60: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND atanhf
    61: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pow
    62: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND powf
    63: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fmod
    64: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log2
    65: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemcmp
    66: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemset
    67: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemcpy
    68: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND remainderf
    69: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tanhf
    70: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sincosf
    71: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sincos
    72: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND cos
    73: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log10
    74: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __memmove_chk
    75: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND posix_memalign
    76: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strnlen
    77: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtol
    78: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ZTH15ThreadedBufSize
    79: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ldexpf
    80: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syscall
    81: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vsnprintf
    82: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gmtime_r
    83: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mktime
    84: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND difftime
    85: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_self
    86: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sched_getcpu
    87: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND llroundl
    88: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_print
    89: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strncpy
    90: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dirname
    91: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_init
    92: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_setstacksize
    93: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_create
    94: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND nanosleep
    95: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __open_2
    96: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat
    97: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lseek
    98: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read
    99: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sysconf
   100: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat
   101: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mkdir
   102: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND nftw
   103: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open
   104: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realpath
   105: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getpid
   106: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlclose
   107: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv
   108: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r
   109: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_join
   110: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND remove
   111: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND clock_gettime
   112: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gettimeofday
   113: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_init
   114: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_lock
   115: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_unlock
   116: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_destroy
   117: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_once
   118: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc
   119: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memalign
   120: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat64
   121: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _ctype_
   122: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_getspecific
   123: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_setspecific
   124: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_create
   125: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fcntl
   126: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror
   127: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __read_chk
   128: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND write
   129: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_write
   130: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fputs
   131: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtof
   132: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_init
   133: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort
   134: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_destroy
   135: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_wrlock
   136: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_unlock
   137: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_rdlock
   138: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __strchr_chk
   139: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc
   140: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sched_yield
   141: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dl_iterate_phdr
   142: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_vprint
   143: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND qsort
   144: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getauxval
   145: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_broadcast
   146: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_wait
   147: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_timedwait
   148: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ungetc
   149: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getc
   150: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND newlocale
   151: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND uselocale
   152: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vsscanf
   153: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vasprintf
   154: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isxdigit_l
   155: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isdigit_l
   156: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strftime_l
   157: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbsrtowcs
   158: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sscanf
   159: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND freelocale
   160: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcoll_l
   161: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strxfrm_l
   162: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcscoll_l
   163: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcsxfrm_l
   164: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswlower_l
   165: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND islower_l
   166: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isupper_l
   167: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND toupper_l
   168: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tolower_l
   169: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswspace_l
   170: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswprint_l
   171: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswblank_l
   172: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswcntrl_l
   173: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswupper_l
   174: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswalpha_l
   175: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswdigit_l
   176: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswpunct_l
   177: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswxdigit_l
   178: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND towupper_l
   179: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND towlower_l
   180: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND btowc
   181: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wctob
   182: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcsnrtombs
   183: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcrtomb
   184: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbsnrtowcs
   185: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbrtowc
   186: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbtowc
   187: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __ctype_get_mb_cur_max
   188: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbrlen
   189: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcslen
   190: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoll_l
   191: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoull_l
   192: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtold_l
   193: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemmove
   194: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND snprintf
   195: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vfprintf
   196: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fputc
   197: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND android_set_abort_message
   198: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND openlog
   199: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syslog
   200: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND closelog
   201: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __cxa_thread_atexit_impl
   202: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_delete
   203: 0000000000440a2c   484 FUNC    GLOBAL DEFAULT   16 OrtSessionOptionsAppendExecutionProvider_Nnapi
   204: 00000000003b1670    12 FUNC    GLOBAL DEFAULT   16 OrtGetApiBase
   205: 00000000005a2640   260 FUNC    GLOBAL DEFAULT   16 OrtSessionOptionsAppendExecutionProvider_CPU

Displaying notes found in: .note.android.ident
  Owner                 Data size       Description
  Android              0x00000084       NT_VERSION      API level 21, NDK r25 (8775105)

Displaying notes found in: .note.gnu.build-id
  Owner                 Data size       Description
  GNU                  0x00000014       NT_GNU_BUILD_ID ffc466f5683be28c570caaa04c104d0e8560be83

@w11m
Copy link
Author

w11m commented Nov 14, 2023

readelf -a libonnxruntime.so readelf of libonnxruntime.so (1.12.1) from https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-android/1.12.1/

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           arm64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          12007416 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         28
  Section header string table index: 27

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0  0  0
  [ 1] .note.android.ident NOTE            0000000000000238 000238 000098 00   A  0  0  4
  [ 2] .note.gnu.build-id NOTE            00000000000002d0 0002d0 000024 00   A  0  0  4
  [ 3] .dynsym           DYNSYM          00000000000002f8 0002f8 0012f0 18   A  9  1  8
  [ 4] .gnu.version      VERSYM          00000000000015e8 0015e8 000194 02   A  3  0  2
  [ 5] .gnu.version_d    VERDEF          000000000000177c 00177c 000038 00   A  9  2  4
  [ 6] .gnu.version_r    VERNEED         00000000000017b4 0017b4 000060 00   A  9  3  4
  [ 7] .gnu.hash         GNU_HASH        0000000000001818 001818 000028 00   A  3  0  8
  [ 8] .hash             HASH            0000000000001840 001840 000658 04   A  3  0  4
  [ 9] .dynstr           STRTAB          0000000000001e98 001e98 000874 00   A  0  0  1
  [10] .rela.dyn         RELA            0000000000002710 002710 0c83e8 18   A  3  0  8
  [11] .rela.plt         RELA            00000000000caaf8 0caaf8 001278 18  AI  3 23  8
  [12] .gcc_except_table PROGBITS        00000000000cbd70 0cbd70 072160 00   A  0  0  4
  [13] .rodata           PROGBITS        000000000013ded0 13ded0 0e5838 00 AMS  0  0 16
  [14] .eh_frame_hdr     PROGBITS        0000000000223708 223708 02e53c 00   A  0  0  4
  [15] .eh_frame         PROGBITS        0000000000251c48 251c48 0ce70c 00   A  0  0  8
  [16] .text             PROGBITS        0000000000320360 320360 807cfc 00  AX  0  0 32
  [17] .plt              PROGBITS        0000000000b28060 b28060 000c70 00  AX  0  0 16
  [18] .data.rel.ro      PROGBITS        0000000000b29cd0 b28cd0 043080 00  WA  0  0  8
  [19] .fini_array       FINI_ARRAY      0000000000b6cd50 b6bd50 000010 00  WA  0  0  8
  [20] .init_array       INIT_ARRAY      0000000000b6cd60 b6bd60 000088 00  WA  0  0  8
  [21] .dynamic          DYNAMIC         0000000000b6cde8 b6bde8 000200 10  WA  9  0  8
  [22] .got              PROGBITS        0000000000b6cfe8 b6bfe8 006630 00  WA  0  0  8
  [23] .got.plt          PROGBITS        0000000000b73618 b72618 000640 00  WA  0  0  8
  [24] .data             PROGBITS        0000000000b74c58 b72c58 0009d8 00  WA  0  0  8
  [25] .bss              NOBITS          0000000000b75630 b73630 004c30 00  WA  0  0 16
  [26] .comment          PROGBITS        0000000000000000 b73630 0000b1 01  MS  0  0  1
  [27] .shstrtab         STRTAB          0000000000000000 b736e1 000113 00      0  0  1
Key:
  (W)rite, (A)lloc, e(X)ecute, (M)erge, (S)trings, (I)nfo
  (L)ink order, (O)S, (G)roup, (T)LS, (C)ompressed, x=unknown

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz MemSiz  Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x001f8 0x001f8 R   0x8
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0xb28cd0 0xb28cd0 R E 0x1000
  LOAD           0xb28cd0 0x0000000000b29cd0 0x0000000000b29cd0 0x49f88 0x49f88 RW  0x1000
  LOAD           0xb72c58 0x0000000000b74c58 0x0000000000b74c58 0x009d8 0x05608 RW  0x1000
  DYNAMIC        0xb6bde8 0x0000000000b6cde8 0x0000000000b6cde8 0x00200 0x00200 RW  0x8
  GNU_RELRO      0xb28cd0 0x0000000000b29cd0 0x0000000000b29cd0 0x49f88 0x4a330 R   0x1
  GNU_EH_FRAME   0x223708 0x0000000000223708 0x0000000000223708 0x2e53c 0x2e53c R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x00000 0x00000 RW  0
  NOTE           0x000238 0x0000000000000238 0x0000000000000238 0x000bc 0x000bc R   0x4

 Section to Segment mapping:
  Segment Sections...
   00
   01     .note.android.ident .note.gnu.build-id .dynsym .gnu.version .gnu.version_d .gnu.version_r .gnu.hash .hash .dynstr .rela.dyn .rela.plt .gcc_except_table .rodata .eh_frame_hdr .eh_frame .text .plt
   02     .data.rel.ro .fini_array .init_array .dynamic .got .got.plt
   03     .data
   04     .dynamic
   05     .data.rel.ro .fini_array .init_array .dynamic .got .got.plt
   06     .eh_frame_hdr
   07
   08     .note.android.ident .note.gnu.build-id

Dynamic section at offset 0xb6bde8 contains 32 entries:
  Tag                Type                 Name/Value
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
 0x0000000000000001 (NEEDED)             Shared library: [liblog.so]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x000000000000000e (SONAME)             Library soname: [libonnxruntime.so]
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW
 0x0000000000000007 (RELA)               0x2710
 0x0000000000000008 (RELASZ)             820200 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffff9 (RELACOUNT)          34171
 0x0000000000000017 (JMPREL)             0xcaaf8
 0x0000000000000002 (PLTRELSZ)           4728 (bytes)
 0x0000000000000003 (PLTGOT)             0xb73618
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000006 (SYMTAB)             0x2f8
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000005 (STRTAB)             0x1e98
 0x000000000000000a (STRSZ)              2164 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x1818
 0x0000000000000004 (HASH)               0x1840
 0x0000000000000019 (INIT_ARRAY)         0xb6cd60
 0x000000000000001b (INIT_ARRAYSZ)       136 (bytes)
 0x000000000000001a (FINI_ARRAY)         0xb6cd50
 0x000000000000001c (FINI_ARRAYSZ)       16 (bytes)
 0x000000006ffffff0 (VERSYM)             0x15e8
 0x000000006ffffffc (VERDEF)             0x177c
 0x000000006ffffffd (VERDEFNUM)          2
 0x000000006ffffffe (VERNEED)            0x17b4
 0x000000006fffffff (VERNEEDNUM)         3
 0x0000000000000000 (NULL)               0x0

Symbol table '.dynsym' contains 202 entries:
   Num:            Value  Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_finalize
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcmp
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen
     6: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset
     8: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strncpy
     9: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND __sF
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fprintf
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memchr
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcmp
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __strlen_chk
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fclose
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strncmp
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND localtime_r
    17: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strftime
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fseeko
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ftello
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fwrite
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fflush
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memmove
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fread
    24: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fopen
    25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fseek
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND localeconv
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoull
    29: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoll
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtod
    31: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __vsnprintf_chk
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap
    35: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __system_property_get
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlopen
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlsym
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlerror
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __memcpy_chk
    40: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND expf
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND exp
    42: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log1pf
    43: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tanh
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND logf
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc
    48: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fmodf
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sinf
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sin
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND cosf
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tanf
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND asinf
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND acosf
    55: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND atanf
    56: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sinhf
    57: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND coshf
    58: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND asinhf
    59: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND acoshf
    60: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND atanhf
    61: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pow
    62: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND powf
    63: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fmod
    64: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log2
    65: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemcmp
    66: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemset
    67: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemcpy
    68: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND remainderf
    69: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tanhf
    70: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sincosf
    71: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sincos
    72: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND cos
    73: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND log10
    74: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND posix_memalign
    75: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strnlen
    76: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND bsearch
    77: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtol
    78: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ldexpf
    79: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syscall
    80: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vsnprintf
    81: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gmtime_r
    82: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mktime
    83: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND difftime
    84: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_self
    85: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sched_getcpu
    86: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND llroundl
    87: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_print
    88: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dirname
    89: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_init
    90: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_setstacksize
    91: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_create
    92: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND nanosleep
    93: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __open_2
    94: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat
    95: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND lseek
    96: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read
    97: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sysconf
    98: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat
    99: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mkdir
   100: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND nftw
   101: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open
   102: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realpath
   103: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getpid
   104: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dlclose
   105: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv
   106: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r
   107: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_join
   108: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND remove
   109: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND clock_gettime
   110: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND gettimeofday
   111: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _ctype_
   112: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_getspecific
   113: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_setspecific
   114: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_create
   115: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fcntl
   116: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror
   117: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __read_chk
   118: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND write
   119: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_write
   120: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fputs
   121: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtof
   122: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __memmove_chk
   123: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_init
   124: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort
   125: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_destroy
   126: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_wrlock
   127: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_unlock
   128: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_rdlock
   129: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __strchr_chk
   130: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_once
   131: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc
   132: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND qsort
   133: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getauxval
   134: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_vprint
   135: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sched_yield
   136: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dl_iterate_phdr
   137: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_lock
   138: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_unlock
   139: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_broadcast
   140: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_wait
   141: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_timedwait
   142: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc
   143: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ungetc
   144: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getc
   145: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND newlocale
   146: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND uselocale
   147: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vsscanf
   148: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vasprintf
   149: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isxdigit_l
   150: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isdigit_l
   151: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strftime_l
   152: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbsrtowcs
   153: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sscanf
   154: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND freelocale
   155: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcoll_l
   156: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strxfrm_l
   157: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcscoll_l
   158: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcsxfrm_l
   159: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswlower_l
   160: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND islower_l
   161: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isupper_l
   162: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND toupper_l
   163: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tolower_l
   164: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswspace_l
   165: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswprint_l
   166: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswblank_l
   167: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswcntrl_l
   168: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswupper_l
   169: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswalpha_l
   170: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswdigit_l
   171: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswpunct_l
   172: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iswxdigit_l
   173: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND towupper_l
   174: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND towlower_l
   175: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND btowc
   176: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wctob
   177: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcsnrtombs
   178: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcrtomb
   179: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbsnrtowcs
   180: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbrtowc
   181: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbtowc
   182: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __ctype_get_mb_cur_max
   183: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mbrlen
   184: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcslen
   185: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoll_l
   186: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoull_l
   187: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtold_l
   188: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_destroy
   189: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemmove
   190: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND snprintf
   191: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vfprintf
   192: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fputc
   193: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND android_set_abort_message
   194: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND openlog
   195: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syslog
   196: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND closelog
   197: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __cxa_thread_atexit_impl
   198: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_delete
   199: 000000000039cddc   484 FUNC    GLOBAL DEFAULT   16 OrtSessionOptionsAppendExecutionProvider_Nnapi
   200: 00000000003240a8    12 FUNC    GLOBAL DEFAULT   16 OrtGetApiBase
   201: 00000000004c5400   260 FUNC    GLOBAL DEFAULT   16 OrtSessionOptionsAppendExecutionProvider_CPU

Displaying notes found in: .note.android.ident
  Owner                 Data size       Description
  Android              0x00000084       NT_VERSION      API level 21, NDK r25 (8775105)

Displaying notes found in: .note.gnu.build-id
  Owner                 Data size       Description
  GNU                  0x00000014       NT_GNU_BUILD_ID 1b2c48e5d2db22ba19a35c1fe345b72066782b58

@w11m
Copy link
Author

w11m commented Nov 14, 2023

I am uncertain if the provided log contains sufficient detail.
In version 1.12.1, the process completed successfully without any error logs.

But in version 1.16.1, the process failed and generated an error log.
cannot locate symbol "OrtGetApiBase" referenced by OOOOOO

@w11m
Copy link
Author

w11m commented Nov 15, 2023

Dear @skottmckay,

I regret any inconvenience caused mention you in this matter.
I have searched might related issue #4036, #10158, and #4539.

Have tried insert code like this also

#define ORT_API_MANUAL_INIT
#include <onnxruntime/onnxruntime_cxx_api.h>
const OrtApi* g_ort = OrtGetApiBase()->GetApi(ORT_API_VERSION);
#undef ORT_API_MANUAL_INIT

However, I am currently unable to point out the root cause of the problem.
Your guidance or insights would be greatly appreciated.

@skottmckay
Copy link
Contributor

Doesn't appear like you're linking correctly against the .so. There are multiple architectures in the android library (32-bit and 64-bit for ARM and AMD64). I would check that you're using the correct one.

You can see the symbol in the readelf output for both versions so it exists.

204: 00000000003b1670 12 FUNC GLOBAL DEFAULT 16 OrtGetApiBase

200: 00000000003240a8 12 FUNC GLOBAL DEFAULT 16 OrtGetApiBase

You don't need to call OrtGetApiBase directly in your code - it's used internally by the ORT C++ API. Adding more usage of a missing symbol doesn't affect whether it's found or not.

@w11m
Copy link
Author

w11m commented Nov 16, 2023

@skottmckay I extract the shared lib (.so) from

Version 1.12.1

[onnxruntime-android-1.12.1.aar]
(https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-android/1.12.1/onnxruntime-android-1.12.1.aar) 2022-08-04 21:27 18138166

And get the lib from \onnxruntime-android-1.12.1\jni\arm64-v8a

Version 1.16.2

onnxruntime-android-1.16.2.aar 2023-11-09 19:47 22818628

And get the lib from \onnxruntime-android-1.16.2\jni\arm64-v8a

@w11m
Copy link
Author

w11m commented Nov 16, 2023

@skottmckay I also checked with readelf of my file
0x0000000000000001 (NEEDED) Shared library: [libonnxruntime.so]

readelf -d /vendor/lib64/test_SampleOnnxruntime

Dynamic section at offset 0xaf4f8 contains 37 entries:
Tag Type Name/Value
0x0000000000000003 (PLTGOT) 0xbfc40
0x0000000000000002 (PLTRELSZ) 2784 (bytes)
0x0000000000000017 (JMPREL) 0x11290
0x0000000000000014 (PLTREL) RELA
0x0000000000000007 (RELA) 0x2398
0x0000000000000008 (RELASZ) 61176 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffff9 (RELACOUNT) 2534
0x0000000000000015 (DEBUG) 0x0
0x0000000000000006 (SYMTAB) 0x310
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000005 (STRTAB) 0x1510
0x000000000000000a (STRSZ) 1904 (bytes)
0x0000000000000004 (HASH) 0x1c80
0x0000000000000001 (NEEDED) Shared library: [libm.so]
0x0000000000000001 (NEEDED) Shared library: [liblog.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so]
0x0000000000000001 (NEEDED) Shared library: [libonnxruntime.so]
0x0000000000000001 (NEEDED) Shared library: [libz.so]
0x0000000000000001 (NEEDED) Shared library: [libdl.so]
0x0000000000000020 (PREINIT_ARRAY) 0xbaf30
0x0000000000000021 (PREINIT_ARRAYSZ) 0x10
0x0000000000000019 (INIT_ARRAY) 0xbaf40
0x000000000000001b (INIT_ARRAYSZ) 160 (bytes)
0x000000000000001a (FINI_ARRAY) 0xbafe0
0x000000000000001c (FINI_ARRAYSZ) 16 (bytes)
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW
0x000000006ffffff0 (VERSYM) 0x2194
0x000000006ffffffe (VERNEED) 0x2314
0x000000006fffffff (VERNEEDNUM) 4
0x0000000000000000 (NULL) 0x0
0x0000000000000000 (NULL) 0x0
0x0000000000000000 (NULL) 0x0
0x0000000000000000 (NULL) 0x0
0x0000000000000000 (NULL) 0x0
0x0000000000000000 (NULL) 0x0


>  ldd /vendor/lib64/test_SampleOnnxruntime

        linux-vdso.so.1 => [vdso] (0x7b4ec5f000)
CANNOT LINK EXECUTABLE "linker64": cannot locate symbol "OrtGetApiBase" referenced by "/vendor/lib64/test_SampleOnnxruntime"...

@skottmckay
Copy link
Contributor

Given the output from libonnxruntime.so shows that symbol to be defined and global, that strongly suggests your app is not actually linking against it correctly.

I would suggest closely checking the link command to make sure the path to the onnxruntime library is correct and that it is being linked at the correct time. i.e. must be later in the link list than the code that is using ORT, otherwise when libonnxruntime.so is linked there will be no usage of OrtGetApiBase yet and the library will be ignored.

@w11m
Copy link
Author

w11m commented Nov 17, 2023

@skottmckay
I don't know why the enviroment mess with version 1.12.1 and 1.16.2
do linked with liboonxruntime.so but keep with old version, now fixed.

Now only need modified code due to API changed with version upgrade, close the issue first.
Thanks for the support.

@w11m w11m closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:mobile issues related to ONNX Runtime mobile; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants