From 401e4c571d813a34034d3079423dc71d5d83f94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <m.kroening@hotmail.de> Date: Fri, 26 Apr 2019 15:59:20 +0200 Subject: [PATCH] Remove trailing blank characters --- basics/asm/Makefile | 38 +++++++++++++------------- basics/asm/asmfunc.asm | 8 +++--- basics/asm/main.asm | 2 +- basics/c/Makefile | 38 +++++++++++++------------- basics/c/asmfunc.asm | 8 +++--- basics/einfach/Makefile | 36 ++++++++++++------------- basics/einfach/halloWelt.c | 8 +++--- chapter2/maximum/Makefile | 40 ++++++++++++++-------------- chapter2/maximum/main.asm | 16 +++++------ chapter2/mergesort/v1/Makefile | 6 ++--- chapter2/mergesort/v2/Makefile | 6 ++--- chapter2/mergesort/v2/main.c | 2 +- chapter2/pi/fpu/Makefile | 40 ++++++++++++++-------------- chapter2/pi/fpu/main.asm | 6 ++--- chapter2/pi/fpu64/Makefile | 40 ++++++++++++++-------------- chapter2/pi/fpu64/main.asm | 8 +++--- chapter2/pi/v1/Makefile | 6 ++--- chapter2/pi/v1/main.go | 4 +-- chapter2/pi/v2/Makefile | 6 ++--- chapter2/pi/v3/Makefile | 6 ++--- chapter2/pi/v4/Makefile | 6 ++--- chapter2/pi/v4/main.c | 2 +- chapter2/pi/v5/Makefile | 6 ++--- chapter2/pi/v5/main.c | 2 +- chapter2/pi/v5/main.go | 4 +-- chapter2/pi/v6/Makefile | 4 +-- chapter2/pi/v6/calcPi_AVX.asm | 8 +++--- chapter2/pi/v6/calcPi_FPU.asm | 6 ++--- chapter2/pi/v6/calcPi_SSE.asm | 4 +-- chapter2/pi/v6/main.c | 2 +- chapter2/pi/v7/Makefile | 4 +-- chapter2/pi/v7/calcPi_SSE_thread.asm | 6 ++--- chapter2/pi/v7/main.c | 4 +-- chapter2/rounding_error/Makefile | 4 +-- chapter2/rounding_error/main.c | 2 +- chapter2/strcpy/string_copy.asm | 12 ++++----- chapter4/aslr/Makefile | 6 ++--- chapter4/aslr/aslr_demo.c | 4 +-- chapter4/shlib/ctest.c | 2 +- chapter4/shlib/prog.c | 10 +++---- 40 files changed, 211 insertions(+), 211 deletions(-) diff --git a/basics/asm/Makefile b/basics/asm/Makefile index 389fa30..f38200b 100644 --- a/basics/asm/Makefile +++ b/basics/asm/Makefile @@ -1,33 +1,33 @@ -#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles -# werden zur ausführbaren Datei "start" zusammengebunden! -MAKE = make -CC = gcc +#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles +# werden zur ausführbaren Datei "basic-asm" zusammengebunden! +MAKE = make +CC = gcc CFLAGS = -Wall -O0 -g #-pthread, nur für POSIX-Threads notwendig LDFLAGS = -static -RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen +RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen ASM = nasm ASMFLAGS = -f elf64 -O0 -g -F dwarf -NAME = start # Name des Programms/der ausführbaren Datei +NAME = start # Name des Programms/der ausführbaren Datei # Objekt-Datei-Liste generieren aus Quell-Datei-Listen -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) +OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) +OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) .PHONY: clean -# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< +# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< -%.o : %.asm - $(ASM) $(ASMFLAGS) -o $@ $< +%.o : %.asm + $(ASM) $(ASMFLAGS) -o $@ $< -all: - $(MAKE) $(NAME) +all: + $(MAKE) $(NAME) -$(NAME): $(OBJS) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(NAME) $(OBJS) +$(NAME): $(OBJS) + $(CC) $(LDFLAGS) $(CFLAGS) -o $(NAME) $(OBJS) -clean: - $(RM) *.o $(NAME) +clean: + $(RM) *.o $(NAME) diff --git a/basics/asm/asmfunc.asm b/basics/asm/asmfunc.asm index 9faff70..390c820 100644 --- a/basics/asm/asmfunc.asm +++ b/basics/asm/asmfunc.asm @@ -1,7 +1,7 @@ extern printf ; forward declaration of printf SECTION .data - msg db 'Hello from asmfunc!', 10, 0 + msg db 'Hello from asmfunc!', 10, 0 SECTION .text @@ -9,7 +9,7 @@ SECTION .text global asmfunc ; Funktionen implementieren -asmfunc: +asmfunc: push rbp ; neuer Stackframe erzeugen mov rbp, rsp @@ -18,7 +18,7 @@ asmfunc: ; set return value to 0 mov rax, 0 - + mov rsp, rbp ; alter Stackframe restaurieren - pop rbp + pop rbp ret ; zurueck zum Aufrufer diff --git a/basics/asm/main.asm b/basics/asm/main.asm index af5d815..d106299 100644 --- a/basics/asm/main.asm +++ b/basics/asm/main.asm @@ -20,7 +20,7 @@ main: ; ersetzt werden. call asmfunc - pop rbp ; alter Stackframe restaurieren + pop rbp ; alter Stackframe restaurieren ; Programm verlassen & signalisieren, ; dass bei bei der Ausführung kein Fehler diff --git a/basics/c/Makefile b/basics/c/Makefile index c7c78cb..b314f21 100644 --- a/basics/c/Makefile +++ b/basics/c/Makefile @@ -1,36 +1,36 @@ -#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles -# werden zur ausführbaren Datei "start" zusammengebunden! -MAKE = make -CC = gcc +#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles +# werden zur ausführbaren Datei "basic-c" zusammengebunden! +MAKE = make +CC = gcc CFLAGS = -Wall -O0 -g #-pthread, nur für POSIX-Threads notwendig LDFLAGS = -static -RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen -ASM = nasm +RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen +ASM = nasm ASMFLAGS = -f elf64 -O0 -g -F dwarf -NAME = start # Name des Programms/der ausführbaren Datei +NAME = start # Name des Programms/der ausführbaren Datei # Objekt-Datei-Liste generieren aus Quell-Datei-Listen -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) +OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) +OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) SRC = $(wildcard *.c) .PHONY: clean -# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< +# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< -%.o : %.asm - $(ASM) $(ASMFLAGS) -o $@ $< +%.o : %.asm + $(ASM) $(ASMFLAGS) -o $@ $< -all: - $(MAKE) $(NAME) +all: + $(MAKE) $(NAME) -$(NAME): $(OBJS) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(NAME) $(OBJS) +$(NAME): $(OBJS) + $(CC) $(LDFLAGS) $(CFLAGS) -o $(NAME) $(OBJS) -clean: +clean: $(RM) *.o $(NAME) depend: .depend diff --git a/basics/c/asmfunc.asm b/basics/c/asmfunc.asm index 862c416..47966e6 100644 --- a/basics/c/asmfunc.asm +++ b/basics/c/asmfunc.asm @@ -1,7 +1,7 @@ extern printf ; externe Funktion printf deklarieren SECTION .data - msg db 'Hello from asmfunc!', 10, 0 + msg db 'Hello from asmfunc!', 10, 0 SECTION .text @@ -9,7 +9,7 @@ SECTION .text global asmfunc ; Funktionen implementieren -asmfunc : +asmfunc : push rbp ; neuer Stackframe erzeugen mov rbp, rsp @@ -18,7 +18,7 @@ asmfunc : ; Rückgabewert auf 0 setzen mov eax, 0 - + mov rsp, rbp ; alter Stackframe restaurieren - pop rbp + pop rbp ret ; Ruecksprung zum Aufrufer diff --git a/basics/einfach/Makefile b/basics/einfach/Makefile index 4a97ec0..2e8d520 100644 --- a/basics/einfach/Makefile +++ b/basics/einfach/Makefile @@ -1,36 +1,36 @@ -#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles -# werden zur ausführbaren Datei "start" zusammengebunden! -MAKE = make -CC = gcc +#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles +# werden zur ausführbaren Datei "halloWelt" zusammengebunden! +MAKE = make +CC = gcc CFLAGS = -Wall -O0 -g #-pthread, nur für POSIX-Threads notwendig LDFLAGS = -static -RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen -ASM = nasm +RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen +ASM = nasm ASMFLAGS = -f elf64 -O0 -g -F dwarf -NAME = start # Name des Programms/der ausführbaren Datei +NAME = start # Name des Programms/der ausführbaren Datei # Objekt-Datei-Liste generieren aus Quell-Datei-Listen -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) +OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) +OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) SRC = $(wildcard *.c) .PHONY: clean -# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< +# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< -%.o : %.asm - $(ASM) $(ASMFLAGS) -o $@ $< +%.o : %.asm + $(ASM) $(ASMFLAGS) -o $@ $< -all: - $(MAKE) $(NAME) +all: + $(MAKE) $(NAME) -$(NAME): $(OBJS) +$(NAME): $(OBJS) $(CC) $(LDFLAGS) $(CFLAGS) -o $(NAME) $(OBJS) -clean: +clean: $(RM) *.o $(NAME) depend: .depend diff --git a/basics/einfach/halloWelt.c b/basics/einfach/halloWelt.c index 140fa6e..6910126 100644 --- a/basics/einfach/halloWelt.c +++ b/basics/einfach/halloWelt.c @@ -7,15 +7,15 @@ int main() int index = -1; char lokalesArray[30] = "Hello World!!!!"; char* zeigerAufZeichenkettenkonst = "Hallo Welt!"; - + printf("%s\n", lokalesArray); - + for (index = 0; *zeigerAufZeichenkettenkonst != STR_END; index++) lokalesArray[index] = *zeigerAufZeichenkettenkonst++; - + lokalesArray[index] = STR_END; printf("\noder...\n\n%s\n", lokalesArray); - + return 0; } diff --git a/chapter2/maximum/Makefile b/chapter2/maximum/Makefile index be189f7..319661d 100644 --- a/chapter2/maximum/Makefile +++ b/chapter2/maximum/Makefile @@ -1,32 +1,32 @@ -#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles -# werden zur ausführbaren Datei "start" zusammengebunden! -MAKE = make -CC = gcc +#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles +# werden zur ausführbaren Datei "maximum" zusammengebunden! +MAKE = make +CC = gcc CFLAGS = -m32 -Wall -O0 -g #-pthread, nur für POSIX-Threads notwendig -RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen -ASM = nasm +RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen +ASM = nasm ASMFLAGS = -f elf32 -O0 -g -F dwarf -NAME = maximum # Name des Programms/der ausführbaren Datei +NAME = maximum # Name des Programms/der ausführbaren Datei # Objekt-Datei-Liste generieren aus Quell-Datei-Listen -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) +OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) +OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) .PHONY: clean -# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< +# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< -%.o : %.asm - $(ASM) $(ASMFLAGS) -o $@ $< +%.o : %.asm + $(ASM) $(ASMFLAGS) -o $@ $< -all: - $(MAKE) $(NAME) +all: + $(MAKE) $(NAME) -$(NAME): $(OBJS) - $(CC) $(CFLAGS) -o $(NAME) $(OBJS) +$(NAME): $(OBJS) + $(CC) $(CFLAGS) -o $(NAME) $(OBJS) -clean: - $(RM) *.o $(NAME) +clean: + $(RM) *.o $(NAME) diff --git a/chapter2/maximum/main.asm b/chapter2/maximum/main.asm index e2e5cd6..c7f5e01 100644 --- a/chapter2/maximum/main.asm +++ b/chapter2/maximum/main.asm @@ -8,20 +8,20 @@ SECTION .text maximum: push ebp ; save old ebp - mov ebp, esp ; create new ebp + mov ebp, esp ; create new ebp sub esp, 4 ; create local var j mov eax, [ebp+8] ; load 42 in eax mov [ebp-4], eax ; mov 42 to j - mov eax, [ebp+12] ; load 2 in eax + mov eax, [ebp+12] ; load 2 in eax cmp eax, [ebp-4] ; compare 2 with j - jl change ; jump below to change, - mov [ebp-4], eax ; if not then move eax to j + jl change ; jump below to change, + mov [ebp-4], eax ; if not then move eax to j + +change: + mov eax, [ebp-4] ; mov j to eax -change: - mov eax, [ebp-4] ; mov j to eax - add esp, 4 ; destroy local var j pop ebp ; restore ebp ret ; jump back to addr before function was called @@ -37,7 +37,7 @@ main: add esp, 8 mov esp, ebp ; restore old stack frame - pop ebp + pop ebp ; leave program and forward maximum's result ; to the shell diff --git a/chapter2/mergesort/v1/Makefile b/chapter2/mergesort/v1/Makefile index e754454..98dc8ca 100644 --- a/chapter2/mergesort/v1/Makefile +++ b/chapter2/mergesort/v1/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -Wall -O0 -g CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = merge_v1 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/mergesort/v2/Makefile b/chapter2/mergesort/v2/Makefile index 23a6bac..0b01c1e 100644 --- a/chapter2/mergesort/v2/Makefile +++ b/chapter2/mergesort/v2/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -Wall -O0 -g -pthread CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = merge_v2 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/mergesort/v2/main.c b/chapter2/mergesort/v2/main.c index 58a372c..def6173 100644 --- a/chapter2/mergesort/v2/main.c +++ b/chapter2/mergesort/v2/main.c @@ -100,7 +100,7 @@ int main(int argc, char **argv) pthread_t thread; thread_param thr_arg; - /* + /* *"seed" auf die aktuelle Zeit setzen, um * nicht immer die selben Zufallszahlen zu erhalten */ diff --git a/chapter2/pi/fpu/Makefile b/chapter2/pi/fpu/Makefile index a901bce..acc1d63 100644 --- a/chapter2/pi/fpu/Makefile +++ b/chapter2/pi/fpu/Makefile @@ -1,30 +1,30 @@ -#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles -# werden zur ausführbaren Datei "start" zusammengebunden! -MAKE = make -CC = gcc +#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles +# werden zur ausführbaren Datei "pi_fpu" zusammengebunden! +MAKE = make +CC = gcc CFLAGS = -m32 -Wall -O0 -g #-pthread, nur für POSIX-Threads notwendig -RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen -ASM = nasm +RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen +ASM = nasm ASMFLAGS = -f elf32 -O0 -g -F dwarf -NAME = start # Name des Programms/der ausführbaren Datei +NAME = start # Name des Programms/der ausführbaren Datei # Objekt-Datei-Liste generieren aus Quell-Datei-Listen -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) +OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) +OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) -# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< +# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< -%.o : %.asm - $(ASM) $(ASMFLAGS) -o $@ $< +%.o : %.asm + $(ASM) $(ASMFLAGS) -o $@ $< -all: - $(MAKE) $(NAME) +all: + $(MAKE) $(NAME) -$(NAME): $(OBJS) - $(CC) $(CFLAGS) -o $(NAME) $(OBJS) +$(NAME): $(OBJS) + $(CC) $(CFLAGS) -o $(NAME) $(OBJS) -clean: - $(RM) *.o $(NAME) +clean: + $(RM) *.o $(NAME) diff --git a/chapter2/pi/fpu/main.asm b/chapter2/pi/fpu/main.asm index 3066ef7..5f35938 100644 --- a/chapter2/pi/fpu/main.asm +++ b/chapter2/pi/fpu/main.asm @@ -47,7 +47,7 @@ L1: fmul st0, st0 fld1 ; st0 = 1.0 faddp st1, st0 - + ; teile 4 durch das Zwischenergebnis fdivr qword [four] @@ -66,12 +66,12 @@ L2: push msg call printf add esp, 12 - + pop ecx pop ebx mov esp, ebp ; alter Stackframe restaurieren - pop ebp + pop ebp ; Programm verlassen & signalisieren, ; dass bei bei der Ausführung kein Fehler diff --git a/chapter2/pi/fpu64/Makefile b/chapter2/pi/fpu64/Makefile index 96bcd7d..517c86d 100644 --- a/chapter2/pi/fpu64/Makefile +++ b/chapter2/pi/fpu64/Makefile @@ -1,30 +1,30 @@ -#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles -# werden zur ausführbaren Datei "start" zusammengebunden! -MAKE = make -CC = gcc +#ACHTUNG: alle *.asm u. *.c Dateien im Ordner dieses Makefiles +# werden zur ausführbaren Datei "pi_fpu64" zusammengebunden! +MAKE = make +CC = gcc CFLAGS = -m64 -Wall -O0 -g #-pthread, nur für POSIX-Threads notwendig -RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen -ASM = nasm +RM = rm -rf #rm = Unix-Befehl remove = Dateien löschen +ASM = nasm ASMFLAGS = -f elf64 -O0 -g -F dwarf -NAME = start # Name des Programms/der ausführbaren Datei +NAME = start # Name des Programms/der ausführbaren Datei # Objekt-Datei-Liste generieren aus Quell-Datei-Listen -OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) +OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) +OBJS += $(patsubst %.asm, %.o, $(wildcard *.asm)) -# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< +# Erzeugung von Objektdateien (*.o) aus den Quellcodedateien (*.c u. *.asm) +%.o : %.c + $(CC) -c $(CFLAGS) -o $@ $< -%.o : %.asm - $(ASM) $(ASMFLAGS) -o $@ $< +%.o : %.asm + $(ASM) $(ASMFLAGS) -o $@ $< -all: - $(MAKE) $(NAME) +all: + $(MAKE) $(NAME) -$(NAME): $(OBJS) - $(CC) -static $(CFLAGS) -o $(NAME) $(OBJS) +$(NAME): $(OBJS) + $(CC) -static $(CFLAGS) -o $(NAME) $(OBJS) -clean: - $(RM) *.o $(NAME) +clean: + $(RM) *.o $(NAME) diff --git a/chapter2/pi/fpu64/main.asm b/chapter2/pi/fpu64/main.asm index 8c32610..2be9f72 100644 --- a/chapter2/pi/fpu64/main.asm +++ b/chapter2/pi/fpu64/main.asm @@ -57,7 +57,7 @@ L1: fmul st0, st0 fld1 ; st0 = 1.0 faddp st1, st0 - + ; teile 4 durch das Zwischenergebnis fdivr qword [four] @@ -72,7 +72,7 @@ L2: fld qword [sum] fmul qword [step] - ; Die ersten sechs Ganzzahlen oder Zeiger werden über die Register + ; Die ersten sechs Ganzzahlen oder Zeiger werden über die Register ; RDI, RSI, RDX, RCX, R8, and R9 übergeben. ; => siehe auch fastcall unter 32bit ; @@ -107,7 +107,7 @@ L2: ; => Wenn -- wie hier -- mit -g compiliert wird, ; sollte er wie üblich verwendet werden. mov rsp, rbp ; alter Stackframe restaurieren - pop rbp + pop rbp ; Programm verlassen & signalisieren, ; dass bei bei der Ausführung kein Fehler @@ -116,4 +116,4 @@ L2: mov rax, 93 ; Nummer des Systemaufrufs "exit" syscall ; oder auch - ; int 0x80 + ; int 0x80 diff --git a/chapter2/pi/v1/Makefile b/chapter2/pi/v1/Makefile index 409180d..413b2d3 100644 --- a/chapter2/pi/v1/Makefile +++ b/chapter2/pi/v1/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = pi_v1 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v1/main.go b/chapter2/pi/v1/main.go index a1d203b..9bdfa42 100644 --- a/chapter2/pi/v1/main.go +++ b/chapter2/pi/v1/main.go @@ -1,7 +1,7 @@ /* * Simple Go example, start programm with following command: * - * go run main.go + * go run main.go */ package main @@ -40,7 +40,7 @@ func main() { } elapsed := time.Since(start) - + fmt.Println("Pi : ", sum*step) fmt.Println("Time : ", elapsed) } diff --git a/chapter2/pi/v2/Makefile b/chapter2/pi/v2/Makefile index 54ba0d7..6aa2ee3 100644 --- a/chapter2/pi/v2/Makefile +++ b/chapter2/pi/v2/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g -pthread CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = pi_v2 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v3/Makefile b/chapter2/pi/v3/Makefile index 2a26823..1c65e58 100644 --- a/chapter2/pi/v3/Makefile +++ b/chapter2/pi/v3/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g -pthread CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = pi_v3 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v4/Makefile b/chapter2/pi/v4/Makefile index a581342..e1fc43a 100644 --- a/chapter2/pi/v4/Makefile +++ b/chapter2/pi/v4/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g -pthread CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = pi_v4 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v4/main.c b/chapter2/pi/v4/main.c index 280cc82..fd82bf0 100644 --- a/chapter2/pi/v4/main.c +++ b/chapter2/pi/v4/main.c @@ -57,7 +57,7 @@ int main(int argc, char **argv) pthread_create(&(threads[i]), NULL, thread_func, &(thr_arg[i])); } - /* Wait until all threads have terminated + /* Wait until all threads have terminated and calculate PI */ for (i = 0; i < MAX_THREADS; i++) { pthread_join(threads[i], NULL); diff --git a/chapter2/pi/v5/Makefile b/chapter2/pi/v5/Makefile index 6bec9d2..4ff2565 100644 --- a/chapter2/pi/v5/Makefile +++ b/chapter2/pi/v5/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g -pthread CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = pi_v5 C_source = main.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v5/main.c b/chapter2/pi/v5/main.c index cceed88..61fdc4b 100644 --- a/chapter2/pi/v5/main.c +++ b/chapter2/pi/v5/main.c @@ -58,7 +58,7 @@ int main(int argc, char **argv) pthread_create(&(threads[i]), NULL, thread_func, &(thr_arg[i])); } - /* Wait until all threads have terminated + /* Wait until all threads have terminated and calculate PI */ for (i = 0; i < MAX_THREADS; i++) { pthread_join(threads[i], NULL); diff --git a/chapter2/pi/v5/main.go b/chapter2/pi/v5/main.go index 244526c..243c859 100644 --- a/chapter2/pi/v5/main.go +++ b/chapter2/pi/v5/main.go @@ -1,7 +1,7 @@ /* * Simple Go example, start programm with following command: * - * go run main.go + * go run main.go */ package main @@ -56,7 +56,7 @@ func main() { } elapsed := time.Since(start) - + fmt.Println("Pi : ", sum*step) fmt.Println("Time : ", elapsed) } diff --git a/chapter2/pi/v6/Makefile b/chapter2/pi/v6/Makefile index 6455241..b3b3aa3 100644 --- a/chapter2/pi/v6/Makefile +++ b/chapter2/pi/v6/Makefile @@ -7,7 +7,7 @@ CXX = g++ CFLAGS = -m32 -Wall -O0 -g #CFLAGS = -m32 -Wall -O3 -g -march=native -mtune=native -mfpmath=sse,387 CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm ASMFLAGS = -f elf32 -O0 -g -F dwarf @@ -23,7 +23,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v6/calcPi_AVX.asm b/chapter2/pi/v6/calcPi_AVX.asm index d213d0d..e255cea 100644 --- a/chapter2/pi/v6/calcPi_AVX.asm +++ b/chapter2/pi/v6/calcPi_AVX.asm @@ -50,7 +50,7 @@ done: calcPi_AVX: push ebp mov ebp, esp - + push ebx push ecx @@ -88,7 +88,7 @@ L1: vaddpd ymm4, ymm4 vsubpd ymm4, ymm5 ; Die Genauigkeit ist nun 2^-23 - ; => noch eine Iteration, um eine doppelte Genauigkeit (nach IEEE) + ; => noch eine Iteration, um eine doppelte Genauigkeit (nach IEEE) ; zu erzielen. vmulpd ymm6, ymm4 vmulpd ymm6, ymm4 @@ -96,7 +96,7 @@ L1: vsubpd ymm4, ymm6 ; mit 4 multiplizieren vmulpd ymm4, ymm3 -%endif +%endif ; Summiere die ermittelten Rechteckshöhen auf vaddpd ymm0, ymm0, ymm4 ; Laufzähler erhöhen und @@ -115,4 +115,4 @@ L2: ; ebp restaurieren pop ebp - ret + ret diff --git a/chapter2/pi/v6/calcPi_FPU.asm b/chapter2/pi/v6/calcPi_FPU.asm index eb3331e..76781c3 100644 --- a/chapter2/pi/v6/calcPi_FPU.asm +++ b/chapter2/pi/v6/calcPi_FPU.asm @@ -33,7 +33,7 @@ L1: fmul st0, st0 fld1 ; st0 = 1.0 faddp st1, st0 - + ; teile 4 durch das Zwischenergebnis fdivr qword [four] @@ -44,11 +44,11 @@ L1: inc ecx jmp L1 L2: - + pop ecx pop ebx mov esp, ebp ; alter Stackframe restaurieren - pop ebp + pop ebp ret diff --git a/chapter2/pi/v6/calcPi_SSE.asm b/chapter2/pi/v6/calcPi_SSE.asm index 0525f46..e94a90d 100644 --- a/chapter2/pi/v6/calcPi_SSE.asm +++ b/chapter2/pi/v6/calcPi_SSE.asm @@ -41,7 +41,7 @@ done: calcPi_SSE: push ebp mov ebp, esp - + push ebx push ecx @@ -86,4 +86,4 @@ L2: ; ebp restaurieren pop ebp - ret + ret diff --git a/chapter2/pi/v6/main.c b/chapter2/pi/v6/main.c index 17e0b04..ef38449 100644 --- a/chapter2/pi/v6/main.c +++ b/chapter2/pi/v6/main.c @@ -29,7 +29,7 @@ void calcPi_intrinsic(void) __m128d xmm0 = {0.0, 0.0}; __m128d xmm1 = {step, step}; __m128d xmm2 = *((__m128d*)ofs); - __m128d xmm3, xmm4; + __m128d xmm3, xmm4; int i; for(i = 0; i < num_steps; i+=2) { diff --git a/chapter2/pi/v7/Makefile b/chapter2/pi/v7/Makefile index bae8bea..09f4d70 100644 --- a/chapter2/pi/v7/Makefile +++ b/chapter2/pi/v7/Makefile @@ -6,7 +6,7 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g -pthread CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm ASMFLAGS = -f elf32 -O0 -g -F dwarf @@ -22,7 +22,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter2/pi/v7/calcPi_SSE_thread.asm b/chapter2/pi/v7/calcPi_SSE_thread.asm index ddba914..a794a95 100644 --- a/chapter2/pi/v7/calcPi_SSE_thread.asm +++ b/chapter2/pi/v7/calcPi_SSE_thread.asm @@ -45,12 +45,12 @@ L1: jmp L1 L2: ; sum = xmm0[0] + xmm0[1] - xorpd xmm3, xmm3 - xor edx, edx + xorpd xmm3, xmm3 + xor edx, edx addsd xmm3, xmm0 shufpd xmm0, xmm0, 0x1 addsd xmm3, xmm0 - + ; copy result to the memory mov edx, [ebp+16] movsd [edx], xmm3 diff --git a/chapter2/pi/v7/main.c b/chapter2/pi/v7/main.c index 4c707fc..7a9fc8b 100644 --- a/chapter2/pi/v7/main.c +++ b/chapter2/pi/v7/main.c @@ -48,7 +48,7 @@ int main(int argc, char **argv) num_steps = 1000000; printf("\nnum_steps = %d\n", (int)num_steps); - + gettimeofday(&start, NULL); sum = 0.0; @@ -63,7 +63,7 @@ int main(int argc, char **argv) pthread_create(&(threads[i]), NULL, thread_func, &(thr_arg[i])); } - /* Wait until all threads have terminated + /* Wait until all threads have terminated and calculate sum*/ for (i = 0; i < MAX_THREADS; i++) { pthread_join(threads[i], NULL); diff --git a/chapter2/rounding_error/Makefile b/chapter2/rounding_error/Makefile index 74fd40b..d80e5a2 100644 --- a/chapter2/rounding_error/Makefile +++ b/chapter2/rounding_error/Makefile @@ -1,7 +1,7 @@ CC = gcc CFLAGS = -O0 -Wall -LDFLAGS = +LDFLAGS = all: main @@ -11,5 +11,5 @@ main: main.o main.o: main.c $(CC) -c $(CFLAGS) main.c -o main.o -clean: +clean: rm -f main.o main diff --git a/chapter2/rounding_error/main.c b/chapter2/rounding_error/main.c index d53a1cc..1427c29 100644 --- a/chapter2/rounding_error/main.c +++ b/chapter2/rounding_error/main.c @@ -17,6 +17,6 @@ int main(int argc, char** argv) printf("erg2 = %.10f\n", erg2); printf("(a + b) + c = %.10f\n", (a + b) + c); printf("a + (b + c) = %.10f\n", a + (b + c)); - + return 0; } diff --git a/chapter2/strcpy/string_copy.asm b/chapter2/strcpy/string_copy.asm index 319dce1..3b075b7 100644 --- a/chapter2/strcpy/string_copy.asm +++ b/chapter2/strcpy/string_copy.asm @@ -1,14 +1,14 @@ SECTION .text global string_copy -string_copy: +string_copy: push ebp mov ebp, esp xor ecx, ecx - xor edx, edx + xor edx, edx ;aufrunf in main >> string_copy(string, "Hallo Welt"); - ; stack >> + ; stack >> ; * auf hallo welt >> ebp+12 ; * auf string >> ebp+ 8 ; RA >> ebp+ 4 @@ -16,10 +16,10 @@ string_copy: mov edi, [ebp+12] ;// neue werte mov esi, [ebp+8] ;// alte werte - -L1: + +L1: mov dl, [edi+ecx] - mov [esi+ecx], dl + mov [esi+ecx], dl cmp dl, 0 je ende inc ecx diff --git a/chapter4/aslr/Makefile b/chapter4/aslr/Makefile index 0f12ac5..cffc501 100644 --- a/chapter4/aslr/Makefile +++ b/chapter4/aslr/Makefile @@ -6,10 +6,10 @@ CXX = g++ # flags for debugging CFLAGS = -m32 -Wall -O0 -g CXXFLAGS = $(CFLAGS) -LDFLAGS = +LDFLAGS = RM = rm -rf ASM = nasm -ASMFLAGS = +ASMFLAGS = NAME = aslr_demo C_source = aslr_demo.c CPP_source = @@ -21,7 +21,7 @@ OBJS += $(patsubst %.asm, %.o, $(filter %.asm, $(ASM_source))) # other implicit rules %.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) -o $@ $< %.o : %.cpp $(CXX) -c $(CXXFLAGS) -o $@ $< diff --git a/chapter4/aslr/aslr_demo.c b/chapter4/aslr/aslr_demo.c index 096d716..54db86b 100644 --- a/chapter4/aslr/aslr_demo.c +++ b/chapter4/aslr/aslr_demo.c @@ -1,8 +1,8 @@ #include <stdio.h> #include <stdlib.h> -/* - * Der Linker definiert diese Symbole, deren Adressen der Beginn +/* + * Der Linker definiert diese Symbole, deren Adressen der Beginn * des BSS- & Data-Segements repräsentieren. */ extern void __bss_start; diff --git a/chapter4/shlib/ctest.c b/chapter4/shlib/ctest.c index aad3af5..b444abf 100644 --- a/chapter4/shlib/ctest.c +++ b/chapter4/shlib/ctest.c @@ -3,7 +3,7 @@ static void __attribute__ ((constructor)) _init(void); static void __attribute__ ((destructor)) _fini(void); - + static void _init(void) { printf("Library initialized\n"); diff --git a/chapter4/shlib/prog.c b/chapter4/shlib/prog.c index 4d7e080..1784e7d 100644 --- a/chapter4/shlib/prog.c +++ b/chapter4/shlib/prog.c @@ -4,7 +4,7 @@ #include <dlfcn.h> #include "ctest.h" -int main(int argc, char **argv) +int main(int argc, char **argv) { void *lib_handle; void (*fn)(int); @@ -12,19 +12,19 @@ int main(int argc, char **argv) /* * RTLD_LAZY: If specified, Linux is not concerned about - * unresolved symbols until they are referenced. - * RTLD_NOW: All unresolved symbols resolved when dlopen() is called. + * unresolved symbols until they are referenced. + * RTLD_NOW: All unresolved symbols resolved when dlopen() is called. * RTLD_GLOBAL: Make symbol libraries visible. */ lib_handle = dlopen("libctest.so", RTLD_LAZY); - if (!lib_handle) + if (!lib_handle) { fprintf(stderr, "%s\n", dlerror()); exit(1); } fn = dlsym(lib_handle, "ctest1"); - if ((error = dlerror()) != NULL) + if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); exit(1); -- GitLab