Unused DT record: type 0x1d arg

I am using android NDK- r10d to build the Android x86 executable (shared link) that runs on the adb shell. At runtime, I get the following warning:

WARNING: linker: ./myapp: **unused DT entry:** type 0x1d arg 0x4a604

I use the root Nexus Player to check the executable.

And my collector is Ubuntu 14.04 (also tried on a Fedora 14 machine).

+24
android-x86 android-ndk shared-libraries linker-warning
Oct 19 '15 at 3:56
source share
3 answers

What are unused DT records errors?

If you have reached this page, possibly because you have compiled or tried to run some executable files on your Android device based on the ARM system, as a result your binary file / application crashes or generates a lot of warnings in your logcat . Usually something like this:

 WARNING: linker: /blahblah/libopenssl.so: unused DT entry: type 0x6ffffffe arg 0x1188 

Q: What is a “DT record”?

In a few words, they are descriptive entries of an array in the ELF file structure file. In particular, they are known as Dynamic Array Tags and are requirements for executable and general objects. However, not all records are required or available, depending on the processor and kernel architecture.

In our case, we are faced with a "Warning" that one of them is "not used." This means that the executable or library ( *.so ) files were compiled with a DT record, but your kernel does not support this record for various reasons. The best examples can be found on the basis of the Android Android ARM system, in which the system library paths are fixed, and the cross-compilers used for your firmware (OS / kernel) do not use these entries. Normally, binaries still work fine, but the kernel puts this warning every time you use it.

Q: When does this happen?

This can happen if:

  • The ARM core is cross-compiled using the wrong flags (this usually applies to other processor architectures).
  • Your ARM binaries and libraries are compiled using legacy AOS compilation flags.
  • and possibly other methods have not yet been discovered.

Starting with version 5.1 (API 22), the Android linker warns about VERNEED and Dynamic sections of VERNEEDNUM ELF.

The most common flags causing this error on Android devices are:

 DT_RPATH 0x0f (15) The DT_STRTAB string table offset of a null-terminated library search path string. This element use has been superseded by DT_RUNPATH. DT_RUNPATH 0x1d (29) The DT_STRTAB string table offset of a null-terminated library search path string. DT_VERNEED 0x6ffffffe The address of the version dependency table. Elements within this table contain indexes into the string table DT_STRTAB. This element requires that the DT_VERNEEDNUM element also be present. DT_VERNEEDNUM 0x6fffffff The number of entries in the DT_VERNEEDNUM table. 

Tracking the above error, we find that this message comes from the bionic linker.cpp library:

  case DT_VERNEED: verneed_ptr_ = load_bias + d->d_un.d_ptr; break; case DT_VERNEEDNUM: verneed_cnt_ = d->d_un.d_val; break; case DT_RUNPATH: // this is parsed after we have strtab initialized (see below). break; default: if (!relocating_linker) { DL_WARN("\"%s\" unused DT entry: type %p arg %p", get_realpath(), reinterpret_cast<void*>(d->d_tag), reinterpret_cast<void*>(d->d_un.d_val)); } break; } 

Code (above) supporting this version control of characters was fixed on April 9, 2015 . Thus, if your NDK build is either configured to support the API earlier than this, or uses the build tools associated with this earlier library, you will receive these warnings.




Q: How do I know which DT records are used by my system or binary files?

There are many ways to do this:

  • You are studying kernel sources for <linux/elf.h> .
  • You look at your Android NDK installation folders and check:
 # To find all elf.h files: find /<path_to>/ndk/platforms/android-*/arch-arm*/usr/include/linux/ -iname "elf.h" 
  1. Make readelf your binary:
 $ readelf --dynamic libopenssl.so Dynamic section at offset 0x23b960 contains 28 entries: Tag Type Name/Value 0x00000003 (PLTGOT) 0x23ce18 0x00000002 (PLTRELSZ) 952 (bytes) 0x00000017 (JMPREL) 0x15e70 0x00000014 (PLTREL) REL 0x00000011 (REL) 0x11c8 0x00000012 (RELSZ) 85160 (bytes) 0x00000013 (RELENT) 8 (bytes) 0x6ffffffa (RELCOUNT) 10632 0x00000015 (DEBUG) 0x0 0x00000006 (SYMTAB) 0x148 0x0000000b (SYMENT) 16 (bytes) 0x00000005 (STRTAB) 0x918 0x0000000a (STRSZ) 1011 (bytes) 0x00000004 (HASH) 0xd0c 0x00000001 (NEEDED) Shared library: [libdl.so] 0x00000001 (NEEDED) Shared library: [libc.so] 0x0000001a (FINI_ARRAY) 0x238458 0x0000001c (FINI_ARRAYSZ) 8 (bytes) 0x00000019 (INIT_ARRAY) 0x238460 0x0000001b (INIT_ARRAYSZ) 16 (bytes) 0x00000020 (PREINIT_ARRAY) 0x238470 0x00000021 (PREINIT_ARRAYSZ) 0x8 0x0000001e (FLAGS) BIND_NOW 0x6ffffffb (FLAGS_1) Flags: NOW 0x6ffffff0 (VERSYM) 0x108c 0x6ffffffe (VERNEED) 0x1188 0x6fffffff (VERNEEDNUM) 2 0x00000000 (NULL) 0x0 

