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
|
BIN_DIR = bin
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
AS = as
|
||||||
LD = ld
|
LD = ld
|
||||||
CFLAGS = -Wall -I$(INC_DIR)
|
CFLAGS = -Wall -I$(INC_DIR)
|
||||||
LDFLAGS = -lcap
|
ASFLAGS =
|
||||||
|
LDFLAGS = -z noexecstack -lcap
|
||||||
|
|
||||||
BLACKJACK_SRC = main.c process.c
|
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_SRC := $(addprefix $(SRC_DIR)/,$(BLACKJACK_SRC))
|
||||||
BLACKJACK_DEPS = debug.h process.h
|
BLACKJACK_DEPS = debug.h process.h
|
||||||
BLACKJACK_DEPS := $(addprefix $(INC_DIR)/,$(BLACKJACK_DEPS))
|
BLACKJACK_DEPS := $(addprefix $(INC_DIR)/,$(BLACKJACK_DEPS))
|
||||||
|
|
||||||
DUMMY_TARGET_SRC = dummy_target.c
|
DUMMY_TARGET_SRC = dummy_target.c dummy_destination.s
|
||||||
DUMMY_TARGET_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(DUMMY_TARGET_SRC)))
|
DUMMY_TARGET_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.s,%.o,$(patsubst %.c,%.o,$(DUMMY_TARGET_SRC))))
|
||||||
DUMMY_TARGET_SRC := $(addprefix $(SRC_DIR)/,$(DUMMY_TARGET_SRC))
|
DUMMY_TARGET_SRC := $(addprefix $(SRC_DIR)/,$(DUMMY_TARGET_SRC))
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
|
||||||
|
$(AS) $(ASFLAGS) -o $@ $<
|
||||||
|
|
||||||
blackjack: $(BLACKJACK_OBJ) $(BLACKJACK_DEPS)
|
blackjack: $(BLACKJACK_OBJ) $(BLACKJACK_DEPS)
|
||||||
$(CC) $(LDFLAGS) -o $(BIN_DIR)/$@ $(BLACKJACK_OBJ)
|
$(CC) $(LDFLAGS) -o $(BIN_DIR)/$@ $(BLACKJACK_OBJ)
|
||||||
|
|
||||||
|
|
@ -35,6 +40,7 @@ all: $(TARGETS)
|
||||||
|
|
||||||
debug: CFLAGS += -DDEBUG -g
|
debug: CFLAGS += -DDEBUG -g
|
||||||
debug: LDFLAGS += -g
|
debug: LDFLAGS += -g
|
||||||
|
debug: ASFLAGS += -g
|
||||||
debug: $(TARGETS)
|
debug: $(TARGETS)
|
||||||
|
|
||||||
clean:
|
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*)
|
extern void hijack_destination();
|
||||||
{
|
|
||||||
puts("thread has been redirected to this function! cool!");
|
|
||||||
while (1) sleep(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue