-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I14d027a72e8f2f5f745f14e8fe3f391938217220
- Loading branch information
1 parent
0ced022
commit d1032f5
Showing
28 changed files
with
3,126 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The patch should be applied to commit da39c3c96f32ca2fc693926a4b24ba62f3b672c0 | ||
of the repository http://llvm.org/git/clang.git | ||
|
||
Alternatively, check out https://github.com/chrisdiamand/clang.git |
26 changes: 26 additions & 0 deletions
26
patches/dwarfidl/0001-Make-sure-the-library-is-copied-to-lib-before-printe.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 72af0fad9558bed28cbacaa25172c337c75b875f Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Fri, 12 Dec 2014 09:57:02 +0000 | ||
Subject: [PATCH] Make sure the library is copied to lib/ before printer is | ||
built. | ||
|
||
--- | ||
Makefile | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/Makefile b/Makefile | ||
index 6edb310..587f1d8 100644 | ||
--- a/Makefile | ||
+++ b/Makefile | ||
@@ -9,7 +9,7 @@ src: parser | ||
$(MAKE) -C src | ||
|
||
.PHONY: printer | ||
-printer: src | ||
+printer: src lib | ||
$(MAKE) -C printer | ||
|
||
lib: src | ||
-- | ||
2.1.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The patches in merged_upstream/ have already been merged to: | ||
https://github.com/stephenrkell/liballocs | ||
|
||
The patches in the patches/ directory have not yet been merged, so need to be | ||
applied manually on top of commit 4a6c3d4. | ||
|
||
Alternatively, check out the repository here: | ||
$ git clone https://github.com/chrisdiamand/liballocs.git |
51 changes: 51 additions & 0 deletions
51
patches/liballocs/merged_upstream/0001-Add-.gitignore-file.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
From f10cae52dfa198889962b88737a84cffb3b02d5d Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Sat, 27 Dec 2014 23:14:56 +0000 | ||
Subject: [PATCH 1/4] Add '.gitignore' file. | ||
|
||
--- | ||
.gitignore | 32 ++++++++++++++++++++++++++++++++ | ||
1 file changed, 32 insertions(+) | ||
create mode 100644 .gitignore | ||
|
||
diff --git a/.gitignore b/.gitignore | ||
new file mode 100644 | ||
index 0000000..2102cd4 | ||
--- /dev/null | ||
+++ b/.gitignore | ||
@@ -0,0 +1,32 @@ | ||
+*.a | ||
+*.allocstubs.c | ||
+*.allocstubs.s | ||
+*.cil.c | ||
+*.cil.i | ||
+*.cil.s | ||
+*.cma | ||
+*.cmi | ||
+*.cmo | ||
+*.cmx | ||
+*.cmxs | ||
+*.d | ||
+*.i | ||
+*.i.allocs | ||
+*.o | ||
+*.o.fixuplog | ||
+*.pyc | ||
+*.so | ||
+*.swp | ||
+tests/alloca/alloca | ||
+tests/offsetof/offsetof | ||
+tests/section-group/section-group | ||
+tests/simple-client/simple-client | ||
+tests/simple-multi-alloc/simple-multi-alloc | ||
+tests/sloppy-dumptypes/sloppy-dumptypes | ||
+tools/allocsites | ||
+tools/dumptypes | ||
+tools/ifacetypes | ||
+tools/find-allocated-type-size | ||
+tools/lang/c/bin | ||
+tools/lang/c/src/base-types-translation | ||
+tools/usedtypes | ||
-- | ||
2.1.4 | ||
|
76 changes: 76 additions & 0 deletions
76
...s/liballocs/merged_upstream/0002-Use-DEBUG-enviromenment-variable-to-control-builds.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
From 1f215c55fdb62967568d827b7592d5a71dad23b3 Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Tue, 30 Dec 2014 23:24:49 +0000 | ||
Subject: [PATCH 2/4] Use DEBUG enviromenment variable to control builds. | ||
|
||
Don't add `-DNDEBUG' to CFLAGS, and disable optimisation, when DEBUG=1. | ||
--- | ||
src/Makefile | 48 +++++++++++++++++++++++++++--------------------- | ||
1 file changed, 27 insertions(+), 21 deletions(-) | ||
|
||
diff --git a/src/Makefile b/src/Makefile | ||
index f8c71b3..445b5f2 100644 | ||
--- a/src/Makefile | ||
+++ b/src/Makefile | ||
@@ -13,31 +13,37 @@ HOOKS_WRAP_OBJS := heap_index_hooks_fast.o malloc_hook_stubs_wrap_fast.o event_h | ||
|
||
CFLAGS += -std=gnu99 -g -I../include -I$(SRCROOT)/include -I$(MALLOC_HOOKS) | ||
|
||
-# STRANGE: this | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -flto -O4 # note! no -DNDEBUG | ||
-# is slower than the following (4.61, 4.54, 4.60) | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -O0 -finline-functions | ||
-# ; what about this? it's the same or slightly slower | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -O4 -flto -finline-functions -DNDEBUG | ||
-# what about this one? makes little difference | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -O4 -flto -DNDEBUG | ||
-# what about this one? same or slightly slower | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -Os -flto -DNDEBUG | ||
-# what about this one? slightly faster | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -O0 -DNDEBUG | ||
-# what about this one? among the fastest (4.52, 4.50, 4.51) | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -O3 -DNDEBUG | ||
-# really double-check that the following isn't faster? nope (4.64, 4.64, 4.59) | ||
-#DEFAULT_EXTRA_CFLAGS := -fPIC -O4 -flto -DNDEBUG | ||
- | ||
-# Summary of the above: -fPIC -O3 -DNDEBUG is the fastest | ||
-DEFAULT_EXTRA_CFLAGS := -fPIC -O3 -DNDEBUG | ||
+ifeq ($(DEBUG),1) | ||
+ DEFAULT_EXTRA_CFLAGS := -fPIC -g | ||
+else | ||
+ # STRANGE: this | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -flto -O4 # note! no -DNDEBUG | ||
+ # is slower than the following (4.61, 4.54, 4.60) | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -O0 -finline-functions | ||
+ # ; what about this? it's the same or slightly slower | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -O4 -flto -finline-functions -DNDEBUG | ||
+ # what about this one? makes little difference | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -O4 -flto -DNDEBUG | ||
+ # what about this one? same or slightly slower | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -Os -flto -DNDEBUG | ||
+ # what about this one? slightly faster | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -O0 -DNDEBUG | ||
+ # what about this one? among the fastest (4.52, 4.50, 4.51) | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -O3 -DNDEBUG | ||
+ # really double-check that the following isn't faster? nope (4.64, 4.64, 4.59) | ||
+ #DEFAULT_EXTRA_CFLAGS := -fPIC -O4 -flto -DNDEBUG | ||
+ | ||
+ # Summary of the above: -fPIC -O3 -DNDEBUG is the fastest | ||
+ DEFAULT_EXTRA_CFLAGS := -fPIC -O3 -DNDEBUG | ||
+endif | ||
|
||
default: liballocs_preload.so liballocs_nonshared.a liballocs_noop.so liballocs_noop.a liballocs_noop.o liballocs.a | ||
|
||
NON_FAST_CFLAGS += -fPIC -DTRACE_MALLOC_HOOKS -DTRACE_HEAP_INDEX #-DTRACE_DEEP_HEAP_INDEX | ||
-FAST_CFLAGS += -fpic -flto -ffat-lto-objects -O4 -DNDEBUG | ||
-#FAST_CFLAGS += -fpic -O3 -DNDEBUG | ||
+FAST_CFLAGS += -fpic -flto -ffat-lto-objects | ||
+ifneq ($(DEBUG),1) | ||
+ FAST_CFLAGS += -O4 -DNDEBUG | ||
+endif | ||
|
||
# regardless of fast/non-fast CFLAGS, link with -Wl,-O2 -flto | ||
LDFLAGS += -Wl,-O2 -flto -Bsymbolic-functions -fPIC | ||
-- | ||
2.1.4 | ||
|
26 changes: 26 additions & 0 deletions
26
patches/liballocs/merged_upstream/0003-tests-Remove-.so-and-others-in-clean-target.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 0803976430af13d033f3023dc4020d2f86a067c5 Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Sun, 8 Feb 2015 01:43:12 +0000 | ||
Subject: [PATCH 3/4] tests: Remove *.so (and others) in 'clean' target. | ||
|
||
Otherwise section-group/lib[1|2].so aren't rebuilt, which causes problems if | ||
the allocsites data has been removed. | ||
--- | ||
tests/Makefile | 4 +++- | ||
1 file changed, 3 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/tests/Makefile b/tests/Makefile | ||
index 28a5da1..e86ac91 100644 | ||
--- a/tests/Makefile | ||
+++ b/tests/Makefile | ||
@@ -119,4 +119,6 @@ default: | ||
# generic clean rule that we can run from test dirs too (with $(MAKE) -f ../Makefile) | ||
clean: # (delete anything whose name is a prefix of a .c file's and doesn't contain a dot) | ||
rm -f $(filter-out .,$(patsubst %.c,%,$(shell find -name '*.c'))) | ||
- find -name '*.cil.*' -o -name '*.i' -o -name '*.o' -o -name '*.s' -o -name '*.allocs' | xargs rm -f | ||
+ find -name '*.cil.*' -o -name '*.i' -o -name '*.o' -o \ | ||
+ -name '*.s' -o -name '*.allocs' -o -name '*.so' -o \ | ||
+ -name '*.allocstubs.c' -o -name '*.fixuplog' | xargs rm -f | ||
-- | ||
2.1.4 | ||
|
28 changes: 28 additions & 0 deletions
28
patches/liballocs/merged_upstream/0004-Print-message-if-dlopen-fails.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
From 112cd53497573bd9e41e3976d6bb1f4599e77757 Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Sun, 8 Feb 2015 01:50:09 +0000 | ||
Subject: [PATCH 4/4] Print message if dlopen() fails. | ||
|
||
--- | ||
src/liballocs.c | 5 ++++- | ||
1 file changed, 4 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/liballocs.c b/src/liballocs.c | ||
index 46d754f..12ccb39 100644 | ||
--- a/src/liballocs.c | ||
+++ b/src/liballocs.c | ||
@@ -943,7 +943,10 @@ static void *typeobj_handle_for_addr(void *caller) | ||
// dlopen the typeobj | ||
const char *types_libname = helper_libfile_name(dynobj_name_from_dlpi_name(info.dli_fname, info.dli_fbase), "-types.so"); | ||
assert(types_libname != NULL); | ||
- return dlopen(types_libname, RTLD_NOW | RTLD_NOLOAD); | ||
+ void *handle = dlopen(types_libname, RTLD_NOW | RTLD_NOLOAD); | ||
+ if (handle == NULL) | ||
+ printf("Error: %s\n", dlerror()); | ||
+ return handle; | ||
} | ||
|
||
void *__liballocs_my_typeobj(void) __attribute__((visibility("protected"))); | ||
-- | ||
2.1.4 | ||
|
24 changes: 24 additions & 0 deletions
24
patches/liballocs/patches/0001-relf.h-Make-sure-struct-link_map-is-defined.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
From 4ee5b75067dcd616d93cd4e16221eb6e17c535d4 Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Fri, 10 Apr 2015 17:55:00 +0100 | ||
Subject: [PATCH 01/11] relf.h: Make sure struct link_map is defined. | ||
|
||
--- | ||
include/relf.h | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/include/relf.h b/include/relf.h | ||
index ddea7e6..ead8242 100644 | ||
--- a/include/relf.h | ||
+++ b/include/relf.h | ||
@@ -1,6 +1,7 @@ | ||
#ifndef RELF_H_ | ||
#define RELF_H_ | ||
|
||
+#include <link.h> | ||
#include <stddef.h> /* for offsetof */ | ||
#include <elf.h> | ||
#include <string.h> | ||
-- | ||
2.1.4 | ||
|
25 changes: 25 additions & 0 deletions
25
patches/liballocs/patches/0002-Include-stdlib.h-before-using-free.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From d4b06bfb9e352fa063797481369db66518b68964 Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Mon, 30 Mar 2015 21:01:36 +0100 | ||
Subject: [PATCH 02/11] Include stdlib.h before using free(). | ||
|
||
--- | ||
include/memtable.h | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/include/memtable.h b/include/memtable.h | ||
index 18847c3..9f9f225 100644 | ||
--- a/include/memtable.h | ||
+++ b/include/memtable.h | ||
@@ -10,6 +10,8 @@ | ||
extern "C" { | ||
#endif | ||
|
||
+#include <stdlib.h> | ||
+ | ||
#if defined (X86_64) || (defined (__x86_64__)) | ||
#define BIGGEST_MMAP_ALLOWED (1ULL<<46) | ||
#else | ||
-- | ||
2.1.4 | ||
|
25 changes: 25 additions & 0 deletions
25
patches/liballocs/patches/0003-Use-c-gather-srcallocs-for-C99-Dwarf3-programs.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From 87ae696c9dad304811e673299dd33a62588efdfb Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Fri, 27 Mar 2015 00:30:04 +0000 | ||
Subject: [PATCH 03/11] Use c-gather-srcallocs for C99 (Dwarf3) programs. | ||
|
||
--- | ||
tools/gather-srcallocs.sh | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/tools/gather-srcallocs.sh b/tools/gather-srcallocs.sh | ||
index ad3b7a4..01066da 100755 | ||
--- a/tools/gather-srcallocs.sh | ||
+++ b/tools/gather-srcallocs.sh | ||
@@ -52,7 +52,7 @@ cat "$all_obj_allocs_file" | cut -f1 | sort | uniq | while read obj rest; do | ||
esac | ||
cu_language_num="$( echo "$cu_language_fullstr" | tr -s '[[:blank:]]' '\t' | cut -f1 )" | ||
case "$cu_language_num" in | ||
- (1|2) # DW_LANG_C89, DW_LANG_C | ||
+ (1|2|12) # DW_LANG_C89, DW_LANG_C, DW_LANG_C99 | ||
$(dirname "$0")/lang/c/bin/c-gather-srcallocs "$cu_sourcepath" "$obj" "$cu_fname" "$cu_compdir" | ||
;; | ||
(*) # unknown | ||
-- | ||
2.1.4 | ||
|
32 changes: 32 additions & 0 deletions
32
patches/liballocs/patches/0004-Find-i.allocs-file-when-the-source-isn-t-CIL-output.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From 66b70c1223c4c189f4fef5b7b305bd25d9f8039a Mon Sep 17 00:00:00 2001 | ||
From: Chris Diamand <chris@diamand.org> | ||
Date: Fri, 27 Mar 2015 00:25:44 +0000 | ||
Subject: [PATCH 04/11] Find i.allocs file when the source isn't CIL output. | ||
|
||
If it has been compiled with clang, there is no '%.cil.c' file. So if searching | ||
for '.cil.c' fails, try just searching for '.c'. | ||
--- | ||
tools/lang/c/bin/c-gather-srcallocs | 7 +++++++ | ||
1 file changed, 7 insertions(+) | ||
|
||
diff --git a/tools/lang/c/bin/c-gather-srcallocs b/tools/lang/c/bin/c-gather-srcallocs | ||
index fe67a71..ad3a8c8 100755 | ||
--- a/tools/lang/c/bin/c-gather-srcallocs | ||
+++ b/tools/lang/c/bin/c-gather-srcallocs | ||
@@ -10,6 +10,13 @@ cu_compdir="$4" | ||
test -n "$cu_compdir" || (echo "args: <sourcepath> <obj> <cu_fname> <cu_compdir>" 1>&2; false) || exit 1 | ||
|
||
cu_allocspath="$( echo "$cu_sourcepath" | grep '\.cil\.c$' | sed 's/\.cil\.c/.i.allocs/' )" | ||
+ | ||
+# If we're using clang instead of CIL then the source path will just be '%.c', | ||
+# not '%.cil.c'. | ||
+if [[ -z "$cu_allocspath" ]]; then | ||
+ cu_allocspath="$( echo "$cu_sourcepath" | grep '\.c$' | sed 's/\.c/.i.allocs/' )" | ||
+fi | ||
+ | ||
if [[ ! -r "$cu_allocspath" ]]; then | ||
echo "Warning: missing expected allocs file ($cu_allocspath) for source file: $cu_sourcepath" 1>&2 | ||
else | ||
-- | ||
2.1.4 | ||
|
Oops, something went wrong.