As you can see from the above error, type corresponds to DT_VERNEED .

From THIS document:

DT_RPATH

This element contains the offset of the row table for a zero-term search for a search string in the library, discussed in the Dependencies of Shared Objects section. The offset is the index into the table recorded in the DT_STRTAB record. DT_RPATH may contain a string containing a list of directories separated by colons (:). All LD_LIBRARY_PATH directories are executed after those of DT_RPATH.

Q: How do you solve or solve these problems?

There are 3 ways to deal with this:

  • quick
  • bad
  • ugly



Fast (you have no sources or just don’t have to worry)

Use the ELF Cleaner to remove offensive DT entries from all of your binaries. This is a quick and easy tool, especially when you don’t have the sources to recompile them correctly for your system. There are at least two cleaners that you can use.




Bad (do you have sources)

The right way to do this is because you will become the gurus of the ARM cross-compiler in the process. You basically need to find and configure the compiler options in the used Makefiles.

From here :

The Android lineup (/ system / bin / linker) does not support RPATH or RUNPATH, so we set LD_LIBRARY_PATH = $ USR / lib and try to avoid creating useless rpath entries using the --disable-rpath configuration flags. Another option that should be avoided depending on LD_LIBRARY_PATH would be to supply a custom linker - this is not done due to the overhead of maintaining the custom linker.




Ugly (you just want your application to work with any dirty binary.)

