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]

[PATCH] malloc: Compile with -fno-strict-aliasing


Not sure what the performance impact will be.  I think this will be
quite nasty for the heap protector.  But I don't see a way around this
with the current malloc.

Thanks,
Florian

malloc does this, among other things:

    To simplify use in double-linked lists, each bin header acts
    as a malloc_chunk. This avoids special-casing for headers.
    But to conserve space and improve locality, we allocate
    only the fd/bk pointers of bins, and then use repositioning tricks
    to treat these as the fields of a malloc_chunk*.

This violates GCC's strict aliasing rules.

2018-11-13  Florian Weimer  <fweimer@redhat.com>

	* malloc/Makefile (CFLAGS-malloc.c): Compile malloc.c if
	-fno-strict-aliasing due to aliasing violations.

diff --git a/malloc/Makefile b/malloc/Makefile
index 7d54bad866..a8cca0a4d6 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -171,6 +171,9 @@ include ../Rules
 CFLAGS-mcheck-init.c += $(PIC-ccflag)
 CFLAGS-obstack.c += $(uses-callbacks)
 
+# malloc.c contains many aliasing violations.
+CFLAGS-malloc.c += -fno-strict-aliasing
+
 $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
 	-rm -f $@
 	$(patsubst %/,cd % &&,$(objpfx)) \


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