This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Compile elf/rtld.c with -fno-tree-loop-distribute-patterns.


On 11/23/19 6:25 AM, Florian Weimer wrote:
* Sandra Loosemore:

In GCC 10, the default at -O2 is now -ftree-loop-distribute-patterns.
This optimization causes GCC to "helpfully" convert the hand-written
loop in _dl_start into a call to memset, which is not available that
early in program startup.  Similar problems in other places in GLIBC
have been addressed by explicitly building with
-fno-tree-loop-distribute-patterns, but this one may have been
overlooked previously because it only affects targets where
HAVE_BUILTIN_MEMSET is not defined.

Thanks for pointing out this problem.

+# On targets without __builtin_memset, rtld.c uses a hand-coded loop
+# in _dl_start.  Make sure this isn't turned into a call to regular memset.
+ifeq (yes,$(have-loop-to-function))
+CFLAGS-rtld.c += -fno-tree-loop-distribute-patterns
+endif

Is it possible to do this via a pragma?  If I understand things
correctly, this is not necessary for PI_STATIC_AND_HIDDEN targets
(where initialization of the dynamic loader is simpler).

I see that the definitions of memset and memmove use "inhibit_loop_to_libcall" (which expands into an optimize attribute) to prevent recursion, but I didn't think the header where that is defined (include/libc-symbols.h) is supposed to be included in the dynamic linker? Also, already in elf/Makefile there is another instance where it adds -fno-tree-loop-distribute-patterns to the CFLAGS, so I just copied that. I don't work with glibc internals enough to have a good feel for what the preferred solution is but I'll test a different solution if this one isn't good enough.

-Sandra



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]