You tell your Java application not to worry when checking for a null value in error handlers and instead receive these warnings, possibly causing fatal exceptions. Use something like:

 class OpensslErrorThread extends Thread { @Override public void run() { try { while(true){ String line = opensslStderr.readLine(); if(line == null){ // OK return; } if(line.contains("unused DT entry")){ Log.i(TAG, "Ignoring \"unused DT entry\" error from openssl: " + line); } else { // throw exception! break; } } } catch(Exception e) { Log.e(TAG, "Exception!") } } } 

This is very bad and ugly, because it does not solve anything, it inflates your code. In addition, warnings exist for some reason, and that means that in future versions of AOS this will be a complete mistake!




Q. What else?

Many changes in the API between 18-25 (from J to N) were made in how the Android kernel and libraries were compiled. I cannot give a distant explanation of all this, but perhaps it will help you in the right direction. The best sources of course are by looking at Android sources and documentation.

For example, HERE or HERE .




And finally, the complete list:

 Name Value d_un Executable Shared Object --------------------------------------------------------------------------------------------- DT_NULL 0 Ignored Mandatory Mandatory DT_NEEDED 1 d_val Optional Optional DT_PLTRELSZ 2 d_val Optional Optional DT_PLTGOT 3 d_ptr Optional Optional DT_HASH 4 d_ptr Mandatory Mandatory DT_STRTAB 5 d_ptr Mandatory Mandatory DT_SYMTAB 6 d_ptr Mandatory Mandatory DT_RELA 7 d_ptr Mandatory Optional DT_RELASZ 8 d_val Mandatory Optional DT_RELAENT 9 d_val Mandatory Optional DT_STRSZ 0x0a (10) d_val Mandatory Mandatory DT_SYMENT 0x0b (11) d_val Mandatory Mandatory DT_INIT 0x0c (12) d_ptr Optional Optional DT_FINI 0x0d (13) d_ptr Optional Optional DT_SONAME 0x0e (14) d_val Ignored Optional DT_RPATH 0x0f (15) d_val Optional Optional DT_SYMBOLIC 0x10 (16) Ignored Ignored Optional DT_REL 0x11 (17) d_ptr Mandatory Optional DT_RELSZ 0x12 (18) d_val Mandatory Optional DT_RELENT 0x13 (19) d_val Mandatory Optional DT_PLTREL 0x14 (20) d_val Optional Optional DT_DEBUG 0x15 (21) d_ptr Optional Ignored DT_TEXTREL 0x16 (22) Ignored Optional Optional DT_JMPREL 0x17 (23) d_ptr Optional Optional DT_BIND_NOW 0x18 (24) Ignored Optional Optional DT_INIT_ARRAY 0x19 (25) d_ptr Optional Optional DT_FINI_ARRAY 0x1a (26) d_ptr Optional Optional DT_INIT_ARRAYSZ 0x1b (27) d_val Optional Optional DT_FINI_ARRAYSZ 0x1c (28) d_val Optional Optional DT_RUNPATH 0x1d (29) d_val Optional Optional DT_FLAGS 0x1e (30) d_val Optional Optional DT_ENCODING 0x1f (32) Unspecified Unspecified Unspecified DT_PREINIT_ARRAY 0x20 (32) d_ptr Optional Ignored DT_PREINIT_ARRAYSZ 0x21 (33) d_val Optional Ignored DT_MAXPOSTAGS 0x22 (34) Unspecified Unspecified Unspecified DT_LOOS 0x6000000d Unspecified Unspecified Unspecified DT_SUNW_AUXILIARY 0x6000000d d_ptr Unspecified Optional DT_SUNW_RTLDINF 0x6000000e d_ptr Optional Optional DT_SUNW_FILTER 0x6000000e d_ptr Unspecified Optional DT_SUNW_CAP 0x60000010 d_ptr Optional Optional DT_SUNW_SYMTAB 0x60000011 d_ptr Optional Optional DT_SUNW_SYMSZ 0x60000012 d_val Optional Optional DT_SUNW_ENCODING 0x60000013 Unspecified Unspecified Unspecified DT_SUNW_SORTENT 0x60000013 d_val Optional Optional DT_SUNW_SYMSORT 0x60000014 d_ptr Optional Optional DT_SUNW_SYMSORTSZ 0x60000015 d_val Optional Optional DT_SUNW_TLSSORT 0x60000016 d_ptr Optional Optional DT_SUNW_TLSSORTSZ 0x60000017 d_val Optional Optional DT_SUNW_CAPINFO 0x60000018 d_ptr Optional Optional DT_SUNW_STRPAD 0x60000019 d_val Optional Optional DT_SUNW_CAPCHAIN 0x6000001a d_ptr Optional Optional DT_SUNW_LDMACH 0x6000001b d_val Optional Optional DT_SUNW_CAPCHAINENT 0x6000001d d_val Optional Optional DT_SUNW_CAPCHAINSZ 0x6000001f d_val Optional Optional DT_HIOS 0x6ffff000 Unspecified Unspecified Unspecified DT_VALRNGLO 0x6ffffd00 Unspecified Unspecified Unspecified DT_CHECKSUM 0x6ffffdf8 d_val Optional Optional DT_PLTPADSZ 0x6ffffdf9 d_val Optional Optional DT_MOVEENT 0x6ffffdfa d_val Optional Optional DT_MOVESZ 0x6ffffdfb d_val Optional Optional DT_POSFLAG_1 0x6ffffdfd d_val Optional Optional DT_SYMINSZ 0x6ffffdfe d_val Optional Optional DT_SYMINENT 0x6ffffdff d_val Optional Optional DT_VALRNGHI 0x6ffffdff Unspecified Unspecified Unspecified DT_ADDRRNGLO 0x6ffffe00 Unspecified Unspecified Unspecified DT_CONFIG 0x6ffffefa d_ptr Optional Optional DT_DEPAUDIT 0x6ffffefb d_ptr Optional Optional DT_AUDIT 0x6ffffefc d_ptr Optional Optional DT_PLTPAD 0x6ffffefd d_ptr Optional Optional DT_MOVETAB 0x6ffffefe d_ptr Optional Optional DT_SYMINFO 0x6ffffeff d_ptr Optional Optional DT_ADDRRNGHI 0x6ffffeff Unspecified Unspecified Unspecified DT_RELACOUNT 0x6ffffff9 d_val Optional Optional DT_RELCOUNT 0x6ffffffa d_val Optional Optional DT_FLAGS_1 0x6ffffffb d_val Optional Optional DT_VERDEF 0x6ffffffc d_ptr Optional Optional DT_VERDEFNUM 0x6ffffffd d_val Optional Optional DT_VERNEED 0x6ffffffe d_ptr Optional Optional DT_VERNEEDNUM 0x6fffffff d_val Optional Optional DT_LOPROC 0x70000000 Unspecified Unspecified Unspecified DT_SPARC_REGISTER 0x70000001 d_val Optional Optional DT_AUXILIARY 0x7ffffffd d_val Unspecified Optional DT_USED 0x7ffffffe d_val Optional Optional DT_FILTER 0x7fffffff d_val Unspecified Optional DT_HIPROC 0x7fffffff Unspecified Unspecified Unspecified 
+67
Jan 27 '17 at 18:20
source share

With readelf -d, you can specify DT entries in your binary format:

  0x0000001d (RUNPATH) Library runpath: [lib] 

As you can see, 0x1d corresponds to RUNPATH. This entry is added with the linker parameter -rpath (or -R if you follow the directory)

+7
Jan 04 '16 at 10:29
source share

WARNING: linker: /data/data/com.gmail.heagoo.apkeditor.pro/files/bin/aapt: unused DT record: enter 0x6ffffffe arg 0x1eb4 WARNING: linker: /data/data/com.gmail.heagoo.apkeditor. pro / files / bin / aapt: unused DT record: enter 0x6fffffff arg 0x2 / data / data / com.gmail.heagoo.apkeditor.pro / files / decoded / AndroidManifest.xml: 2: error: resource identifier not found for attribute ' compileSdkVersion 'in package' android '

/data/data/com.gmail.heagoo.apkeditor.pro/files/decoded/AndroidManifest.xml:2: error: resource identifier not found for attribute 'compileSdkVersionCodename' in package 'android'

/data/data/com.gmail.heagoo.apkeditor.pro/files/decoded/AndroidManifest.xml:18: error: the resource identifier was not found for the attribute 'appComponentFactory' in the package 'android'

0
May 05 '19 at 9:14
source share



All Articles