svf-lib 1.0.2639 → 1.0.2641

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -177,8 +177,10 @@ public:
177
177
  bool hasIntersect(const AddressValue &other) const
178
178
  {
179
179
  for (const auto& addr : _addrs)
180
+ {
180
181
  if (other._addrs.count(addr))
181
182
  return true;
183
+ }
182
184
  return false;
183
185
  }
184
186
 
@@ -536,7 +536,9 @@ class SparseBitVector
536
536
 
537
537
  // Make sure our current iterator is valid.
538
538
  if (CurrElementIter == End)
539
+ {
539
540
  --CurrElementIter;
541
+ }
540
542
 
541
543
  // Search from our current iterator, either backwards or forwards,
542
544
  // depending on what element we are looking for.
@@ -755,7 +757,9 @@ public:
755
757
  // is nothing more to do.
756
758
  if (ElementIter == Elements.end() ||
757
759
  ElementIter->index() != ElementIndex)
760
+ {
758
761
  return false;
762
+ }
759
763
  return ElementIter->test(Idx % ElementSize);
760
764
  }
761
765
 
@@ -4,30 +4,62 @@
4
4
 
5
5
  include(GNUInstallDirs)
6
6
 
7
+ set(_Z3_HINTS ${Z3_HOME} $ENV{Z3_HOME} ${Z3_DIR} $ENV{Z3_DIR})
8
+ set(_Z3_EXPLICIT_ROOT "")
9
+ foreach(_Z3_HINT IN LISTS _Z3_HINTS)
10
+ if(_Z3_HINT AND EXISTS "${_Z3_HINT}/include/z3++.h")
11
+ set(_Z3_EXPLICIT_ROOT "${_Z3_HINT}")
12
+ break()
13
+ endif()
14
+ endforeach()
15
+
7
16
  # Try upstream/system CONFIG package first; use it if found (sets required variables):
8
- find_package(Z3 CONFIG QUIET HINTS ${Z3_HOME} $ENV{Z3_HOME} ${Z3_DIR} $ENV{Z3_DIR})
17
+ if(NOT _Z3_EXPLICIT_ROOT)
18
+ find_package(Z3 CONFIG QUIET HINTS ${_Z3_HINTS})
19
+ endif()
9
20
  if(Z3_FOUND)
10
21
  if(NOT Z3_FIND_QUIETLY)
11
22
  message(STATUS "Found upstream/system Z3 package (Z3Config.cmake)")
12
23
  endif()
13
24
  else()
14
25
  if(NOT Z3_FIND_QUIETLY)
15
- message(STATUS "Failed to find upstream/system Z3 package; reverting to manual search")
26
+ if(_Z3_EXPLICIT_ROOT)
27
+ message(STATUS "Using explicit Z3 root: ${_Z3_EXPLICIT_ROOT}")
28
+ else()
29
+ message(STATUS "Failed to find upstream/system Z3 package; reverting to manual search")
30
+ endif()
16
31
  endif()
17
32
 
18
33
  # Fall back to explicit manual header + lib search (prioritise searching $Z3_DIR)
19
- find_library(
20
- Z3_LIBRARY_DIR
21
- NAMES z3 libz3
22
- HINTS ${Z3_HOME} $ENV{Z3_HOME} ${Z3_DIR} $ENV{Z3_DIR}
23
- PATH_SUFFIXES bin lib ${CMAKE_INSTALL_BINDIR} ${CMAKE_INSTALL_LIBDIR}
24
- )
25
- find_path(
26
- Z3_INCLUDE_DIR
27
- NAMES z3++.h
28
- HINTS ${Z3_HOME} $ENV{Z3_HOME} ${Z3_DIR} $ENV{Z3_DIR}
29
- PATH_SUFFIXES include ${CMAKE_INSTALL_INCLUDEDIR}
30
- )
34
+ if(_Z3_EXPLICIT_ROOT)
35
+ find_library(
36
+ Z3_LIBRARY_DIR
37
+ NAMES z3 libz3
38
+ HINTS ${_Z3_EXPLICIT_ROOT}
39
+ PATH_SUFFIXES bin lib ${CMAKE_INSTALL_BINDIR} ${CMAKE_INSTALL_LIBDIR}
40
+ NO_DEFAULT_PATH
41
+ )
42
+ find_path(
43
+ Z3_INCLUDE_DIR
44
+ NAMES z3++.h
45
+ HINTS ${_Z3_EXPLICIT_ROOT}
46
+ PATH_SUFFIXES include ${CMAKE_INSTALL_INCLUDEDIR}
47
+ NO_DEFAULT_PATH
48
+ )
49
+ else()
50
+ find_library(
51
+ Z3_LIBRARY_DIR
52
+ NAMES z3 libz3
53
+ HINTS ${_Z3_HINTS}
54
+ PATH_SUFFIXES bin lib ${CMAKE_INSTALL_BINDIR} ${CMAKE_INSTALL_LIBDIR}
55
+ )
56
+ find_path(
57
+ Z3_INCLUDE_DIR
58
+ NAMES z3++.h
59
+ HINTS ${_Z3_HINTS}
60
+ PATH_SUFFIXES include ${CMAKE_INSTALL_INCLUDEDIR}
61
+ )
62
+ endif()
31
63
 
