On Mon, Nov 21, 2022 at 3:49 AM Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Mon, Nov 21, 2022 at 12:22:32PM +0100, Thomas Neumann via Gcc-patches > wrote: > > > When dynamically linking a fast enough machine hides the latency, but when > > > Statically linking or on slower devices this change caused a 5x increase > > > in > > > Instruction count and 2x increase in cycle count before getting to main. > > > > > > This has been quite noticeable on smaller devices. Is there a reason the > > > btree > > > can't be initialized lazily? It seems a bit harsh to pay the cost of > > > unwinding at > > > startup even when you don't throw exceptions.. > > > > we cannot easily do that lazily because otherwise we need a mutex for lazy > > initialization, which is exactly what we wanted to get rid of. > > > > Having said that, I am surprised that you saw a noticeable difference. On > > most platforms there should not be dynamic frame registration at all, as the > > regular frames are directly read from the ELF data. > > > > Can you please send me an precise description on how to reproduce the issue? > > (Platform, tools, a VM if you have one would be great). I will then debug > > this to improve the startup time. > > I can see it being called as well for -static linked binaries. > -static links in crtbeginT.o which is libgcc/crtstuff.c built with > CRTSTUFFT_O macro being defined among other things, and that disables > USE_PT_GNU_EH_FRAME: > #if defined(OBJECT_FORMAT_ELF) \ > && !defined(OBJECT_FORMAT_FLAT) \ > && defined(HAVE_LD_EH_FRAME_HDR) \ > && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \ > && defined(__GLIBC__) && __GLIBC__ >= 2 > #include <link.h> > /* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h. > But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */ > # if !defined(__UCLIBC__) \ > && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ > || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) > # define USE_PT_GNU_EH_FRAME > # endif > #endif > > I think .eh_frame_hdr was never used for statically linked programs, > see already https://gcc.gnu.org/legacy-ml/gcc-patches/2001-12/msg01383.html > We don't pass --eh-frame-hdr when linking statically and dl_iterate_phdr > doesn't handle those. > Now, if -static -Wl,--eh-frame-hdr is passed when linking to the driver, > .eh_frame_hdr section is created and __GNU_EH_FRAME_HDR symbol points to > the start of that section, so at least that section could be found > if something in the crt files and libgcc is adjusted. But e.g. > i?86, nios2, frv and bfin we also need to find the got. Also, would it > work even for static PIEs? > > Jakub >
There is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54568 -- H.J.