aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile4
-rw-r--r--src/allocator.py6
-rw-r--r--src/allocators/glibc.py6
-rw-r--r--src/benchmark.py8
-rw-r--r--src/exec.c32
-rw-r--r--src/run_cmd.c18
6 files changed, 49 insertions, 25 deletions
diff --git a/src/Makefile b/src/Makefile
index 8a5e0a4..8d6d110 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,7 +15,7 @@ MEMSIZE=$(shell echo $(MEMSIZE_KB)"* 1024" | bc)
.PHONY: all clean
-all: $(OBJDIR)/print_status_on_exit.so $(OBJDIR)/allocators/bumpptr_alloc.so $(OBJDIR)/run_cmd
+all: $(OBJDIR)/print_status_on_exit.so $(OBJDIR)/allocators/bumpptr_alloc.so $(OBJDIR)/exec
$(OBJDIR)/allocators/bumpptr_alloc.so: bumpptr_alloc.c Makefile | $(OBJDIR)/allocators
@echo "Compiling $@...";
@@ -26,7 +26,7 @@ $(OBJDIR)/print_status_on_exit.so: print_status_on_exit.c Makefile | $(OBJDIR)
@echo "Compiling $@...";
$(CC) $(LDFLAGS) -shared $(CFLAGS) -o $@ $<
-$(OBJDIR)/run_cmd: run_cmd.c Makefile | $(OBJDIR)
+$(OBJDIR)/exec: exec.c Makefile | $(OBJDIR)
@echo "Compiling $@...";
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
diff --git a/src/allocator.py b/src/allocator.py
index 73f2777..ae22620 100644
--- a/src/allocator.py
+++ b/src/allocator.py
@@ -89,7 +89,8 @@ class Allocator_Sources (object):
class Allocator (object):
allowed_attributes = ["binary_suffix", "version", "sources", "build_cmds",
- "LD_PRELOAD", "cmd_prefix", "color", "patches"]
+ "LD_PRELOAD", "cmd_prefix", "color", "patches",
+ "LD_LIBRARY_PATH"]
def __init__(self, name, **kwargs):
self.name = name
@@ -151,7 +152,7 @@ class Allocator (object):
f.write(str(datetime.now().timestamp()))
print_info2("Create allocator dictionary")
- for attr in ["LD_PRELOAD", "cmd_prefix"]:
+ for attr in ["LD_PRELOAD", "LD_LIBRARY_PATH", "cmd_prefix"]:
value = getattr(self, attr, "") or ""
paths = {"dir": self.dir}
paths["srcdir"] = self.sources.dir if self.sources is not None else ""
@@ -162,6 +163,7 @@ class Allocator (object):
res_dict = {"cmd_prefix": self.cmd_prefix,
"binary_suffix": self.binary_suffix or "",
"LD_PRELOAD": self.LD_PRELOAD,
+ "LD_LIBRARY_PATH": self.LD_LIBRARY_PATH,
"color": self.color}
print_debug("Resulting dictionary:", res_dict)
return res_dict
diff --git a/src/allocators/glibc.py b/src/allocators/glibc.py
index 8ccd8a0..4f596ae 100644
--- a/src/allocators/glibc.py
+++ b/src/allocators/glibc.py
@@ -25,8 +25,10 @@ class Glibc (Allocator):
"cd glibc-build; make",
"cd glibc-build; make install"]
- kwargs["cmd_prefix"] = ("{dir}/lib/ld-linux-x86-64.so.2 --library-path {dir}/lib:"
- + library_path)
+ # kwargs["cmd_prefix"] = ("{dir}/lib/ld-linux-x86-64.so.2 --library-path {dir}/lib:"
+ # + library_path)
+
+ kwargs["LD_LIBRARY_PATH"] = "{dir}/lib:" + library_path
super().__init__(name, **kwargs)
diff --git a/src/benchmark.py b/src/benchmark.py
index fa99c65..c869061 100644
--- a/src/benchmark.py
+++ b/src/benchmark.py
@@ -293,6 +293,10 @@ class Benchmark (object):
env["LD_PRELOAD"] += " " + "build/print_status_on_exit.so"
env["LD_PRELOAD"] += " " + alloc["LD_PRELOAD"]
+ if "LD_LIBRARY_PATH" in alloc:
+ env["LD_LIBRARY_PATH"] = env.get("LD_LIBRARY_PATH", "")
+ env["LD_LIBRARY_PATH"] += ":" + alloc["LD_LIBRARY_PATH"]
+
self.start_servers(alloc_name=alloc_name, alloc=alloc, env=env)
# Preallocator hook
@@ -322,7 +326,9 @@ class Benchmark (object):
argv.extend(prefix_argv)
argv.extend(measure_argv)
- argv.extend(["build/run_cmd", env["LD_PRELOAD"]])
+ argv.extend(["build/exec", "-p", env["LD_PRELOAD"]])
+ if alloc["LD_LIBRARY_PATH"] != "":
+ argv.extend(["-l", env["LD_LIBRARY_PATH"]])
argv.extend(cmd_argv)
diff --git a/src/exec.c b/src/exec.c
new file mode 100644
index 0000000..37ef5b6
--- /dev/null
+++ b/src/exec.c
@@ -0,0 +1,32 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char* argv[]) {
+ if (argc < 3) {
+ printf("Usage: %s [-p LD_PRELOAD] [-l LD_LIBRARY_PATH] <cmd> [cmd args]\n");
+ printf("\tset LD_PRELOAD to ld_preload and call execvp <cmd> [cmd args]\n");
+ return 1;
+ }
+
+ int i = 1;
+ for (; i < argc; i++) {
+ // Overwrite LD_PRELOAD.
+ if (strncmp(argv[i], "-p", 2) == 0) {
+ setenv("LD_PRELOAD", argv[i+1], 1);
+ i++;
+ // Overwrite LD_LIBRARY_PATH.
+ } else if (strncmp(argv[i], "-l", 2) == 0) {
+ setenv("LD_LIBRARY_PATH", argv[i+1], 1);
+ i++;
+ } else {
+ break;
+ }
+ }
+
+
+ // Run cmd.
+ execvp(argv[i], &argv[i]);
+}
diff --git a/src/run_cmd.c b/src/run_cmd.c
deleted file mode 100644
index aa15964..0000000
--- a/src/run_cmd.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-int main(int argc, char* argv[]) {
- if (argc < 3) {
- printf("Usage: %s <ld_preload> <cmd> [cmd args]\n");
- printf("\tset LD_PRELOAD to ld_preload and call execvp <cmd> [cmd args]\n");
- return 1;
- }
-
- // Overwrite LD_PRELOAD.
- setenv("LD_PRELOAD", argv[1], 1);
-
- // Run cmd.
- execvp(argv[2], &argv[2]);
-}