# CTF is rebuilt independently.
ifeq ($(KBUILD_EXTMOD),)
+ctf-dir := .ctf
quiet_cmd_ctf = DWARF2CTF
- cmd_ctf = scripts/dwarf2ctf/dwarf2ctf objects.builtin modules.builtin scripts/dwarf2ctf/dedup.blacklist $^
+ cmd_ctf = scripts/dwarf2ctf/dwarf2ctf $(ctf-dir) objects.builtin modules.builtin scripts/dwarf2ctf/dedup.blacklist $^
builtins := $(shell cat objects.builtin 2>/dev/null)
ctf-stamp := .ctf/dtrace-ctf.stamp
kernel/dtrace/dtrace_ctf.ko: .ctf/dtrace-ctf.stamp
else
+ctf-dir := $(KBUILD_EXTMOD)/.ctf
quiet_cmd_ctf = DWARF2CTF
- cmd_ctf = scripts/dwarf2ctf/dwarf2ctf -e $^
+ cmd_ctf = scripts/dwarf2ctf/dwarf2ctf $(ctf-dir) -e $^
builtins :=
-ctf-stamp := .ctf/$(notdir $(M)-extmod).stamp
+ctf-stamp := $(ctf-dir)/$(notdir $(M)-extmod).stamp
endif
# All the modules' CTF likewise depends on the stamp file.
-all-module-ctfs = $(addprefix .ctf/,$(notdir $(modules:.ko=.mod.ctf)))
+all-module-ctfs = $(addprefix $(ctf-dir)/,$(notdir $(modules:.ko=.mod.ctf)))
$(all-module-ctfs): $(ctf-stamp)
# We depend upon a stamp file in lieu of the builtin modules' CTF files, because
$(ctf-stamp): $(builtins) $(modules:.ko=.o)
$(call if_changed,ctf)
@shopt -s nullglob; \
- for name in .ctf/*.ctf.new; do \
+ for name in $(ctf-dir)/*.ctf.new; do \
scripts/move-if-change $$name $${name%.new}; \
done
@touch $(ctf-stamp)
# Expands to the names of the CTF files to be incorporated into this module.
# The former is used in prerequisite lists, thanks to secondary expansion.
-module-ctfs-modular-prereq = $$(addprefix .ctf/,$$(notdir $$*.mod.ctf))
-module-ctfs-modular = $(addprefix .ctf/,$(notdir $*.mod.ctf))
+module-ctfs-modular-prereq = $$(addprefix $(ctf-dir)/,$$(notdir $$*.mod.ctf))
+module-ctfs-modular = $(addprefix $(ctf-dir)/,$(notdir $*.mod.ctf))
# Expands to the name of a CTF file, given a target of a module name given to
# one of the link rules below.
ifneq ($(CONFIG_MODULE_SIG),y)
-ctf-module-name = $(addprefix .ctf/,$(notdir $(basename $@)).mod.ctf)
+ctf-module-name = $(addprefix $(ctf-dir)/,$(notdir $(basename $@)).mod.ctf)
else
-ctf-module-name = $(addprefix .ctf/,$(notdir $(basename $(basename $@))).mod.ctf)
+ctf-module-name = $(addprefix $(ctf-dir)/,$(notdir $(basename $(basename $@))).mod.ctf)
endif
# Expands to a series of objcopy --add-section arguments to add all
module-ctf-flags = $(if $(filter dtrace_ctf.ko dtrace_ctf.ko.unsigned,$(notdir $@)), \
--strip-debug \
- $(foreach builtin,$(wildcard .ctf/*.builtin.ctf), \
+ $(foreach builtin,$(wildcard $(ctf-dir)/*.builtin.ctf), \
--add-section $(patsubst %.builtin.ctf,.dtrace_ctf.%,$(notdir $(builtin)))=$(builtin)), \
--add-section .dtrace_ctf=$(ctf-module-name))
# We have to put content in our dummy no-CTF files because --add-section
# in binutils 2.20 silently fails if asked to add an empty file as a section.
-cmd_touch_ctf = @for name in $(filter .ctf/%,$(module-ctfs-modular)); do \
+cmd_touch_ctf = @for name in $(filter $(ctf-dir)/%,$(module-ctfs-modular)); do \
test -f $$name || dd if=/dev/zero of=$$name bs=1 count=1 2>/dev/null; \
done
cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
$(LDFLAGS_$(modname)) -o $@.tmp \
- $(patsubst .ctf/%,,$(filter-out FORCE,$^)) && \
+ $(patsubst $(ctf-dir)/%,,$(filter-out FORCE,$^)) && \
$(OBJCOPY) $(module-ctf-flags) $@.tmp $@ && rm -f $@.tmp
$(modules): %.ko : %.o %.mod.o $(module-ctfs-modular-prereq) FORCE
* Run dwarf2ctf over a single object file or set thereof.
*
* starting_argv is the point in the argv array at which the arguments start.
+ * output_dir is the directory into which the CTF goes.
*/
-static void run(int starting_argv, char *argv[]);
+static void run(int starting_argv, char *argv[], char *output_dir);
/*
* A fully descriptive CTF type ID: both file and type ID in one place.
void *unused __unused__);
/*
- * Write out the CTF files from the module_to_ctf_file hashtable.
+ * Write out the CTF files from the module_to_ctf_file hashtable into files in
+ * the output_dir.
*/
-static void write_types(void);
+static void write_types(char *output_dir);
/*
* Construct CTF out of each type and return that type's ID and file.
int main(int argc, char *argv[])
{
- int starting_argv = 2;
+ int starting_argv = 3;
+ char *output_dir;
trace = getenv("DWARF2CTF_TRACE");
- if ((argc == 2 && (strcmp(argv[1], "-e") != 0)) || (argc < 3)) {
- fprintf(stderr, "Syntax: dwarf2ctf objects.builtin "
+ if ((argc == 3 && (strcmp(argv[1], "-e") != 0)) || (argc < 4)) {
+ fprintf(stderr, "Syntax: dwarf2ctf outputdir objects.builtin "
"modules.builtin vmlinux.o module.o...,\n");
- fprintf(stderr, " or dwarf2ctf -e module.o ... "
+ fprintf(stderr, " or dwarf2ctf outputdir -e module.o ... "
"for (inefficient)\n");
fprintf(stderr, "external module use\n");
exit(1);
}
+ output_dir = argv[1];
+
elf_version(EV_CURRENT);
if (elf_errno()) {
* at once, deduplicating them. In external-module mode, we act as if
* independently invoked with every argument.
*/
- if (strcmp(argv[1], "-e") != 0) {
+ if (strcmp(argv[2], "-e") != 0) {
char *builtin_objects_file;
char *builtin_module_file;
char *dedup_blacklist_file;
- builtin_objects_file = argv[1];
- builtin_module_file = argv[2];
- dedup_blacklist_file = argv[3];
- starting_argv = 4;
+ builtin_objects_file = argv[2];
+ builtin_module_file = argv[3];
+ dedup_blacklist_file = argv[4];
+ starting_argv = 5;
init_builtin(builtin_objects_file, builtin_module_file);
init_blacklist(dedup_blacklist_file);
- run(starting_argv, argv);
+ run(starting_argv, argv, output_dir);
} else {
char **name;
one_argv[0] = *name;
one_argv[1] = NULL;
- run(0, one_argv);
+ run(0, one_argv, output_dir);
}
}
* Run dwarf2ctf over a single object file or set thereof.
*
* starting_argv is the point in the argv array at which the arguments start.
+ * output_dir is the directory into which the CTF goes.
*/
-static void run(int starting_argv, char *argv[])
+static void run(int starting_argv, char *argv[], char *output_dir)
{
char **name;
* necessary linker scripts.
*/
dw_ctf_trace("Writeout.\n");
- write_types();
+ write_types(output_dir);
g_hash_table_destroy(id_to_type);
g_hash_table_destroy(id_to_module);
/* Writeout. */
-static void write_types(void)
+static void write_types(char *output_dir)
{
GHashTableIter module_iter;
char *module;
/*
* Work over all the modules and write their compressed CTF data out
- * into a new .ctf directory. Built-in modules get names ending in
+ * into the output directory. Built-in modules get names ending in
* .builtin.ctf.new; others get names ending in .mod.ctf.new. The
* makefile moves .ctf.new over the top of .ctf iff it has changed.
*/
- if ((mkdir(".ctf", 0777) < 0) && errno != EEXIST) {
+ if ((mkdir(output_dir, 0777) < 0) && errno != EEXIST) {
fprintf(stderr, "Cannot create .ctf directory: %s\n",
strerror(errno));
exit(1);
}
}
- path = str_appendn(path, ".ctf/", module,
+ path = str_appendn(path, output_dir, "/", module,
builtin_module ? ".builtin" : ".mod",
".ctf.new", NULL);