I'm using gcc 8.2.0 with binutils 2.31.1 to build my dietlibc (www.fefe.de/dietlibc/, use CVS version to reproduce). Part of the startup code of my libc goes through auxvec to find PT_TLS and then initialize the thread local storage. Now, this code worked fine for years. When I make clean and build with the above mentioned versions, I get a segfault in the AT_PHDR traversal, because AT_PHDR points to 0x400040 but /proc/pid/maps says: 00401000-00404000 r-xp 00001000 08:12 19664433 And indeed, readelf on the binary shows that: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000001000 0x0000000000401000 0x0000000000401000 0x00000000000021e7 0x00000000000021e7 R E 0x1000 So the kernel did as it was told and loaded starting from 1000. My current understanding is that I did it right and this is a bug in binutils to put the wrong value in the ELF header. Am I wrong? How else am I supposed to access the PHDR? Or maybe I am supposed to find the thread local storage data some other way? Please advise.
Dup. *** This bug has been marked as a duplicate of bug 23428 ***
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a788aedd86da983faf0afef3cb41461118a2e9f2 commit a788aedd86da983faf0afef3cb41461118a2e9f2 Author: Alan Modra <amodra@gmail.com> Date: Mon Jan 13 22:30:46 2020 +1030 PR23560, PR23561, readelf memory leaks PR 23560 PR 23561 * dwarf.c (display_debug_frames): Move fde_fc earlier. Free fde_fc col_type and col_offset. * readelf.c (apply_relocations): Move symsec check earlier. (free_debug_section): Free reloc_info. (process_notes_at): Free pnotes on error path. (process_object): Free dump_sects here.. (process_archive): ..not here.