32
64
  # If the headers were found, find & extract the Z3 version number
33
65
  set(_ver_h "${Z3_INCLUDE_DIR}/z3_version.h")
package/llvm_install.sh CHANGED
@@ -4,14 +4,125 @@ sysOS=`uname -s`
4
4
  arch=`uname -m`
5
5
  MajorLLVMVer=21
6
6
  LLVMVer=${MajorLLVMVer}.1.0
7
+ Z3Ver=4.15.4
7
8
  UbuntuLLVM_RTTI="https://github.com/bjjwwang/SVF-LLVM/releases/download/${LLVMVer}/llvm-${LLVMVer}-ubuntu22-rtti-x86-64.tar.gz"
8
9
  UbuntuArmLLVM_RTTI="https://github.com/bjjwwang/SVF-LLVM/releases/download/${LLVMVer}/llvm-${LLVMVer}-ubuntu22-rtti-aarch64.tar.gz"
9
10
 
10
- UbuntuZ3Arm="https://github.com/SVF-tools/SVF-npm/raw/prebuilt-libs/z3-4.8.7-aarch64-ubuntu.zip"
11
- UbuntuZ3="https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip"
11
+ Z3PrebuiltBase="https://github.com/SVF-tools/SVF-npm/raw/prebuilt-libs"
12
+ UbuntuZ3Arm="${Z3PrebuiltBase}/z3-${Z3Ver}-arm64-ubuntu-22.04.zip"
13
+ UbuntuZ3="${Z3PrebuiltBase}/z3-${Z3Ver}-x86_64-ubuntu-22.04.zip"
14
+ MacOSZ3Arm="${Z3PrebuiltBase}/z3-${Z3Ver}-arm64-macos-14.zip"
12
15
  Z3Home="z3.obj"
13
16
  LLVMHome="llvm-${LLVMVer}.obj"
14
17
 
