From f57c2acc4690051dca45d4e48e2d403123c01f59 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Sun, 29 Oct 2017 17:24:13 +0100 Subject: [PATCH] sed for mach_32 --- nm-otool/.gitignore | 6 +++++- nm-otool/Makefile | 30 ++++++++++++++++++++---------- nm-otool/tests/compile.sh | 3 +++ nm-otool/tests/test_facile.c | 2 ++ nm-otool/tests/test_moins_facile.c | 3 +++ 5 files changed, 33 insertions(+), 11 deletions(-) create mode 100755 nm-otool/tests/compile.sh create mode 100644 nm-otool/tests/test_facile.c create mode 100644 nm-otool/tests/test_moins_facile.c diff --git a/nm-otool/.gitignore b/nm-otool/.gitignore index 4b26ffcc..03325401 100644 --- a/nm-otool/.gitignore +++ b/nm-otool/.gitignore @@ -1,3 +1,7 @@ ft_nm ft_otool -tests +srcs/mach_32 +includes/mach_32.h +tests/* +!tests/*.c +!tests/*.sh diff --git a/nm-otool/Makefile b/nm-otool/Makefile index 5a294e01..814198a0 100644 --- a/nm-otool/Makefile +++ b/nm-otool/Makefile @@ -34,15 +34,21 @@ NM_OBJ = $(OBJ_DIR)ft_nm.o OTOOL_OBJ = $(OBJ_DIR)ft_otool.o SRC_BASE = \ -dump_symtab.c\ -ft_nm.c\ ft_otool.c\ -mach_64/mach_64.c\ -mach_64/symbol_64_filter.c\ -mach_64/symbol_64_format.c\ -mach_64/symbol_64_free.c\ mach_64/symbol_64_init.c\ -mach_64/symbol_64_sort.c +mach_64/symbol_64_filter.c\ +mach_64/symbol_64_sort.c\ +mach_64/mach_64.c\ +mach_64/symbol_64_free.c\ +mach_64/symbol_64_format.c\ +mach_32/symbol_32_free.c\ +mach_32/symbol_32_sort.c\ +mach_32/mach_32.c\ +mach_32/symbol_32_format.c\ +mach_32/symbol_32_filter.c\ +mach_32/symbol_32_init.c\ +ft_nm.c\ +dump_symtab.c SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE)) OBJS = $(addprefix $(OBJ_DIR), $($(notdir SRC_BASE):.c=.o)) @@ -52,16 +58,20 @@ NB = $(words $(SRC_BASE)) INDEX = 0 MACH_64_SRC := $(wildcard $(SRC_DIR)mach_64/*) -MACH_SRC := $(subst _64,_32, $(MACH_64_SRC:.c=.p)) +MACH_64_SRC += $(INC_DIR)mach_64.h +MACH_SRC := $(subst _64,_32, $(MACH_64_SRC)) -all: $(MACH_SRC) +SHELL := /bin/bash + +all: @make -C $(LIBFT_DIR) @make -j $(NAME) # $(SRC_DIR)/mach/%.c: $(SRC_DIR)/mach_64/%.c $(MACH_SRC): - @mkdir -p $(SRC_DIR)/mach + @mkdir -p $(SRC_DIR)/mach_32 @echo "$@ ---> $(subst _32,_64, $@)" + @sed s/_64/_32/g $(subst _32,_64, $@) > $@ ft_nm: $(LIBFT_LIB) $(OBJ_DIR) $(OBJS) $(NM_OBJ) @$(CC) $(OBJS) -o $@ \ diff --git a/nm-otool/tests/compile.sh b/nm-otool/tests/compile.sh new file mode 100755 index 00000000..0dc4e1d1 --- /dev/null +++ b/nm-otool/tests/compile.sh @@ -0,0 +1,3 @@ +gcc test_facile.c -o test_facile +gcc test_moins_facile.c -o test_moins_facile +gcc -m32 test_moins_facile.c -o test_moins_facile_32-bit diff --git a/nm-otool/tests/test_facile.c b/nm-otool/tests/test_facile.c new file mode 100644 index 00000000..3417f85b --- /dev/null +++ b/nm-otool/tests/test_facile.c @@ -0,0 +1,2 @@ +#include +int main(void) { puts("Test facile"); return (0); } diff --git a/nm-otool/tests/test_moins_facile.c b/nm-otool/tests/test_moins_facile.c new file mode 100644 index 00000000..62150ae0 --- /dev/null +++ b/nm-otool/tests/test_moins_facile.c @@ -0,0 +1,3 @@ + #include +int une_globale = 40; +int main(void) { printf("La globale vaut: %d\n", une_globale); return (0); }