DynamoRIO / drmemory

Memory Debugger for Windows, Linux, Mac, and Android
Other
2.36k stars 256 forks source link

Add AArch64 support #2016

Open lgeek opened 6 years ago

lgeek commented 6 years ago

I'm running this on an AArch64 system with Debian Stretch; Linux 4.9.0, gcc 6.3.0, cmake 3.7.2. It looks like the build system thinks it's running on x86-64. On the other hand, cmake prints The system is: Linux - 4.9.0-3-arm64 - aarch64 in CMakeOutput.log. Here's the output from cmake:

$ cmake ..
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is GNU 6.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Dr. Memory version number: 1.11.17353
-- Looking for include file asm-i386/stat.h
-- Looking for include file asm-i386/stat.h - not found
-- Performing Test HAVE_FVISIBILITY_INTERNAL
-- Performing Test HAVE_FVISIBILITY_INTERNAL - Success
-- Performing Test HAVE_FVISIBILITY_HIDDEN
-- Performing Test HAVE_FVISIBILITY_HIDDEN - Success
-- Building DynamoRIO from local sources /home/cosmin/drmemory/build/dynamorio/cmake
-- Version number: 6.2.17316
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/as
/usr/bin/as missing flag "-mmnemonic.*intel"
/usr/bin/as too old: using /home/cosmin/drmemory/dynamorio/make/as-2.18.50
-- Found Perl: /usr/bin/perl (found version "5.24.1") 
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of uint
-- Check size of uint - done
-- Check size of ushort
-- Check size of ushort - done
-- Check size of bool
-- Check size of bool - failed
-- Check size of byte
-- Check size of byte - failed
-- Check size of sbyte
-- Check size of sbyte - failed
-- Check size of uint32
-- Check size of uint32 - failed
-- Check size of uint64
-- Check size of uint64 - failed
-- Check size of int32
-- Check size of int32 - failed
-- Check size of int64
-- Check size of int64 - failed
-- Check size of _Bool
-- Check size of _Bool - done
-- Performing Test no_stack_protector_avail
-- Performing Test no_stack_protector_avail - Success
-- Performing Test nounused_avail
-- Performing Test nounused_avail - Success
-- Performing Test HAVE_TYPELIMITS_CONTROL
-- Performing Test HAVE_TYPELIMITS_CONTROL - Success
-- Performing Test no_pie_avail
-- Performing Test no_pie_avail - Failed
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.8") 
CMake Error at build/dynamorio/cmake/DynamoRIOConfig.cmake:1073 (message):
  *** /usr/bin/ld failed: ***

  /usr/bin/ld: unrecognised emulation mode: elf_x86_64

  Supported emulations: aarch64linux aarch64elf aarch64elf32 aarch64elf32b
  aarch64elfb armelf armelfb aarch64linuxb aarch64linux32 aarch64linux32b
  armelfb_linux_eabi armelf_linux_eabi

Call Stack (most recent call first):
  dynamorio/clients/drcachesim/CMakeLists.txt:150 (configure_DynamoRIO_client)
  dynamorio/clients/drcachesim/CMakeLists.txt:161 (add_drmemtrace)

-- Configuring incomplete, errors occurred!
See also "/home/cosmin/drmemory/build/CMakeFiles/CMakeOutput.log".
See also "/home/cosmin/drmemory/build/CMakeFiles/CMakeError.log".

CMakeError.log CMakeOutput.log

derekbruening commented 6 years ago

Dr. Memory does not yet support AArch64. DynamoRIO's AArch64 support is mostly done but some IR gaps are likely to be exposed by a client that looks at everything like Dr. Memory (or any taint tracking tool). We would welcome contributions to port to AArch64.

lgeek commented 6 years ago

My bad, I hadn't realized it's not expected to build at this time. I've ran into a related issue building on an AArch32 userspace with an AArch64 kernel, I'll open a new issue.

varsub01 commented 4 years ago

Hi,

I am hitting the same issue. Has support for Dr. Memory on Aarch64 been added recently by any chance?

derekbruening commented 4 years ago

No, as the help wanted label indicates, work on this is likely to rely on new contributors.

varsub01 commented 4 years ago

Thanks Derek. I intend to take up this task. Can you provide any specific details on the IR gaps that you allude in a previous comment? Any help to scope out the work would be appreciated.

derekbruening commented 4 years ago

https://github.com/DynamoRIO/dynamorio/issues/2626 covers finishing the AArch64 encoder/decoder/IR. I believe it is pretty much complete: @AssadHashmi would know which opcodes or operand details are still missing.

For Dr. Memory, I would suggest starting with the pattern mode. That is already ported to ARM (32-bit). The full mode's fastpath is complex, low-level, and unfortunately could use some refactoring and cleanup to make it easier to port.

AssadHashmi commented 4 years ago

DynamoRIO/dynamorio#2626 covers finishing the AArch64 encoder/decoder/IR. I believe it is pretty much complete: @AssadHashmi would know which opcodes or operand details are still missing.

The biggest gap is in the NEON instructions. IMO the most efficient approach is first to get AArch64 to build then fix gaps as they arise at runtime starting with simple use-cases. A recent example of NEON IR is https://github.com/DynamoRIO/dynamorio/pull/3710

frankfkliu commented 3 years ago

Hi, Derek. Is there any update on porting Dr.memory to AArch64?

derekbruening commented 3 years ago

Hi, Derek. Is there any update on porting Dr.memory to AArch64?

@gregcawthorne or @AssadHashmi would know the latest. Are you looking to help with the port, or to use the tool?

gregcawthorne commented 3 years ago

@frankfkliu Hi! We have a implementation of the slowpath working pretty well and just ironing out some last bugs. We have a decent chunk of the DrMemory test passing and once we have a few more we will make version available on in a PR most likely.

We also have a fair amount of work on the fastpath done, but it is still unstable and we are focusing on getting the slowpath work upstreamed at present.

I am hoping to get something publicly available within the next month or so.

frankfkliu commented 3 years ago

Thanks! @gregcawthorne @derekbruening I am studying the realization principle of Dr.memory & dynamoRIO, wish to use Dr.memory on AArch64 platform, furthermore, try to make tools base on dynamoRIO for memory related performance analysis if possible.

derekbruening commented 11 months ago

https://github.com/DynamoRIO/drmemory/tree/slowpath-aarch64-port is still outstanding from @gregcawthorne but it has many failures and so needs a bunch of work to be fixed up and integrated. That gets the slowpath going. For the fastpath given all the complexities in trying to refactor the x86 fastpath to use drreg (#1795) I'm thinking it's best to just start from scratch for aarch64 with drreg and optimize (possibly adding new drreg features) later.