mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 11:11:35 +01:00
userland: add ported to all archs
This commit is contained in:
10
README.adoc
10
README.adoc
@@ -11362,10 +11362,12 @@ This verifies that the venerable `add` instruction and our setup are working.
|
||||
Then, modify that program to make the assertion fail:
|
||||
|
||||
....
|
||||
TODO
|
||||
ASSERT_EQ(%rax, $4)
|
||||
....
|
||||
|
||||
and then watch the assertion fail:
|
||||
because 1 + 2 tends to equal 3 instead of 4.
|
||||
|
||||
And then watch the assertion fail:
|
||||
|
||||
....
|
||||
./build-userland
|
||||
@@ -11375,10 +11377,10 @@ and then watch the assertion fail:
|
||||
with error message:
|
||||
|
||||
....
|
||||
TODO
|
||||
error 1 at line 8
|
||||
....
|
||||
|
||||
Notice how we give the actual assembly line number where the failing assert was!
|
||||
and notice how we give the actual assembly line number where the failing assert was!
|
||||
|
||||
Other setup sanity checks that you might want to look into include:
|
||||
|
||||
|
||||
9
userland/arch/x86_64/add.S
Normal file
9
userland/arch/x86_64/add.S
Normal file
@@ -0,0 +1,9 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#userland-assembly */
|
||||
|
||||
#include "common.h"
|
||||
|
||||
ENTRY
|
||||
mov $1, %rax
|
||||
add $2, %rax
|
||||
ASSERT_EQ(%rax, $3)
|
||||
EXIT
|
||||
@@ -9,9 +9,9 @@
|
||||
mov reg, %rax; \
|
||||
mov const, %rbx; \
|
||||
cmp %rax, %rbx; \
|
||||
ASSERT(je); \
|
||||
pop %rbx; \
|
||||
pop %rax; \
|
||||
ASSERT(je); \
|
||||
;
|
||||
|
||||
# TODO
|
||||
|
||||
Reference in New Issue
Block a user