diff --git a/scripts/abi_artifact_generator/config/functions.yml b/scripts/abi_artifact_generator/config/functions.yml index cef1b469..4d2dba08 100644 --- a/scripts/abi_artifact_generator/config/functions.yml +++ b/scripts/abi_artifact_generator/config/functions.yml @@ -103,7 +103,7 @@ argument_tests: - big_struct - big_struct - lots_of_arguments: + lots_of_one_byte_arguments: - uint8_t - uint8_t - uint8_t @@ -127,6 +127,102 @@ argument_tests: - uint8_t - uint8_t - uint8_t + lots_of_two_byte_arguments: + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + - uint16_t + lots_of_four_byte_arguments: + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + - uint32_t + lots_of_eight_byte_arguments: + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + - uint64_t + lots_of_sixteen_byte_arguments: + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T + - UINT128_T # # Equivalence tests. @@ -358,7 +454,7 @@ argument_tests: unnaturally_aligned_struct_128_in_registers: - size_t - size_t - - unnaturally_aligned_struct_16 + - unnaturally_aligned_struct_128 unnaturally_aligned_struct_128_on_stack: - size_t - size_t @@ -427,6 +523,98 @@ argument_tests: - uint8_t - unnaturally_aligned_struct_16 + # + # Dedicated tests for highlighting apple arm64 abi quirks + # + apple_double_aligned_on_stack: + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - uint8_t + - uint8_t + - uint16_t + apple_reverse_double_aligned_on_stack: + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - uint16_t + - uint8_t + - uint8_t + apple_quad_aligned_on_stack: + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint32_t + apple_reverse_quad_aligned_on_stack: + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - uint32_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + apple_multi_aligned_on_stack: + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint64_t + apple_reverse_multi_aligned_on_stack: + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - size_t + - uint64_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + - uint8_t + return_value_tests: single_8_bit_return_value: "uint8_t" single_16_bit_return_value: "int16_t" diff --git a/scripts/abi_artifact_generator/templates/setup.inc.jinja_template b/scripts/abi_artifact_generator/templates/setup.inc.jinja_template index 971a280b..626c53cd 100644 --- a/scripts/abi_artifact_generator/templates/setup.inc.jinja_template +++ b/scripts/abi_artifact_generator/templates/setup.inc.jinja_template @@ -89,4 +89,6 @@ int main() { /*{ for name in return_value_functions -}*/ setup_/*( name )*/(); /*{ endfor -}*/ + + return 0; } diff --git a/share/revng/test/configuration/revng-qa/architectures.yml b/share/revng/test/configuration/revng-qa/architectures.yml index a35234d4..b24c0c41 100644 --- a/share/revng/test/configuration/revng-qa/architectures.yml +++ b/share/revng/test/configuration/revng-qa/architectures.yml @@ -4,13 +4,15 @@ tags: variables: MSVC_CFLAGS: - -WX # treats warnings as errors - - -nologo # supresses startup banner + - -nologo # suppresses startup banner MSVC_LDFLAGS: # Sadly, msvc linker only supports `/`-style parameters. - /debug # creates debug information - - /nologo # supresses startup banner + - /nologo # suppresses startup banner - /wx # treats warnings as errors + - name: apple + - name: clang # Use clang instead of gcc - name: compiler variables: GCC_CFLAGS: @@ -46,6 +48,9 @@ tags: - -Wl,-Ttext-segment=0x20000 COMMON_CFLAGS: - -DTARGET_arm + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=armv7a-hardfloat-linux-uclibceabi - name: x86-64 implies: [cross-compiler] variables: @@ -55,6 +60,9 @@ tags: OBJDUMP_FLAGS: -Mintel COMMON_CFLAGS: - -DTARGET_x86_64 + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=x86_64-gentoo-linux-musl - name: mips implies: [cross-compiler] variables: @@ -63,6 +71,9 @@ tags: QEMU_NAME: mips COMMON_CFLAGS: - -DTARGET_mips + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=mips-unknown-linux-musl - name: mipsel implies: [cross-compiler] variables: @@ -71,6 +82,9 @@ tags: QEMU_NAME: mipsel COMMON_CFLAGS: - -DTARGET_mipsel + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=mipsel-unknown-linux-musl - name: i386 implies: [cross-compiler] variables: @@ -79,6 +93,9 @@ tags: QEMU_NAME: i386 COMMON_CFLAGS: - -DTARGET_i386 + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=i386-gentoo-linux-musl - name: s390x implies: [cross-compiler] variables: @@ -87,6 +104,9 @@ tags: QEMU_NAME: s390x COMMON_CFLAGS: - -DTARGET_s390x + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=s390x-ibm-linux-musl - name: aarch64 implies: [cross-compiler] variables: @@ -95,3 +115,29 @@ tags: QEMU_NAME: aarch64 COMMON_CFLAGS: - -DTARGET_aarch64 + CLANG_CFLAGS: + # TODO: symlink `clang --target=$TARGET` to `$TARGET-clang`. + - --target=aarch64-unknown-linux-musl + + - name: apple-x86-64 + implies: [x86-64, apple, clang] + variables: + APPLE_NAME: x86_64 + APPLE_TRIPLE: x86_64-apple-darwin11 + - name: apple-aarch64 + implies: [aarch64, apple, clang] + variables: + APPLE_NAME: arm64 + APPLE_TRIPLE: aarch64-apple-darwin11 + CLANG_CFLAGS: + - -mcpu=apple-m1 + - name: apple-i386 + implies: [i386, apple, clang] + variables: + APPLE_NAME: x86 + APPLE_TRIPLE: i686-apple-darwin11 + - name: apple-arm + implies: [arm, apple, clang] + variables: + APPLE_NAME: arm + APPLE_TRIPLE: arm-apple-darwin11 diff --git a/share/revng/test/configuration/revng-qa/compile.yml b/share/revng/test/configuration/revng-qa/compile.yml index e4288240..03329b94 100644 --- a/share/revng/test/configuration/revng-qa/compile.yml +++ b/share/revng/test/configuration/revng-qa/compile.yml @@ -1,33 +1,39 @@ tags: - - name: clang - name: simple-executable - name: stripped - name: with-debug-info + commands: - type: revng-qa.compiled-with-debug-info from: - type: source filter: linux and simple-executable and !clang command: ${TRIPLE}gcc $INPUT -o $OUTPUT $GCC_CFLAGS $COMMON_CFLAGS + - type: revng-qa.compiled-with-debug-info from: - type: source filter: linux and simple-executable and clang - command: ${TRIPLE}clang $INPUT -o $OUTPUT $GCC_CFLAGS $COMMON_CFLAGS + command: ${TRIPLE}clang $INPUT -o $OUTPUT $GCC_CFLAGS $COMMON_CFLAGS $CLANG_CFLAGS + - type: revng-qa.compiled-stripped from: - type: revng-qa.compiled-with-debug-info - command: ${TRIPLE}strip $INPUT -o $OUTPUT + command: llvm-objcopy --strip-all $INPUT $OUTPUT + - type: revng-qa.compiled tags: [with-debug-info] from: - type: revng-qa.compiled-with-debug-info + filter: "!clang" command: cp $INPUT $OUTPUT + - type: revng-qa.compiled tags: [stripped] from: - type: revng-qa.compiled-stripped command: cp $INPUT $OUTPUT + - type: revng-qa.disassembled from: - type: revng-qa.compiled diff --git a/share/revng/test/configuration/revng-qa/for-import-pe.yml b/share/revng/test/configuration/revng-qa/for-import-pe.yml index 079802fc..1952292c 100644 --- a/share/revng/test/configuration/revng-qa/for-import-pe.yml +++ b/share/revng/test/configuration/revng-qa/for-import-pe.yml @@ -14,6 +14,9 @@ tags: - name: vc19-x86-64 variables: MSVC_TRIPLE: "x86_64-winsdk-vc19-" + - name: vc19-aarch64 + variables: + MSVC_TRIPLE: "aarch64-winsdk-vc19-" - name: vc19-i386 variables: MSVC_TRIPLE: "i386-winsdk-vc19-" @@ -24,6 +27,7 @@ sources: - tags: [windows, for-import-pe, simple-executable] repeat-for: - [vc19-x86-64] + - [vc19-aarch64] - [vc19-i386] - [vc16-i386] prefix: share/revng/test/tests/model/import/pe diff --git a/share/revng/test/configuration/revng-qa/for-invalidation.yml b/share/revng/test/configuration/revng-qa/for-invalidation.yml index da86ef56..a5d24517 100644 --- a/share/revng/test/configuration/revng-qa/for-invalidation.yml +++ b/share/revng/test/configuration/revng-qa/for-invalidation.yml @@ -2,7 +2,7 @@ tags: - name: for-invalidation variables: GCC_CFLAGS: - - -Wl,--section-start=.text=0x500000 + - -Wl,--section-start=.text=0x500000 sources: - tags: diff --git a/share/revng/test/configuration/revng-qa/for-runtime-abi-tests.yml b/share/revng/test/configuration/revng-qa/for-runtime-abi-tests.yml index 31a0c869..8b708df5 100644 --- a/share/revng/test/configuration/revng-qa/for-runtime-abi-tests.yml +++ b/share/revng/test/configuration/revng-qa/for-runtime-abi-tests.yml @@ -7,6 +7,14 @@ tags: # Safeguard in case somebody tries using it with msvc - -DABIDEF=UNSUPPORTED + - name: x86-64-apple-abi + implies: [apple-x86-64] + variables: + ABI_NAME: SystemV_x86_64 + MSVC_CFLAGS: + # Safeguard in case somebody tries using it with msvc + - -DABIDEF=UNSUPPORTED + - name: x86-64-microsoft-abi implies: [x86-64] variables: @@ -33,6 +41,14 @@ tags: # Safeguard in case somebody tries using it with msvc - -DABIDEF=UNSUPPORTED + - name: i386-apple-abi + implies: [apple-i386, clang] + variables: + ABI_NAME: SystemV_x86 + MSVC_CFLAGS: + # Safeguard in case somebody tries using it with msvc + - -DABIDEF=UNSUPPORTED + - name: i386-regparm-3-systemv-abi implies: [i386] variables: @@ -138,11 +154,32 @@ tags: variables: ABI_NAME: AAPCS64 + - name: aarch64-aapcs64-microsoft-abi + implies: [aarch64] + variables: + ABI_NAME: Microsoft_AAPCS64 + GCC_CFLAGS: + # Safeguard in case somebody tries using it with gcc + - -DABIDEF=UNSUPPORTED + + - name: aarch64-aapcs64-apple-abi + implies: [apple-aarch64] + variables: + ABI_NAME: Apple_AAPCS64 + MSVC_CFLAGS: + # Safeguard in case somebody tries using it with gcc + - -DABIDEF=UNSUPPORTED + - name: arm-aapcs-abi implies: [arm] variables: ABI_NAME: AAPCS + - name: arm-aapcs-apple-abi + implies: [apple-arm] + variables: + ABI_NAME: AAPCS + - name: mips-systemv-abi implies: [mips] variables: @@ -171,6 +208,10 @@ sources: repeat-for: - [x86-64-systemv-abi] + # This test is temporarily disabled because of a clang bug. + # (https://github.com/llvm/llvm-project/issues/55844) + # - [x86-64-apple-abi] + - [x86-64-microsoft-abi, windows] - [x86-64-vectorcall-microsoft-abi, windows] @@ -190,11 +231,20 @@ sources: - [i386-stdcall-microsoft-abi, windows] - [i386-vectorcall-microsoft-abi, windows] - # TODO: re-enable once arm64 support is fixed. - # - [aarch64-aapcs64-abi] + # Disabled for now because `ld64.lld` does not recognize the architecture + # TODO: look further into this. + # - [i386-apple-abi] + + - [aarch64-aapcs64-abi] + - [aarch64-aapcs64-apple-abi] + - [aarch64-aapcs64-microsoft-abi, windows] - [arm-aapcs-abi] + # Disabled for now because `ld64.lld` does not recognize the architecture + # TODO: look further into this. + # - [arm-aapcs-apple-abi] + # TODO: re-enable once mips testing suite is fixed. # - [mips-systemv-abi] # - [mipsel-systemv-abi] @@ -209,15 +259,59 @@ commands: - type: revng-qa.runtime-abi-tests from: - type: source - filter: for-runtime-abi-tests and !windows + filter: for-runtime-abi-tests and !windows and !apple suffix: / command: |- - "${INPUT}/build_abi_test_binaries_with_gcc.sh" + source "${INPUT}/prepare-functions-binary.sh"; + prepare-linux-functions + "${TRIPLE}" + "${GCC_CFLAGS} ${COMMON_CFLAGS}" + "${INPUT}" + "${OUTPUT}"; + + source "${INPUT}/prepare-foreign-executable.sh"; + prepare-linux-foreign-executable + "${TRIPLE}" + "${GCC_CFLAGS} ${COMMON_CFLAGS}" + "${OBJDUMP_FLAGS}" + "${INPUT}" + "${OUTPUT}"; + + source "${INPUT}/prepare-the-runner.sh"; + prepare-the-runner + "${TRIPLE}" + "${GCC_CFLAGS} ${COMMON_CFLAGS}" "${INPUT}" "${OUTPUT}" + + - type: revng-qa.runtime-abi-tests + from: + - type: source + filter: for-runtime-abi-tests and !windows and apple + suffix: / + command: |- + source "${INPUT}/prepare-functions-binary.sh"; + prepare-apple-functions "${TRIPLE}" "${GCC_CFLAGS} ${COMMON_CFLAGS}" + "${INPUT}" + "${OUTPUT}"; + + source "${INPUT}/prepare-foreign-executable.sh"; + prepare-apple-foreign-executable + "${APPLE_TRIPLE}" + "${GCC_CFLAGS} ${COMMON_CFLAGS}" "${OBJDUMP_FLAGS}" + "${APPLE_NAME}" + "${INPUT}" + "${OUTPUT}"; + + source "${INPUT}/prepare-the-runner.sh"; + prepare-the-runner + "${TRIPLE}" + "${GCC_CFLAGS} ${COMMON_CFLAGS}" + "${INPUT}" + "${OUTPUT}" - type: revng-qa.runtime-abi-tests from: @@ -229,15 +323,41 @@ commands: MSVC_TRIPLE="x86_64-winsdk-vc19-"; elif [[ "${QEMU_NAME}" =~ ^i386$$ ]]; then MSVC_TRIPLE="i386-winsdk-vc19-"; + elif [[ "${QEMU_NAME}" =~ ^aarch64$$ ]]; then + MSVC_TRIPLE="aarch64-winsdk-vc19-"; else echo "Unsupported architecture" > /dev/stderr; exit 1; fi; - "${INPUT}/build_abi_test_binaries_with_msvc.sh" - "${INPUT}" - "${OUTPUT}" - "${TRIPLE}" + + INPUT_DIRECTORY="$$(realpath "$INPUT")" + OUTPUT_DIRECTORY="$$(realpath "$OUTPUT")" + + WORKDIR="$$(mktemp -d)" && + trap 'rm -rf "$$WORKDIR"' EXIT && + pushd "$$WORKDIR" >& /dev/null && + + source "${INPUT}/prepare-functions-binary.sh" && + prepare-windows-functions + "$${MSVC_TRIPLE}" + "${MSVC_CFLAGS} ${COMMON_CFLAGS}" + "${MSVC_LDFLAGS}" + "$${INPUT_DIRECTORY}" + "$${OUTPUT_DIRECTORY}" && + + source "${INPUT}/prepare-foreign-executable.sh" && + prepare-windows-foreign-executable "$${MSVC_TRIPLE}" - "${GCC_CFLAGS} ${COMMON_CFLAGS}" "${MSVC_CFLAGS} ${COMMON_CFLAGS}" - "${MSVC_LDFLAGS}"; + "${MSVC_LDFLAGS}" + "$${INPUT_DIRECTORY}" + "$${OUTPUT_DIRECTORY}" && + + source "${INPUT}/prepare-the-runner.sh" && + prepare-the-runner + "${TRIPLE}" + "${GCC_CFLAGS} ${COMMON_CFLAGS}" + "$${INPUT_DIRECTORY}" + "$${OUTPUT_DIRECTORY}" && + + popd >& /dev/null diff --git a/share/revng/test/tests/abi/build_abi_test_binaries_with_gcc.sh b/share/revng/test/tests/abi/build_abi_test_binaries_with_gcc.sh deleted file mode 100755 index 9c8c66b4..00000000 --- a/share/revng/test/tests/abi/build_abi_test_binaries_with_gcc.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -set -euo pipefail - -if [ $# -gt 5 ] || [ $# -lt 4 ]; then - echo "$0 INPUT_DIRECTORY OUTPUT_DIRECTORY TRIPLE CFLAGS [OBJDUMP_FLAGS]" > /dev/stderr - exit 1 -fi - -INPUT_DIRECTORY="$1" -OUTPUT_DIRECTORY="$2" -TRIPLE="$3" -CFLAGS="$4" -OBJDUMP_FLAGS="$5" - -test -n "${INPUT_DIRECTORY}" -test -n "${OUTPUT_DIRECTORY}" -test -n "${TRIPLE}" -test -n "${CFLAGS}" - -mkdir -p "${OUTPUT_DIRECTORY}" - -# Build the "functions" binary -"${TRIPLE}gcc" \ - ${CFLAGS} -O3 -ggdb3 -static \ - "${INPUT_DIRECTORY}/functions.c" \ - -o "${OUTPUT_DIRECTORY}/functions" - -# Build the binary for runner to `mmap` -"${TRIPLE}gcc" \ - ${CFLAGS} -O3 -static \ - -Wl,--section-start=.text=0x2000000 \ - -fno-zero-initialized-in-bss \ - "${INPUT_DIRECTORY}/setup.c" \ - -o "${OUTPUT_DIRECTORY}/foreign-executable" - -# Run `objdump` on it -"${TRIPLE}objdump" \ - ${OBJDUMP_FLAGS} \ - --wide -h \ - "${OUTPUT_DIRECTORY}/foreign-executable" \ - > "${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" -${TRIPLE}objdump \ - ${OBJDUMP_FLAGS} \ - --wide -t \ - "${OUTPUT_DIRECTORY}/foreign-executable" \ - > "${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" -${TRIPLE}objdump \ - ${OBJDUMP_FLAGS} \ - --wide --no-show-raw-insn -d \ - "${OUTPUT_DIRECTORY}/foreign-executable" \ - > "${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" - -# Run `gather_symbols.py` -python3 "${INPUT_DIRECTORY}/gather_symbols.py" \ - "expected_state value_dumps address_dumps size_dumps" \ - "${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" \ - "${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" \ - "${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" \ - > "${OUTPUT_DIRECTORY}/gathered_symbols.h" - -# Build the `runner` -"${TRIPLE}gcc" \ - ${CFLAGS} -O3 -D_GNU_SOURCE -static \ - -I"${OUTPUT_DIRECTORY}" \ - "${INPUT_DIRECTORY}/runner.c" \ - "${INPUT_DIRECTORY}/decoders.c" \ - -o "${OUTPUT_DIRECTORY}/probe-calls" diff --git a/share/revng/test/tests/abi/build_abi_test_binaries_with_msvc.sh b/share/revng/test/tests/abi/build_abi_test_binaries_with_msvc.sh deleted file mode 100755 index be57c257..00000000 --- a/share/revng/test/tests/abi/build_abi_test_binaries_with_msvc.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash - -# -# This file is distributed under the MIT License. See LICENSE.md for details. -# - -set -euo pipefail - -if [ $# -gt 7 ]; then - echo "$0 INPUT_DIRECTORY OUTPUT_DIRECTORY TRIPLE MSVC_TRIPLE CFLAGS MSVC_CFLAGS LDFLAGS" > /dev/stderr - exit 1 -fi - -INPUT_DIRECTORY="$1" -OUTPUT_DIRECTORY="$2" -TRIPLE="$3" -MSVC_TRIPLE="$4" -CFLAGS="$5" -MSVC_CFLAGS="$6" -LDFLAGS="$7" - -test -n "${INPUT_DIRECTORY}" -test -n "${OUTPUT_DIRECTORY}" -test -n "${TRIPLE}" -test -n "${MSVC_TRIPLE}" -test -n "${CFLAGS}" -test -n "${MSVC_CFLAGS}" -test -n "${LDFLAGS}" - -mkdir -p "${OUTPUT_DIRECTORY}" - -OUTPUT_DIRECTORY="$(realpath "$OUTPUT_DIRECTORY")" -INPUT_DIRECTORY="$(realpath "$INPUT_DIRECTORY")" - -# Build the "functions" binary - -# Move to a temporary directory before using cl.exe -WORKDIR="$(mktemp -d)" -trap 'rm -rf "$WORKDIR"' EXIT -pushd "$WORKDIR" >& /dev/null - -timeout 30 ${MSVC_TRIPLE}cl \ - ${MSVC_CFLAGS} -O2 -std:c11 -Zi -GS- \ - "z:\\${INPUT_DIRECTORY}/functions.c" \ - -Fe"z:\\${OUTPUT_DIRECTORY}/functions.exe" \ - -link ${LDFLAGS} /opt:ref,noicf \ - /pdb:"z:\\${OUTPUT_DIRECTORY}/functions.pdb" \ - /map:"z:\\${OUTPUT_DIRECTORY}/functions.map" - -# Build the binary for runner to `mmap` -timeout 30 ${MSVC_TRIPLE}cl \ - ${MSVC_CFLAGS} -O2 -std:c11 -Zi -GS- \ - "z:\\${INPUT_DIRECTORY}/setup.c" \ - -Fe"z:\\${OUTPUT_DIRECTORY}/foreign-executable.exe" \ - -link ${LDFLAGS} /opt:ref,noicf /ignore:4281 \ - /dynamicbase:no /base:0x2000000 /fixed /filealign:4096 \ - /pdb:"z:\\${OUTPUT_DIRECTORY}/foreign-executable.pdb" \ - /map:"z:\\${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" - -popd >& /dev/null - -# Run `dumpbin` on it -timeout 120 ${MSVC_TRIPLE}dumpbin \ - -nologo -headers \ - z:\\"${OUTPUT_DIRECTORY}/foreign-executable.exe" \ - -out:z:\\"${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" -timeout 120 ${MSVC_TRIPLE}dumpbin \ - -nologo -symbols -disasm:nobytes \ - z:\\"${OUTPUT_DIRECTORY}/foreign-executable.exe" \ - -out:z:\\"${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" - -# Run `gather_symbols.py` -timeout 30 python3 "${INPUT_DIRECTORY}/gather_symbols.py" \ - "expected_state value_dumps address_dumps size_dumps" \ - "${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" \ - "${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" \ - "${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" \ - > "${OUTPUT_DIRECTORY}/gathered_symbols.h" - -# Build the `runner` -${TRIPLE}gcc \ - ${CFLAGS} -O3 -D_GNU_SOURCE -static \ - -I"${OUTPUT_DIRECTORY}" \ - "${INPUT_DIRECTORY}/runner.c" \ - "${INPUT_DIRECTORY}/decoders.c" \ - -o "${OUTPUT_DIRECTORY}/probe-calls" - -# For consistency with the gcc toolchain, rename binaries -mv "${OUTPUT_DIRECTORY}/functions.exe" "${OUTPUT_DIRECTORY}/functions" -mv "${OUTPUT_DIRECTORY}/foreign-executable.exe" "${OUTPUT_DIRECTORY}/foreign-executable" diff --git a/share/revng/test/tests/abi/gather_symbols.py b/share/revng/test/tests/abi/gather_symbols.py index 9d5a7d42..086f4b3f 100644 --- a/share/revng/test/tests/abi/gather_symbols.py +++ b/share/revng/test/tests/abi/gather_symbols.py @@ -70,8 +70,8 @@ def list_symbols(self): rb"\n0+([a-fA-F0-9]+)\s+" # address (without leading 0s) + rb"(\w+)\s+" # symbol type (local, global, etc) + rb"(?:(\w+)\s+|)" # optional extra flags (weak, debug, etc) - + rb"([\*\.\w]+)\s+" # section symbol belongs to - + rb"([a-fA-F0-9]+)\s+" # either alignment or size of the symbol + + rb"([\*\.\w,]+)\s+" # section symbol belongs to + + rb"([a-fA-F0-9]+|)\s*" # either alignment or size of the symbol (optional) + rb"([\w\._-]+)+", # name of the symbol self.symbols, ): @@ -103,11 +103,12 @@ def find_section(self, name): def find_callsites(self, name): result = [] for match in re.finditer( - rb"\n\s+0*([a-fA-F0-9]+):" # address (without leading 0s) + rb"\n\s*0*([a-fA-F0-9]+):" # address (without leading 0s) + rb"[^<\n]*<" # any number of non-`<` characters followed by `<` + + rb"(?:_|)" # an optional `_` prefix + bytes(name, "utf-8") # name + rb">\n" # `>` character and a new line - + rb"\s+0*([a-fA-F0-9]+)", # address of the next instruction + + rb"\s*0*([a-fA-F0-9]+)", # address of the next instruction self.disassembly, ): result.append((match[1].decode("utf-8"), match[2].decode("utf-8"))) @@ -115,6 +116,36 @@ def find_callsites(self, name): return result +class MachoObjdumpOutputParser(ObjdumpOutputParser): + def __init__(self, *args): + super().__init__(*args) + + def find_section(self, name): + assert len(name) > 0 + assert name[0] == "." + + match = re.search( + rb" segname __" + + bytes(name[1:].upper(), "utf-8") + + rb"\n" # name + + rb" vmaddr 0x0*(\w+)\n" # virtual address + + rb" vmsize 0x0*(\w+)\n" # size + + rb" fileoff 0*(\w+)\n", # offset + self.sections, + ) + if match: + offset = int(match[3].decode("utf-8")) + offset_string = "0" if offset == 0 else hex(offset).lstrip("0x") + return Section( + name, + match[2].decode("utf-8"), # size + match[1].decode("utf-8"), # vma + offset_string, # offset + ) + else: + raise Exception("unable to find a section: '" + name + "'") + + class DumpbinOutputParser(DisassemblyParser): def __init__(self, *args): super().__init__(*args) @@ -173,6 +204,8 @@ def find_callsites(self, name): def select_parser(sections, symbols, disassembly): if re.match(rb"^\n[^:]+:\s+file format elf.+\n", sections): return ObjdumpOutputParser(sections, symbols, disassembly) + elif re.match(rb"^\n[^:]+:\s+file format mach-o.+\n", sections): + return MachoObjdumpOutputParser(sections, symbols, disassembly) elif re.match(rb"^\r\nDump of file .*\.exe\r\n\r\nPE signature found\r\n", sections): return DumpbinOutputParser(sections, symbols, disassembly) else: @@ -368,6 +401,7 @@ def main(): result = Gathered() result.sections.append(parser.find_section(".text")) + result.sections.append(parser.find_section(".data")) list_of_symbols_to_extract = arguments.list_of_symbols_to_extract.split() for name, address in parser.list_symbols().items(): diff --git a/share/revng/test/tests/abi/musl_memory_functions.c b/share/revng/test/tests/abi/musl_memory_functions.c new file mode 100644 index 00000000..29f04f09 --- /dev/null +++ b/share/revng/test/tests/abi/musl_memory_functions.c @@ -0,0 +1,87 @@ +// These functions were copied from the musl implementation. +// The license: +// +// ---------------------------------------------------------------------- +// Copyright © 2005-2020 Rich Felker, et al. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ---------------------------------------------------------------------- + +#include +#include +#include + +int memcmp(const void *vl, const void *vr, size_t n) { + const unsigned char *l = vl, *r = vr; + for (; n && *l == *r; n--, l++, r++) + ; + return n ? *l - *r : 0; +} + +void *memset(void *dest, int c, size_t n) { + unsigned char *s = dest; + size_t k; + + /* Fill head and tail with minimal branching. Each + * conditional ensures that all the subsequently used + * offsets are well-defined and in the dest region. */ + + if (!n) + return dest; + s[0] = s[n - 1] = c; + if (n <= 2) + return dest; + s[1] = s[n - 2] = c; + s[2] = s[n - 3] = c; + if (n <= 6) + return dest; + s[3] = s[n - 4] = c; + if (n <= 8) + return dest; + + /* Advance pointer to align it at a 4-byte boundary, + * and truncate n to a multiple of 4. The previous code + * already took care of any head/tail that get cut off + * by the alignment. */ + + k = -(uintptr_t) s & 3; + s += k; + n -= k; + n &= -4; + + /* Pure C fallback with no aliasing violations. */ + for (; n; n--, s++) + *s = c; + + return dest; +} + +void *memcpy(void *restrict dest, const void *restrict src, size_t n) { + unsigned char *d = dest; + const unsigned char *s = src; + + for (; n; n--) + *d++ = *s++; + return dest; +} + +void *memmove(void *dest, const void *src, size_t n) { + return memcpy(dest, src, n); +} diff --git a/share/revng/test/tests/abi/prepare-foreign-executable.sh b/share/revng/test/tests/abi/prepare-foreign-executable.sh new file mode 100644 index 00000000..8ddd3a1c --- /dev/null +++ b/share/revng/test/tests/abi/prepare-foreign-executable.sh @@ -0,0 +1,146 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +function prepare-linux-foreign-executable() { + if [ $# -ne 5 ]; then + echo 'prepare-linux-foreign-executable ${TRIPLE} ${CFLAGS} ${OBJDUMP_FLAGS} ${INPUT_DIRECTORY} ${OUTPUT_DIRECTORY}' > /dev/stderr + exit 1 + fi + + TRIPLE="$1" + CFLAGS="$2" + OBJDUMP_FLAGS="$3" + INPUT_DIRECTORY="$4" + OUTPUT_DIRECTORY="$5" + + # `-fno-zero-initialized-in-bss` is there for arms, as this leads to us not + # having to worry about mapping `.bss` too. + + "${TRIPLE}gcc" -c \ + ${CFLAGS} -O3 \ + -fno-zero-initialized-in-bss \ + -ffreestanding \ + "${INPUT_DIRECTORY}/setup.c" \ + -o "${OUTPUT_DIRECTORY}/foreign-executable.o" + "${TRIPLE}gcc" \ + ${CFLAGS} -O3 \ + -fno-tree-loop-distribute-patterns \ + -Wl,--section-start=.text=0x2000000 \ + -Wl,--section-start=.data=0x3000000 \ + -Wl,--entry=main \ + -nostdlib -nodefaultlibs \ + "${OUTPUT_DIRECTORY}/foreign-executable.o" \ + "${INPUT_DIRECTORY}/musl_memory_functions.c" \ + -o "${OUTPUT_DIRECTORY}/foreign-executable" + + "${TRIPLE}objdump" \ + ${OBJDUMP_FLAGS} \ + --wide -h \ + "${OUTPUT_DIRECTORY}/foreign-executable" \ + > "${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" + ${TRIPLE}objdump \ + ${OBJDUMP_FLAGS} \ + --wide -t \ + "${OUTPUT_DIRECTORY}/foreign-executable" \ + > "${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" + ${TRIPLE}objdump \ + ${OBJDUMP_FLAGS} \ + --wide --no-show-raw-insn -d \ + "${OUTPUT_DIRECTORY}/foreign-executable" \ + > "${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" +} + +function prepare-apple-foreign-executable() { + if [ $# -ne 6 ]; then + echo 'prepare-apple-foreign-executable ${TRIPLE} ${CFLAGS} ${OBJDUMP_FLAGS} ${APPLE_ARCHITECTURE_NAME} ${INPUT_DIRECTORY} ${OUTPUT_DIRECTORY}' > /dev/stderr + exit 1 + fi + + TRIPLE="$1" + CFLAGS="$2" + OBJDUMP_FLAGS="$3" + APPLE_ARCHITECTURE_NAME="$4" + INPUT_DIRECTORY="$5" + OUTPUT_DIRECTORY="$6" + + # TODO: add a symlink from `${TRIPLE}clang` to `clang --target=${TRIPLE}` + # and use that instead + clang -c \ + --target=${TRIPLE} \ + ${CFLAGS} -O3 \ + -fno-zero-initialized-in-bss -ffreestanding \ + -fno-optimize-sibling-calls -fno-pic \ + -Wno-unused-command-line-argument \ + "${INPUT_DIRECTORY}/setup.c" \ + -o "${OUTPUT_DIRECTORY}/foreign-executable.o" + clang -c \ + --target=${TRIPLE} \ + ${CFLAGS} -O3 \ + -fno-zero-initialized-in-bss -ffreestanding \ + -nostdlib -nodefaultlibs -fno-pic \ + -Wno-pointer-to-int-cast -Wno-unused-command-line-argument \ + "${INPUT_DIRECTORY}/musl_memory_functions.c" \ + -o "${OUTPUT_DIRECTORY}/musl_memory_functions.o" + + # TODO: add a symlink for `${TRIPLE}ld64.lld` and use that instead + ld64.lld \ + -arch ${APPLE_ARCHITECTURE_NAME} \ + -platform_version macos 14.5 1 \ + "${OUTPUT_DIRECTORY}/foreign-executable.o" \ + "${OUTPUT_DIRECTORY}/musl_memory_functions.o" \ + -o "${OUTPUT_DIRECTORY}/foreign-executable" + + llvm-objdump \ + ${OBJDUMP_FLAGS} \ + --wide -p \ + "${OUTPUT_DIRECTORY}/foreign-executable" \ + > "${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" + llvm-objdump \ + ${OBJDUMP_FLAGS} \ + --wide -t \ + "${OUTPUT_DIRECTORY}/foreign-executable" \ + > "${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" + llvm-objdump \ + ${OBJDUMP_FLAGS} \ + --wide --no-show-raw-insn -d \ + "${OUTPUT_DIRECTORY}/foreign-executable" \ + > "${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" +} + +function prepare-windows-foreign-executable() { + if [ $# -ne 5 ]; then + echo 'prepare-windows-foreign-executable ${TRIPLE} ${CFLAGS} ${LDFLAGS} ${INPUT_DIRECTORY} ${OUTPUT_DIRECTORY}' > /dev/stderr + exit 1 + fi + + TRIPLE="$1" + CFLAGS="$2" + LDFLAGS="$3" + INPUT_DIRECTORY="$4" + OUTPUT_DIRECTORY="$5" + + timeout 30 ${TRIPLE}cl -c \ + ${CFLAGS} -O2 -std:c11 -Zi -GS- \ + "z:\\${INPUT_DIRECTORY}/setup.c" \ + -Fo"z:\\${OUTPUT_DIRECTORY}/foreign-executable.obj" + timeout 30 ${TRIPLE}link \ + ${LDFLAGS} /opt:ref,noicf /filealign:4096 \ + /ignore:4281 /nodefaultlib /entry:main /subsystem:console \ + "z:\\${OUTPUT_DIRECTORY}/foreign-executable.obj" \ + /out:"z:\\${OUTPUT_DIRECTORY}/foreign-executable.exe" \ + /pdb:"z:\\${OUTPUT_DIRECTORY}/foreign-executable.pdb" \ + /map:"z:\\${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" + + timeout 120 ${MSVC_TRIPLE}dumpbin \ + -nologo -headers \ + z:\\"${OUTPUT_DIRECTORY}/foreign-executable.exe" \ + -out:z:\\"${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" + timeout 120 ${MSVC_TRIPLE}dumpbin \ + -nologo -symbols -disasm:nobytes \ + z:\\"${OUTPUT_DIRECTORY}/foreign-executable.exe" \ + -out:z:\\"${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" + + # For consistency with the other toolchains, rename the binary + mv "${OUTPUT_DIRECTORY}/foreign-executable.exe" "${OUTPUT_DIRECTORY}/foreign-executable" +} diff --git a/share/revng/test/tests/abi/prepare-functions-binary.sh b/share/revng/test/tests/abi/prepare-functions-binary.sh new file mode 100644 index 00000000..63b2e1d3 --- /dev/null +++ b/share/revng/test/tests/abi/prepare-functions-binary.sh @@ -0,0 +1,54 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +function prepare-linux-functions() { + if [ $# -ne 4 ]; then + echo 'prepare-linux-functions ${TRIPLE} ${CFLAGS} ${INPUT_DIRECTORY} ${OUTPUT_DIRECTORY}' > /dev/stderr + exit 1 + fi + + TRIPLE="$1" + CFLAGS="$2" + INPUT_DIRECTORY="$3" + OUTPUT_DIRECTORY="$4" + + "${TRIPLE}gcc" \ + ${CFLAGS} -O3 -ggdb3 -static \ + "${INPUT_DIRECTORY}/functions.c" \ + -o "${OUTPUT_DIRECTORY}/functions" +} + +function prepare-apple-functions() { + # NOTE: Since macho support in revng is currently limited, temporarily build + # this binary with no regard to the specific architecture this code is + # testing. We can get away with that since it's only ever used to extract + # information about the prototypes from (in this case) dwarf. + # TODO: when our macho support improves, switch to the proper binary, so that + # it serves as an extra test of the importer. + prepare-linux-functions "$@" +} + +function prepare-windows-functions() { + if [ $# -ne 5 ]; then + echo 'prepare-windows-functions ${TRIPLE} ${CFLAGS} ${LDFLAGS} ${INPUT_DIRECTORY} ${OUTPUT_DIRECTORY}' > /dev/stderr + exit 1 + fi + + TRIPLE="$1" + CFLAGS="$2" + LDFLAGS="$3" + INPUT_DIRECTORY="$4" + OUTPUT_DIRECTORY="$5" + + timeout 30 ${TRIPLE}cl \ + ${CFLAGS} -O2 -std:c11 -Zi -GS- \ + "z:\\${INPUT_DIRECTORY}/functions.c" \ + -Fe"z:\\${OUTPUT_DIRECTORY}/functions.exe" \ + -link ${LDFLAGS} /opt:ref,noicf \ + /pdb:"z:\\${OUTPUT_DIRECTORY}/functions.pdb" \ + /map:"z:\\${OUTPUT_DIRECTORY}/functions.map" + + # For consistency with the other toolchains, rename the binary + mv "${OUTPUT_DIRECTORY}/functions.exe" "${OUTPUT_DIRECTORY}/functions" +} diff --git a/share/revng/test/tests/abi/prepare-the-runner.sh b/share/revng/test/tests/abi/prepare-the-runner.sh new file mode 100644 index 00000000..a626d6c0 --- /dev/null +++ b/share/revng/test/tests/abi/prepare-the-runner.sh @@ -0,0 +1,31 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +function prepare-the-runner() { + if [ $# -ne 4 ]; then + echo 'prepare-the-runner ${TRIPLE} ${CFLAGS} ${INPUT_DIRECTORY} ${OUTPUT_DIRECTORY}' > /dev/stderr + exit 1 + fi + + TRIPLE="$1" + CFLAGS="$2" + INPUT_DIRECTORY="$3" + OUTPUT_DIRECTORY="$4" + + # Run `gather_symbols.py`: it outputs a header that is used when building the runner. + python3 "${INPUT_DIRECTORY}/gather_symbols.py" \ + "expected_state value_dumps address_dumps size_dumps" \ + "${OUTPUT_DIRECTORY}/foreign-executable-sections.txt" \ + "${OUTPUT_DIRECTORY}/foreign-executable-symbols.txt" \ + "${OUTPUT_DIRECTORY}/foreign-executable-disassembly.txt" \ + > "${OUTPUT_DIRECTORY}/gathered_symbols.h" + + # Build the `runner` + "${TRIPLE}gcc" \ + ${CFLAGS} -O3 -D_GNU_SOURCE -static \ + -I"${OUTPUT_DIRECTORY}" \ + "${INPUT_DIRECTORY}/runner.c" \ + "${INPUT_DIRECTORY}/decoders.c" \ + -o "${OUTPUT_DIRECTORY}/probe-calls" +} diff --git a/share/revng/test/tests/abi/runner.c b/share/revng/test/tests/abi/runner.c index c0fdb3db..188bbfa6 100644 --- a/share/revng/test/tests/abi/runner.c +++ b/share/revng/test/tests/abi/runner.c @@ -204,21 +204,33 @@ int main(int argc, char **argv) { } const struct section *text_section = select_a_section(".text"); - assert(text_section != NULL); - - void *mapped = mmap((void *) (size_t) text_section->vma, - binary_file_stats.st_size, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_FIXED, - binary_file, - text_section->file_offset); - if (mapped == MAP_FAILED) { + const struct section *data_section = select_a_section(".data"); + assert(text_section != NULL && data_section != NULL); + + assert((size_t) text_section->vma % 0x1000 == 0); + void *mapped_text = mmap((void *) (size_t) text_section->vma, + binary_file_stats.st_size, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_FIXED, + binary_file, + text_section->file_offset); + + assert((size_t) data_section->vma % 0x1000 == 0); + void *mapped_data = mmap((void *) (size_t) data_section->vma, + binary_file_stats.st_size, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_FIXED, + binary_file, + data_section->file_offset); + + if (mapped_text == MAP_FAILED || mapped_data == MAP_FAILED) { puts("`mmap` failed."); return 4; } - if (mapped != (void *) (size_t) text_section->vma) { - puts("`mmap` couldn't provide the expected virtual address. Should 'inner' " - "binary be compiled with a different `section-start` value?"); + if (mapped_text != (void *) (size_t) text_section->vma + || mapped_data != (void *) (size_t) data_section->vma) { + puts("`mmap` couldn't provide the expected virtual address. " + "Use a different `section-start` value for the 'inner' binary."); return 5; } @@ -261,11 +273,17 @@ int main(int argc, char **argv) { free_the_stored_state(); - success = munmap(mapped, binary_file_stats.st_size); + success = munmap(mapped_text, binary_file_stats.st_size); if (success == -1) { puts("`munmap` failed."); return 6; } + success = munmap(mapped_data, binary_file_stats.st_size); + if (success == -1) { + puts("`munmap` failed."); + return 6; + } + success = close(binary_file); if (success == -1) { puts("`close` failed."); diff --git a/share/revng/test/tests/analysis/Decompilation/x86-64/dual-case-switch.c b/share/revng/test/tests/analysis/Decompilation/x86-64/dual-case-switch.c index e0916b1b..bcda2914 100644 --- a/share/revng/test/tests/analysis/Decompilation/x86-64/dual-case-switch.c +++ b/share/revng/test/tests/analysis/Decompilation/x86-64/dual-case-switch.c @@ -44,7 +44,6 @@ WEAK uint64_t f(uint64_t arg1) { } } - report(1); goto LABEL_END; diff --git a/share/revng/test/tests/analysis/Decompilation/x86-64/pretty-ints.c b/share/revng/test/tests/analysis/Decompilation/x86-64/pretty-ints.c index 63097aca..51971c7b 100644 --- a/share/revng/test/tests/analysis/Decompilation/x86-64/pretty-ints.c +++ b/share/revng/test/tests/analysis/Decompilation/x86-64/pretty-ints.c @@ -2,8 +2,8 @@ // This file is distributed under the MIT License. See LICENSE.md for details. // -#include #include +#include #define WEAK __attribute__((weak)) @@ -50,7 +50,6 @@ int do_stuff() { + bitwise_xor(arg) + write_and_get_char(); } -WEAK -void _start() { +WEAK void _start() { do_stuff(); } diff --git a/share/revng/test/tests/analysis/Decompilation/x86-64/reduce-c-casts.c b/share/revng/test/tests/analysis/Decompilation/x86-64/reduce-c-casts.c index cd1c16c0..0fabf1d0 100644 --- a/share/revng/test/tests/analysis/Decompilation/x86-64/reduce-c-casts.c +++ b/share/revng/test/tests/analysis/Decompilation/x86-64/reduce-c-casts.c @@ -5,10 +5,10 @@ typedef unsigned int uint; typedef unsigned char uchar; -#define DECLARE_OPERATION(op, op_name, type1, type2) \ - __attribute__((weak)) type1 op_name##_##type1##_##type2(type1 a, type2 b) { \ - return a op b; \ - } +#define DECLARE_OPERATION(op, op_name, type1, type2) \ + __attribute__((weak)) type1 op_name##_##type1##_##type2(type1 a, type2 b) { \ + return a op b; \ + } DECLARE_OPERATION(+, add, uint, uchar) DECLARE_OPERATION(+, add, uchar, uint) diff --git a/share/revng/test/tests/analysis/Decompilation/x86-64/segments-and-sections.c b/share/revng/test/tests/analysis/Decompilation/x86-64/segments-and-sections.c index b1a5b2a8..30ba03c4 100644 --- a/share/revng/test/tests/analysis/Decompilation/x86-64/segments-and-sections.c +++ b/share/revng/test/tests/analysis/Decompilation/x86-64/segments-and-sections.c @@ -28,8 +28,7 @@ WEAK int sum_globals() { return TheData.x + TheData.y; } -WEAK -void _start() { +WEAK void _start() { print_string(); sum_globals(); } diff --git a/share/revng/test/tests/analysis/DetectStackSize/dynamic_native/memcpy-from-stack-arguments.c b/share/revng/test/tests/analysis/DetectStackSize/dynamic_native/memcpy-from-stack-arguments.c index bd053fef..a9067bb8 100644 --- a/share/revng/test/tests/analysis/DetectStackSize/dynamic_native/memcpy-from-stack-arguments.c +++ b/share/revng/test/tests/analysis/DetectStackSize/dynamic_native/memcpy-from-stack-arguments.c @@ -1,5 +1,5 @@ -#include #include +#include typedef struct { uint64_t data[512 / 8]; @@ -12,7 +12,8 @@ void memcpy_from_stack_arguments(data_512_t argument) { global = argument; } -void backward_memcpy_from_stack_arguments(data_512_t argument) __attribute__((weak)); +void backward_memcpy_from_stack_arguments(data_512_t argument) + __attribute__((weak)); void backward_memcpy_from_stack_arguments(data_512_t argument) { for (size_t I = 0; I < 512 / 8; ++I) { size_t inverse_index = 512 / 8 - I - 1; diff --git a/test-configure b/test-configure index 64a5727a..07a86321 100755 --- a/test-configure +++ b/test-configure @@ -179,7 +179,7 @@ class Variables: elif type(self.variables[name]) is not list: error(f"Key {name} is defined with different types") - self.variables[name] += value + self.variables[name] = value + self.variables[name] else: error(f"Unexpected type for variable {name}")