From: Teng Qin Date: Thu, 9 Nov 2017 06:11:33 +0000 (-0800) Subject: Add parsing for indirect functions X-Git-Tag: v2017.11.13.00~11 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;ds=sidebyside;h=bb8d886a25225b1811f2fc890c8f77b59c1d1578;p=folly.git Add parsing for indirect functions Summary: Currently `folly::symbolizer`'s `getDefinitionByAddress` and `getSymbolByName` only parses `STT_OBJECT` and `STT_FUNC`. There are some standar library functions that uses the GNU indirect function feature that would have been missed: ==== For libpthread-2.23.so: ====== Symbol system Addr 119d0 Size 8 is a STT_GNU_IFUNC ====== Symbol siglongjmp Addr 10700 Size 8 is a STT_GNU_IFUNC ====== Symbol longjmp Addr 10700 Size 8 is a STT_GNU_IFUNC ====== Symbol __vfork Addr 10af0 Size 8 is a STT_GNU_IFUNC ====== Symbol vfork Addr 10af0 Size 8 is a STT_GNU_IFUNC ====== Symbol system_ifunc Addr 119d0 Size 8 is a STT_GNU_IFUNC ====== Symbol longjmp_ifunc Addr 10700 Size 8 is a STT_GNU_IFUNC ====== Symbol vfork_ifunc Addr 10af0 Size 8 is a STT_GNU_IFUNC ====== Symbol siglongjmp_ifunc Addr 10700 Size 8 is a STT_GNU_IFUNC ====== Symbol __vfork_ifunc Addr 10af0 Size 8 is a STT_GNU_IFUNC ====== Symbol __vfork@GLIBC_2.2.5 Addr 10af0 Size 8 is a STT_GNU_IFUNC ====== Symbol siglongjmp@GLIBC_2.2.5 Addr 10700 Size 8 is a STT_GNU_IFUNC ====== Symbol vfork@GLIBC_2.2.5 Addr 10af0 Size 8 is a STT_GNU_IFUNC ====== Symbol system@GLIBC_2.2.5 Addr 119d0 Size 8 is a STT_GNU_IFUNC ====== Symbol longjmp@GLIBC_2.2.5 Addr 10700 Size 8 is a STT_GNU_IFUNC ==== For libc-2.23.so: ====== Symbol __gettimeofday Addr c05e0 Size a8 is a STT_GNU_IFUNC ====== Symbol strcpy Addr 8e150 Size 35 is a STT_GNU_IFUNC ====== Symbol wmemcmp Addr afb50 Size 37 is a STT_GNU_IFUNC ====== Symbol strncmp Addr 8eb30 Size 41 is a STT_GNU_IFUNC ====== Symbol stpncpy Addr 929f0 Size 35 is a STT_GNU_IFUNC ====== Symbol __mempcpy_chk Addr 11cec0 Size 68 is a STT_GNU_IFUNC ====== Symbol strncpy Addr 903d0 Size 35 is a STT_GNU_IFUNC ====== Symbol time Addr c0500 Size a8 is a STT_GNU_IFUNC ====== Symbol strpbrk Addr 90700 Size 22 is a STT_GNU_IFUNC ====== Symbol strspn Addr 90a80 Size 22 is a STT_GNU_IFUNC ====== Symbol __stpncpy Addr 929f0 Size 35 is a STT_GNU_IFUNC ====== Symbol __strcasecmp Addr 92a80 Size 54 is a STT_GNU_IFUNC ====== Symbol memset Addr 92230 Size 41 is a STT_GNU_IFUNC ====== Symbol strstr Addr 916b0 Size 21 is a STT_GNU_IFUNC ====== Symbol strcspn Addr 8e270 Size 22 is a STT_GNU_IFUNC ====== Symbol memcmp Addr 91c40 Size 37 is a STT_GNU_IFUNC ====== Symbol mempcpy Addr 923b0 Size 68 is a STT_GNU_IFUNC And 80 more... This Diff adds parsing for `STT_GNU_IFUNC` symbols as well Reviewed By: yfeldblum Differential Revision: D6282727 fbshipit-source-id: 71b7c44831e4ddfdccf1e794cb86e049e14227bc --- diff --git a/folly/experimental/symbolizer/Elf.cpp b/folly/experimental/symbolizer/Elf.cpp index 7be8f69d..071f1b43 100644 --- a/folly/experimental/symbolizer/Elf.cpp +++ b/folly/experimental/symbolizer/Elf.cpp @@ -28,6 +28,10 @@ #include #include +#ifndef STT_GNU_IFUNC +#define STT_GNU_IFUNC 10 +#endif + namespace folly { namespace symbolizer { @@ -361,7 +365,7 @@ ElfFile::Symbol ElfFile::getDefinitionByAddress(uintptr_t address) const { }; return iterateSymbolsWithTypes( - section, {STT_OBJECT, STT_FUNC}, findSymbols); + section, {STT_OBJECT, STT_FUNC, STT_GNU_IFUNC}, findSymbols); }; // Try the .dynsym section first if it exists, it's smaller. @@ -400,7 +404,7 @@ ElfFile::Symbol ElfFile::getSymbolByName(const char* name) const { }; return iterateSymbolsWithTypes( - section, {STT_OBJECT, STT_FUNC}, findSymbols); + section, {STT_OBJECT, STT_FUNC, STT_GNU_IFUNC}, findSymbols); }; // Try the .dynsym section first if it exists, it's smaller.