Skip to content

Commit ac5d11f

Browse files
committed
src: arch: Add x86 arch
1 parent 2911cf9 commit ac5d11f

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

shellblocks/src/arch/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#if defined(__mips__)
55
#include "mips/utils.h"
6+
#elif defined(__i386__) || defined(__x86_64__)
7+
#include "x86/utils.h"
68
#elif defined(__arm__)
79
#include "arm/utils.h"
810
#endif

shellblocks/src/arch/x86/utils.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef SHELLCODE_BLOCKS_ARCH_I386_UTILS_H
2+
#define SHELLCODE_BLOCKS_ARCH_I386_UTILS_H
3+
4+
#define NOP_OPCODE (0x90909090)
5+
6+
#define GET_REL_ADDRESS(OUTPUT, LABEL) \
7+
__asm__ volatile ( \
8+
"call " GET_REL_LABEL(LABEL) "\n\t" \
9+
GET_REL_LABEL(LABEL) ": pop %0\n\t" \
10+
"add $(" #LABEL " - " GET_REL_LABEL(LABEL) "), %0\n\t" \
11+
: "=r" (OUTPUT) : : \
12+
)
13+
14+
#endif // !SHELLCODE_BLOCKS_ARCH_I386_UTILS_H

0 commit comments

Comments
 (0)