add assembly targets and rules
This commit is contained in:
parent
654f083f60
commit
a1b815415e
3 changed files with 24 additions and 9 deletions
14
Makefile
14
Makefile
|
|
@ -4,23 +4,28 @@ OBJ_DIR = obj
|
|||
BIN_DIR = bin
|
||||
|
||||
CC = gcc
|
||||
AS = as
|
||||
LD = ld
|
||||
CFLAGS = -Wall -I$(INC_DIR)
|
||||
LDFLAGS = -lcap
|
||||
ASFLAGS =
|
||||
LDFLAGS = -z noexecstack -lcap
|
||||
|
||||
BLACKJACK_SRC = main.c process.c
|
||||
BLACKJACK_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(BLACKJACK_SRC)))
|
||||
BLACKJACK_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(BLACKJACK_SRC))))
|
||||
BLACKJACK_SRC := $(addprefix $(SRC_DIR)/,$(BLACKJACK_SRC))
|
||||
BLACKJACK_DEPS = debug.h process.h
|
||||
BLACKJACK_DEPS := $(addprefix $(INC_DIR)/,$(BLACKJACK_DEPS))
|
||||
|
||||
DUMMY_TARGET_SRC = dummy_target.c
|
||||
DUMMY_TARGET_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(DUMMY_TARGET_SRC)))
|
||||
DUMMY_TARGET_SRC = dummy_target.c dummy_destination.s
|
||||
DUMMY_TARGET_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(DUMMY_TARGET_SRC))))
|
||||
DUMMY_TARGET_SRC := $(addprefix $(SRC_DIR)/,$(DUMMY_TARGET_SRC))
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
blackjack: $(BLACKJACK_OBJ) $(BLACKJACK_DEPS)
|
||||
$(CC) $(LDFLAGS) -o $(BIN_DIR)/$@ $(BLACKJACK_OBJ)
|
||||
|
||||
|
|
@ -35,6 +40,7 @@ all: $(TARGETS)
|
|||
|
||||
debug: CFLAGS += -DDEBUG -g
|
||||
debug: LDFLAGS += -g
|
||||
debug: ASFLAGS += -g
|
||||
debug: $(TARGETS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
13
src/dummy_destination.s
Normal file
13
src/dummy_destination.s
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
.global hijack_destination
|
||||
|
||||
.text
|
||||
hijack_destination:
|
||||
leaq redirect_msg(%rip), %rdi
|
||||
call puts
|
||||
.sleep_loop:
|
||||
mov $0x1, %edi
|
||||
call sleep
|
||||
jmp .sleep_loop
|
||||
|
||||
.section rodata
|
||||
redirect_msg: .string "thread has been redirected to this function! cool!"
|
||||
|
|
@ -49,11 +49,7 @@ __attribute__((noreturn)) void* slave3_job(void*)
|
|||
}
|
||||
}
|
||||
|
||||
__attribute__((noreturn)) void* hijack_destination(void*)
|
||||
{
|
||||
puts("thread has been redirected to this function! cool!");
|
||||
while (1) sleep(1);
|
||||
}
|
||||
extern void hijack_destination();
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue