On Sun, Nov 27, 2016 at 03:20:26AM +0000, David Holland wrote: > While discussing the Emacs problems with Joerg (see PR 51654 for the > gory details) the conclusion we came to is that the best real fix (as > opposed to the workaround of disabling ASLR) is to shift the > __ps_strings global from crt0 to libc; then it won't be referenced > directly by programs, won't be in the linked program's BSS, and won't > be accidentally saved when Emacs dumps. Instead, libc will provide a > private entry point to assign the value of __ps_strings. (This also > turns out to simplify the piece of libc initialization that is > crashing Emacs.)
The function calls don't really help as libc has to support old crt0.o anyway. Ignoring compat, there is no need for three different calls, just provide a way to pass down __ps_strings. The other two variables are derived from it anyway. That was the reason why ___start no longer takes as many arguments. > - I put declarations for the hooks in unistd.h. I'd rather use a > private header so they aren't exposed, but there isn't currently one > shared by libc and crt0. Should I set one up? There is the precedence case with rtld.h. > - I put the hooks in the .text.startup section like _libc_init but > I'm not sure if that's actually appropriate -- what is and isn't > supposed to go in .text.startup? It's basically a subsection for functions used only once during initial startup, so that the linker can try to group them together to avoid wasting TLB space etc. Joerg
