forked from gramineproject/graphene
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LibOS] asm offset constants generation
Auto generate offset constants for assembly. replace magic number with symbolic constants in LibOS/shim/src/syscallas.S. This patch also introduces Makefile.rules to accommodate common make rules so that V=1 (like Linux style make) is accepted. Signed-off-by: Isaku Yamahata <[email protected]>
- Loading branch information
Showing
6 changed files
with
81 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
libsysdb.so.cached | ||
asm-offsets.h | ||
asm-offsets.s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stddef.h> | ||
|
||
#include <shim_internal.h> | ||
#include <shim_tls.h> | ||
|
||
#define OFFSET_T(name, str_t, member) \ | ||
asm volatile(".ascii \" #define " #name " %0 \"\n":: \ | ||
"i"(offsetof(str_t, member))) | ||
|
||
void dummy(void) | ||
{ | ||
OFFSET_T(SHIM_TCB_OFFSET, __libc_tcb_t, shim_tcb); | ||
OFFSET_T(TCB_SYSCALL_NR, shim_tcb_t, context.syscall_nr); | ||
OFFSET_T(TCB_SP, shim_tcb_t, context.sp); | ||
OFFSET_T(TCB_RET_IP, shim_tcb_t, context.ret_ip); | ||
OFFSET_T(TCB_REGS, shim_tcb_t, context.regs); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
ifeq ("$(origin V)", "command line") | ||
BUILD_VERBOSE = $(V) | ||
endif | ||
ifndef BUILD_VERBOSE | ||
BUILD_VERBOSE = 0 | ||
endif | ||
|
||
ifeq ($(BUILD_VERBOSE),1) | ||
quiet = | ||
Q = | ||
else | ||
quiet = quiet_ | ||
Q = @ | ||
endif | ||
|
||
export Q quiet BUILD_VERBOSE | ||
|
||
squote := ' | ||
escsq = $(subst $(squote),'\$(squote)',$1) | ||
|
||
echo-cmd = $(if $($(quiet)cmd_$(1)), echo ' $(call escsq,$($(quiet)cmd_$(1)))';) | ||
cmd = @$(echo-cmd) $(cmd_$(1)) | ||
|
||
|
||
quiet_cmd_asm_offsets_s = [ $@ ] | ||
cmd_asm_offsets_s = $(CC) $(CFLAGS) $(defs) -S $< -o $@ | ||
|
||
asm-offsets.s: asm-offsets.c $(headers) | ||
$(call cmd,asm_offsets_s) | ||
CLEAN_FILES += asm-offsets.s | ||
|
||
|
||
quiet_cmd_asm_offsets_h = [ $@ ] | ||
cmd_asm_offsets_h = \ | ||
(set -e; \ | ||
echo "/* DO NOT MODIFY. THIS FILE WAS AUTO-GENERATED. */"; \ | ||
echo "\#ifndef _ASM_OFFSETS_H_"; \ | ||
echo "\#define _ASM_OFFSETS_H_"; \ | ||
echo ""; \ | ||
awk '/\.ascii \" \#define/{val=$$5; gsub("\\$$", "", val); print $$3" "$$4" "val}' $^; \ | ||
echo ""; \ | ||
echo "\#endif") > $@ | ||
|
||
asm-offsets.h: asm-offsets.s | ||
$(call cmd,asm_offsets_h) | ||
CLEAN_FILES += asm-offests.h |