18
+ function download_file {
19
+ if [[ $# -ne 2 ]]; then
20
+ echo "$0: bad args to download_file!"
21
+ exit 1
22
+ fi
23
+
24
+ local url="$1"
25
+ local out="$2"
26
+
27
+ local download_failed=false
28
+ if command -v curl >/dev/null 2>&1; then
29
+ if ! curl -fL "$url" -o "$out"; then
30
+ download_failed=true
31
+ fi
32
+ elif command -v wget >/dev/null 2>&1; then
33
+ if ! wget -c "$url" -O "$out"; then
34
+ download_failed=true
35
+ fi
36
+ else
37
+ echo "Cannot find curl or wget."
38
+ exit 1
39
+ fi
40
+
41
+ if $download_failed; then
42
+ echo "Failed to download $url"
43
+ rm -f "$out"
44
+ exit 1
45
+ fi
46
+ }
47
+
48
+ function find_z3_root {
49
+ local search_dir="$1"
50
+ local candidate=""
51
+
52
+ while IFS= read -r -d '' candidate; do
53
+ if [[ -d "$candidate/include" && -d "$candidate/bin" ]]; then
54
+ echo "$candidate"
55
+ return 0
56
+ fi
57
+ done < <(find "$search_dir" -type d -print0)
58
+
59
+ return 1
60
+ }
61
+
62
+ function unpack_z3_package {
63
+ if [[ $# -ne 2 ]]; then
64
+ echo "$0: bad args to unpack_z3_package!"
65
+ exit 1
66
+ fi
67
+
68
+ local archive="$1"
69
+ local target_dir="$2"
70
+ local unpack_dir="z3-unpack"
71
+ local nested_zip=""
72
+ local nested_dir=""
73
+ local z3_dir=""
74
+
75
+ rm -rf "$unpack_dir" "$target_dir"
76
+ mkdir "$unpack_dir"
77
+ unzip -q "$archive" -d "$unpack_dir"
78
+
79
+ while IFS= read -r -d '' nested_zip; do
80
+ nested_dir="$unpack_dir/nested-$(basename "$nested_zip" .zip)"
81
+ mkdir -p "$nested_dir"
82
+ unzip -q "$nested_zip" -d "$nested_dir"
83
+ done < <(find "$unpack_dir" -type f -name 'z3-*.zip' -print0)
84
+
85
+ if ! z3_dir=$(find_z3_root "$unpack_dir"); then
86
+ rm -rf "$unpack_dir"
87
+ echo "Z3 package did not contain the expected bin/ and include/ layout."
88
+ exit 1
89
+ fi
90
+
91
+ mv "$z3_dir" "$target_dir"
92
+ rm -rf "$unpack_dir"
93
+ }
94
+
95
+ function fix_linux_z3_links {
96
+ if [[ "$sysOS" != "Linux" ]]; then
97
+ return
98
+ fi
99
+
100
+ if [[ -f "$Z3_DIR/bin/libz3.so" ]]; then
101
+ ln -sf libz3.so "$Z3_DIR/bin/libz3.so.4"
102
+ fi
103
+ }
104
+
105
+ function fix_macos_z3_load_paths {
106
+ if [[ "$sysOS" != "Darwin" ]]; then
107
+ return
108
+ fi
109
+
110
+ local z3_dylib="$Z3_DIR/bin/libz3.dylib"
111
+ local z3_rpath="@loader_path/../../../${Z3Home}/bin"
112
+ local binary=""
113
+
114
+ if [[ -f "$z3_dylib" ]]; then
115
+ install_name_tool -id "@rpath/libz3.dylib" "$z3_dylib"
116
+ fi
117
+
118
+ while IFS= read -r -d '' binary; do
119
+ install_name_tool -change "/opt/homebrew/opt/z3/lib/libz3.4.15.dylib" "@rpath/libz3.dylib" "$binary" 2>/dev/null || true
120
+ install_name_tool -change "/opt/homebrew/opt/z3/lib/libz3.dylib" "@rpath/libz3.dylib" "$binary" 2>/dev/null || true
121
+ install_name_tool -change "libz3.dylib" "@rpath/libz3.dylib" "$binary" 2>/dev/null || true
122
+ install_name_tool -add_rpath "$z3_rpath" "$binary" 2>/dev/null || true
123
+ done < <(find "$SVFHOME/SVF-osx/bin" "$SVFHOME/SVF-osx/lib" \( -type f -perm -111 -o -name '*.dylib' \) -print0)
124
+ }
125
+
15
126
  if [[ $sysOS == "Darwin" ]]
16
127
  then
17
128
  # Create soft links for SvfLLVM
@@ -112,16 +223,18 @@ if [[ $sysOS == "Darwin" ]]
112
223
  then
113
224
  if [ ! -d "$install_path/$Z3Home" ]
114
225
  then
115
- echo 'Downloading z3 binary for MacOS '
116
- brew install z3
117
- if [ $? -eq 0 ]; then
118
- echo "z3 binary installation completed."
119
- else
120
- echo "z3 binary installation failed."
121
- exit 1
122
- fi
123
- mkdir -p $install_path/$Z3Home
124
- ln -s $(brew --prefix z3)/* $install_path/$Z3Home
226
+ if [[ $arch == "arm64" ]]
227
+ then
228
+ urlZ3=$MacOSZ3Arm
229
+ else
230
+ echo "No prebuilt z3 binary is available for MacOS ${arch}."
231
+ exit 1
232
+ fi
233
+ echo 'Downloading z3 binary for MacOS arm64'
234
+ download_file "$urlZ3" z3.zip
235
+ echo 'Unzipping z3 binary for MacOS'
236
+ unpack_z3_package z3.zip "$install_path/$Z3Home"
237
+ rm z3.zip
125
238
  fi
126
239
  elif [[ $sysOS == "Linux" ]]
127
240
  then
@@ -135,17 +248,18 @@ then
135
248
  fi
136
249
  if [ ! -d "$install_path/$Z3Home" ]
137
250
  then
138
- echo 'Downloading z3 binary for Ubuntu'
139
- wget -c $urlZ3 -O z3.zip
140
- mkdir $install_path/$Z3Home
141
- echo 'Unzipping z3 binary for Ubuntu'
142
- unzip -q "z3.zip" && mv ./z3-*/* $install_path/$Z3Home/
143
- rm z3.zip
251
+ echo 'Downloading z3 binary for Ubuntu'
252
+ download_file "$urlZ3" z3.zip
253
+ echo 'Unzipping z3 binary for Ubuntu'
254
+ unpack_z3_package z3.zip "$install_path/$Z3Home"
255
+ rm z3.zip
144
256
  fi
145
257
  else
146
258
  echo 'not support z3 builds in OS other than Ubuntu and Mac'
147
259
  fi
148
260
  export Z3_DIR="$install_path/$Z3Home"
261
+ fix_linux_z3_links
262
+ fix_macos_z3_load_paths
149
263
  echo "Z3_DIR=$Z3_DIR"
150
264
  export SVF_DIR="$install_path/SVF"
151
265
  echo "SVF_DIR=$SVF_DIR"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2639",
3
+ "version": "1.0.2641",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {