Skip to content

Commit 42fbc46

Browse files
committed
rename test.c to gen_asm.c
1 parent 27bf645 commit 42fbc46

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dkms.conf
5353

5454
# custom
5555
bin/
56+
gen_asm.s
5657

5758
# Visual Studio noise
5859
# Visual Studio 2015/2017 cache/options directory

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ behaviour on the C-stack level, could make use of simple, stable code, that can
111111
platforms as they come along.
112112

113113
## Cross-compilation
114-
Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling src/platform/test.c
114+
Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling
115+
src/platform/gen_asm.c
115116
- x86 requires the -m32 flag to compilers and linkers.
116117
- arm32 requires to use the arm-linux-gnueabi-* tools, including cc and linker
117118
- aarch64 requires the aarch64-linux-gnu-* tools.

lib/sysv_i386/libstackman.a

8 Bytes
Binary file not shown.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/* function to test the generation
22
* of assembly code under e.g. Gcc.
33
* use by calling, for example:
4-
* cc -S -m32 -fcf-protection=none test.c
4+
* cc -S -m32 -fcf-protection=none gen_asm.c
55
* and examinine the generated test.s assembly code.
66
* -m32 selects 32 bit mode, use other directives to select a different platform.
7-
* The -fcf-protection
8-
* flag disables generation of intel CET compatible code, but stack switching
9-
* is not compatible with the proposed shadow stack.
7+
* The -fcf-protection flag disables generation of intel CET compatible code, but stack switching
8+
* is not compatible with the proposed shadow stack. Only the latest compilers have it.
109
*/
1110

1211
#define STACKMAN_VERBOSE
13-
#define STACKMAN_SWITCH_IMPL
1412
#define STACKMAN_INLINE_ASM 1
1513
#define STACKMAN_BUILD_LIB /* so that we don´t generate indirection shims */
16-
#include "platform.h"
14+
#include "../stackman_impl.h"

src/platforms/switch_aarch64_gcc.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* implementation that is independent of subtleties of inline
66
* assembly code which may change with compiler versions.
77
* The file is generated using
8-
* "aarch64-linux-gnu-gcc -DSTACKMAN_SWITCH_IMPL -S test.c"
9-
* and then copying the code from test.s into this file.
8+
* "aarch64-linux-gnu-gcc -S gen_asm.c"
9+
* and then copying the code from gen_asm.s into this file.
1010
*
1111
*/
1212
.arch armv8-a
13-
.file "test.c"
13+
.file "gen_asm.c"
1414
.text
1515
.align 2
1616
.global stackman_switch

src/platforms/switch_aarch64_gcc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#if !__ASSEMBLER__ && !defined(STACKMAN_ASSEMBLY_SRC)
2424

2525
/*
26-
* To test this, #include this file in a file, test.c and
27-
* gcc -S -DSTACKMAN_SWITCH_IMPL test.c
28-
* then examine test.s for the result.
26+
* To test this, compile with appropriate cross platform flags, e.g.
27+
* "arm-linux-gnueabi-gcc -S gen_asm.c"
28+
* then examine gen_asm.s for the result.
2929
* We instruct optimizer to not omit frame pointers, -fno-omit_frame_pointer
3030
* and not use local stack vars, -O1.
3131
* option is applied with an __attribute__.

src/platforms/switch_arm_gcc.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* dependable, such as with clang on linux x86_64 or if
44
* STACKMAN_INLINE_ASM is false
55
* The file is generated using
6-
* "arm-linux-gnueabi-gcc -DSTACKMAN_SWITCH_IMPL -S test.c" and then copying the code
7-
* from test.s into this file.
6+
* "arm-linux-gnueabi-gcc -S gen_asm.c" and then copying the code
7+
* from gen_asm.s into this file.
88
*
99
*/
1010
.arch armv5t
@@ -17,7 +17,7 @@
1717
.eabi_attribute 30, 6
1818
.eabi_attribute 34, 0
1919
.eabi_attribute 18, 4
20-
.file "test.c"
20+
.file "gen_asm.c"
2121
.text
2222
.align 2
2323
.global stackman_switch

src/platforms/switch_arm_gcc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
* stack pointer on function exit, thereby invalidating our changes
3030
* to the stack pointer.
3131
* To arrive at reasonable assembler, follow some approach similar to:
32-
* cp switch_arm_gcc.h test.c
33-
* gcc -S -O -DSTACKMAN_SWITCH_IMPL test.c
34-
* mv test.s switch_arm_gcc.s
35-
* assembly code which can then be modified for actual use. Simple optimized
32+
* "gcc -S gen_asm.c"
33+
* to generate gen_asm.s which can then be
34+
* modified for actual use.
35+
* Simple optimized
3636
* version is better than no-optimized because the latter uses stack
3737
* variables for arguments. And it turns out that this version actually
3838
* runs because it does not use fp for restoring the stack pointer

src/platforms/switch_x86_64_gcc.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* implementation that is independent of subtleties of inline
66
* assembly code which may change with compiler versions.
77
* The file is generated using
8-
* "gcc -DSTACKMAN_SWITCH_IMPL -S -fcf-protection=none test.c"
9-
* and then copying the code from test.s into this file.
8+
* "gcc -S -fcf-protection=none gen_asm.c"
9+
* and then copying the code from gen_asm.s into this file.
1010
*
1111
*/
12-
.file "test.c"
12+
.file "gen_asm.c"
1313
.text
1414
.globl stackman_switch
1515
.type stackman_switch, @function

src/platforms/switch_x86_gcc.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* implementation that is independent of subtleties of inline
66
* assembly code which may change with compiler versions.
77
* The file is generated using
8-
* "gcc -DSTACKMAN_SWITCH_IMPL -S -m32 -fcf-protection=none test.c"
9-
* and then copying the code from test.s into this file.
8+
* "gcc -S -m32 -fcf-protection=none gen_asm.c"
9+
* and then copying the code from gen_asm.s into this file.
1010
*
1111
*/
12-
.file "test.c"
12+
.file "gen_asm.c"
1313
.text
1414
.globl stackman_switch
1515
.type stackman_switch, @function

0 commit comments

Comments
 (0)