diff --git a/include/revng/Model/model-schema.yml b/include/revng/Model/model-schema.yml index 706a5a620..6740850d0 100644 --- a/include/revng/Model/model-schema.yml +++ b/include/revng/Model/model-schema.yml @@ -668,10 +668,19 @@ definitions: doc: The size of the binary (in bytes) type: uint64_t - - name: Name + - name: CanonicalPath doc: |- - The binary's filename at the time when it was imported. This is kept - as an heuristic to re-search the file if it is missing. + The path of the binary in its "canonical" position (if sensible). + For instance, for `sh`, it makes sense to use `/bin/sh`. + This enables to lookup debug information and libraries relative to its + "canonical" position. + + Moreover, if `Hash` is not enough to obtain the actual content of the + binary, this field will be used to perform a fuzzy search in sensible + place. + + In case of Windows binaries, use UNIX paths relative to C:\ (e.g., use + /Windows for C:\Windows). type: string - name: Segment diff --git a/lib/Model/Importer/Binary/Importers.h b/lib/Model/Importer/Binary/Importers.h index 6f4547307..e2f2c7089 100644 --- a/lib/Model/Importer/Binary/Importers.h +++ b/lib/Model/Importer/Binary/Importers.h @@ -37,7 +37,7 @@ public: // reliable than the filename of the file on disk (this is still used as a // fallback in order to be compatible with the old pipeline). if (Reference.isValid()) - return Reference.get()->Name(); + return Reference.get()->Path(); else if (not InputPath.empty()) return InputPath; else if (not ObjectFile.getFileName().empty()) diff --git a/python/revng/internal/cli/revng2.py b/python/revng/internal/cli/revng2.py index b2a79ee2b..c95441163 100644 --- a/python/revng/internal/cli/revng2.py +++ b/python/revng/internal/cli/revng2.py @@ -58,7 +58,9 @@ def generate_model_with_binaries(binaries: list[Path]): with open(binary, "rb") as f: hash_ = compute_hash(f) size = f.seek(0, os.SEEK_END) - result.append({"Index": index, "Hash": hash_, "Size": size, "Name": str(binary.resolve())}) + result.append( + {"Index": index, "Hash": hash_, "Size": size, "CanonicalPath": str(binary.resolve())} + ) return {"Binaries": result} diff --git a/python/revng/internal/pipebox.py b/python/revng/internal/pipebox.py index af914ff0b..2ccb75ed3 100644 --- a/python/revng/internal/pipebox.py +++ b/python/revng/internal/pipebox.py @@ -104,7 +104,7 @@ class ImportFiles(Pipe): requests: list[FileRequest] = [] for binary in model_obj.Binaries: indexes.append(binary.Index) - requests.append(FileRequest(binary.Hash, binary.Name, binary.Size)) + requests.append(FileRequest(binary.Hash, binary.CanonicalPath, binary.Size)) return (indexes, requests) diff --git a/python/revng/project/project.py b/python/revng/project/project.py index a6cf10327..90b35c9f4 100644 --- a/python/revng/project/project.py +++ b/python/revng/project/project.py @@ -196,7 +196,7 @@ class Project(ABC): size = Path(binary_path).stat().st_size self.model.Binaries.append( - BinaryIdentifier(Index=0, Hash=hash_, Size=size, Name=Path(binary_path).name) + BinaryIdentifier(Index=0, Hash=hash_, Size=size, CanonicalPath=Path(binary_path).name) ) self._commit() self._analyze("initial-auto-analysis") diff --git a/share/doc/revng/user-manual/tutorial/model-from-scratch.md b/share/doc/revng/user-manual/tutorial/model-from-scratch.md index c5b96410f..047bb2746 100644 --- a/share/doc/revng/user-manual/tutorial/model-from-scratch.md +++ b/share/doc/revng/user-manual/tutorial/model-from-scratch.md @@ -41,7 +41,7 @@ The first thing rev.ng needs to know is which binary to load, this is done by sp ```yaml title="model.yml" Binaries: - Index: 0 - Name: sum + CanonicalPath: sum # Output of `sha256sum sum` Hash: bba591a825f58c1b94fc4d8c13f5d3531a89282cb3319a1418ee3f8396880567 # Output of `wc -c sum`