Android header files define both Elf32_Nhdr and Elf64_Nhdr. The attached patch removes redefinition of the struct Reproducible: Always
Created attachment 89085 [details] Elf32_Nhdr.patch
I still encounter this problem. (patch works though)
(In reply to Chiu-Hsiang Hsu from comment #2) > I still encounter this problem. On what Android version?
(In reply to Julian Seward from comment #3) > (In reply to Chiu-Hsiang Hsu from comment #2) > > I still encounter this problem. > > On what Android version? compiling Valgrind with android-ndk-r10e-linux-x86_64.bin platform : android-21 ---- full compiling command : $ wget http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin $ chmod u+x android-ndk-r10e-linux-x86_64.bin $ ./android-ndk-r10e-linux-x86_64.bin $ export NDKROOT=/path/to/android-ndk-r10e # modify your path $ svn co svn://svn.valgrind.org/valgrind/trunk valgrind $ cd valgrind $ export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar $ export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld $ export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc $ ./autogen.sh $ CPPFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm" \ CFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm" \ ./configure --prefix=/data/local/Inst \ --host=armv7-unknown-linux --target=armv7-unknown-linux \ --with-tmpdir=/sdcard $ make -j8
If this is to be committed, it needs some kind of conditionalisation. For example, the patch causes the build to fail when using android-ndk-r6 and platform android-3: m_coredump/coredump-elf.c:158: error: 'Elf32_Nhdr' undeclared (first use in this function)
Created attachment 94205 [details] open Elf32_Nhdr definition only for Android API level less than 21 I try to keep the definition only for Android API level less than 21. Tested with android-ndk-r10e for platform android-3, android-19, android-21.
when NDK r15 ships, the unified headers will be the default, so all API levels will have this defined and dimitry's patch (that just removes this) will work, but chh's conditional patch will stop working then (even though it works with <= r14). in the AOSP tree we're basically carrying dimitry's patch, but it might make more sense for upstream to wait for r15 to ship (hopefully june/july).
Created attachment 120387 [details] Variant: only disable this on __clang__ Here is another patch that preserves the existing behavior unless __clang__ is defined. Building with clang only became the default in NDK r13, in late 2016.
I have got the same problem > m_coredump/coredump-elf.c:149:4: error: typedef redefinition with different types ('struct Elf32_Nhdr' vs 'struct elf32_note') > /home/xxx/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/linux/elf.h:370:3: note: previous definition is here On my Gentoo: > Linux maxmsi 5.7.19-gentoo #1 SMP Thu Sep 3 23:53:16 CEST 2020 x86_64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz GenuineIntel GNU/Linux Building on master: > commit 2471e0521da06200bd9d553b4d17750af2852bb0 > Author: Julian Seward <jseward@acm.org> > Date: Fri Oct 30 17:34:14 2020 +0100 > > arm64 front end: mark a couple of vector load/store insns as "verbose". Solved by commenting Elf32_Nhdr typedef in coregrind/m_coredump/coredump-elf.c The funny comment stays since: > 0ef7dc3c2f coregrind/m_coredump/coredump-elf.c (Julian Seward 2011-07-12 07:14:47 +0000 142) /* Android's libc doesn't provide a definition for this. Hence: */