On 11/06/2016 19:12, Carlo Kok wrote:
On some (ubuntu 14.04.4, libc 2.19-0ubuntu6.9) systems I'm getting a sigsegv when casting the link_map's l_addr to Elf64_Ehdr. This is something libgc does and works fine on most linux systems, but not all.
What am I missing here, and if this isn't guaranteed to work, how else can I get all the loaded data segments.
Because _DYNAMIC is not an Elf64_Ehdr on all architectures. It is defined as:
elf/link.h
28 /* We use this macro to refer to ELF types independent of the native wordsize.
29 `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
30 #define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
31 #define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
32 #define _ElfW_1(e,w,t) e##w##t
[...]
76 extern ElfW(Dyn) _DYNAMIC[];