8000 Arm coproc registers read/write by jbcayrou · Pull Request #889 · unicorn-engine/unicorn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Arm coproc registers read/write #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ bindings/python/unicorn/include/
bindings/python/MANIFEST
bindings/rust/target/
bindings/rust/Cargo.lock
bindings/tmp/
config.log


Expand Down
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,31 @@ else()
)
add_test(${TEST_FILE} ${TEST_FILE})
endforeach(TEST_FILE)

# arm and arm64
# Build utils/arm_list_coprocregs.c to get the list of all coproc registers implemented in qemu
if (UNICORN_HAS_AARCH64)
add_executable(arm64_list_coprocregs ${CMAKE_CURRENT_SOURCE_DIR}/utils/arm_list_coprocregs.c)
target_link_libraries(arm64_list_coprocregs unicorn )
target_link_libraries(arm64_list_coprocregs unicorn-common)
target_compile_options(arm64_list_coprocregs PRIVATE
-DNEED_CPU_H
-include aarch64.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are failing CI because MSVC doesn't recognize this options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho yes I forgot to manage MSVC case

-I${CMAKE_BINARY_DIR}/aarch64-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/arm
)
endif()
if (UNICORN_HAS_ARM)
add_executable(arm_list_coprocregs ${CMAKE_CURRENT_SOURCE_DIR}/utils/arm_list_coprocregs.c)
target_link_libraries(arm_list_coprocregs unicorn )
target_link_libraries(arm_list_coprocregs unicorn-common)
target_compile_options(arm_list_coprocregs PRIVATE
-DNEED_CPU_H
-include arm.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

-I${CMAKE_BINARY_DIR}/arm-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/arm
)
endif()
endif()

if(NOT MSVC)
Expand All @@ -1197,3 +1222,4 @@ Cflags: -I\$\{includedir\}\n"
)
install(FILES ${CMAKE_BINARY_DIR}/unicorn.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()

21 changes: 19 additions & 2 deletions bindings/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,34 @@ else
ENV_VARS = LD_LIBRARY_PATH=../ DYLD_LIBRARY_PATH=../ LIBUNICORN_PATH=$(TRAVIS_BUILD_DIR)
endif

TEMPDIR = tmp

HEADERS = $(wildcard ../include/unicorn/*.h)
HEADERS_DIR = ../include/unicorn
HEADERS_PREPROC_DIR = $(TEMPDIR)
HEADERS_PREPROC := $(HEADERS:$(HEADERS_DIR)/%.h=$(HEADERS_PREPROC_DIR)/%.h)

.PHONY: build install python c clean check test

build:

build: $(TEMPDIR) $(HEADERS_PREPROC)
$(MAKE) -C python gen_const
$(MAKE) -C go gen_const
$(MAKE) -C java gen_const
$(MAKE) -C ruby gen_const
python const_generator.py dotnet
python const_generator.py pascal

tmp_headers: $(TEMPDIR) $(HEADERS_PREPROC)

$(TEMPDIR):
-mkdir $(TEMPDIR)

$(HEADERS_PREPROC): $(HEADERS_PREPROC_DIR)/%.h : $(HEADERS_DIR)/%.h
# To generate header file with macro expanded. '-C' to keep comments
$(CC) -E -C $< -o $@
@echo "Preprocess "$<" in "$@" successfully!"

install: build
$(MAKE) -C python install
$(MAKE) -C java install
Expand All @@ -49,6 +66,6 @@ clean:
# rm -rf *.txt
$(MAKE) -C python clean
$(MAKE) -C java clean

rm -rf $(TEMPDIR)
check:
make -C python check
18 changes: 16 additions & 2 deletions bindings/const_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import print_function
import sys, re, os

INCL_DIR = os.path.join('..', 'include', 'unicorn')
INCL_DIR = os.path.join('.', 'tmp')

include = [ 'arm.h', 'arm64.h', 'mips.h', 'x86.h', 'sparc.h', 'm68k.h', 'ppc.h', 'riscv.h', 'unicorn.h' ]

Expand Down Expand Up @@ -119,6 +119,8 @@
},
}

all_arch_prefix = [ template["python"][tmp_target].upper() for tmp_target in include]

# markup for comments to be added to autogen files
MARKUP = '//>'

Expand All @@ -129,8 +131,11 @@ def gen(lang):
prefix = templ[target]
outfile = open(templ['out_file'] %(prefix), 'wb') # open as binary prevents windows newlines
outfile.write((templ['header'] % (prefix)).encode("utf-8"))
add_comments = True

if target == 'unicorn.h':
prefix = ''
add_comments = False
with open(os.path.join(INCL_DIR, target)) as f:
lines = f.readlines()

Expand All @@ -139,7 +144,7 @@ def gen(lang):
for line in lines:
line = line.strip()

if line.startswith(MARKUP): # markup for comments
if add_comments and line.startswith(MARKUP): # markup for comments
outfile.write(("\n%s%s%s\n" %(templ['comment_open'], \
line.replace(MARKUP, ''), templ['comment_close'])).encode("utf-8"))
continue
Expand Down Expand Up @@ -170,6 +175,15 @@ def gen(lang):
else:
rhs = str(count)

if prefix == "":
incorrect_prefix = False
for arch in all_arch_prefix:
if f[0].startswith("UC_" + arch):
incorrect_prefix = True
break
if incorrect_prefix:
continue

lhs = f[0].strip()
# evaluate bitshifts in constants e.g. "UC_X86 = 1 << 1"
match = re.match(r'(?P<rhs>\s*\d+\s*<<\s*\d+\s*)', rhs)
Expand Down
Loading
0