You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-4Lines changed: 42 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
[](https://github.com/kristjanvalur/stackman/actions/workflows/buildcommit.yml)
2
2
3
3
# stackman
4
+
4
5
Simple low-level stack manipulation API and implementation for common platforms
5
6
6
7
## Purpose
8
+
7
9
This library aims to provide a basic API to perfom stack manipulation
8
10
on various platforms. Stack manipulation involves changing the machine stack
9
11
pointer while optionally saving and restoring the stack contents.
@@ -29,34 +31,48 @@ Additionally, it provides a set of pre-assembled libraries for the most common
29
31
platforms so that no assembly steps are required by users.
30
32
31
33
## Features
34
+
32
35
- Simple api
36
+
33
37
-`stackman_switch()` and `stackman_call()` are the only functions.
34
38
- The caller provides a callback and context pointer to customize behaviour.
35
-
Simple implementation
39
+
40
+
- Simple implementation
41
+
36
42
- The code involving assembly is as simple as possible, allowing for
37
43
straightforward implementation on most platforms.
38
44
- Complex logic and branching is delegated to the C callback.
39
45
- Custom platform assembly code must only do three things:
40
46
1. Save and restore volatile registers and stack state on the stack
41
47
2. Call the callback twice with the current stack pointer
42
48
3. Set the stack pointer to the value returned by the first callback.
43
-
- Assembly support
49
+
50
+
- Assembly support
51
+
44
52
The straightforward and application-agnostic switching allows the switching function to be implemented in full assembler. This removes
45
53
the risk of inline-assembler doing any sort of unexpected things such
46
54
as in-lining the function or otherwise change the assumptions that the
47
55
function makes about its environment. This assembly code can be created by the in-line assembler in a controlled environment.
56
+
48
57
- No dependencies
58
+
49
59
The library merely provides stack switching. It consist only of a couple of functions with no dependencies.
60
+
50
61
- Stable
62
+
51
63
There is no need to add or modify functionality.
64
+
52
65
- Libraries provided.
66
+
53
67
The aim is to provide pre-assembled libraries for the most popular platforms. This relieves other tools that want to do stack
54
68
manipulation from doing any sort of assembly or complex linkage. Just include the headers and link to the appropriate library.
55
69
56
70
## Supported platforms
71
+
57
72
The current code is distilled out of other work, with the aim of simplifying and
58
73
standardizing the api. A number of ABI specifications is supported, meaning architecture and
59
74
calling convention, plus archive format:
75
+
60
76
- win_x86 (32 bits)
61
77
- win_x64
62
78
- win_ARM64 (experimental)
@@ -65,7 +81,8 @@ calling convention, plus archive format:
65
81
- AAPCS (32 bit arm)
66
82
- AAPCS64 (64 bit arm)
67
83
68
-
Supported toolchains:
84
+
### Supported toolchains:
85
+
69
86
- Gnu C
70
87
- clang
71
88
- Microsoft Visual Studio
@@ -74,16 +91,21 @@ Other platforms can be easily adapted from both existing implementations for oth
74
91
projects as well as from example code provided.
75
92
76
93
## API
94
+
77
95
There are two functions that make up the stackman library: `stakman_switch()` and `stackman_call()` who
0 commit comments