diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2019-01-27 19:24:12 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2019-02-03 23:19:44 +0100 |
| commit | c22769c31f7fb7ecfdfd952757eb37d4d7e5dfbd (patch) | |
| tree | 80b483215591815110b90d1d40fe92314dddb4fa /miasm2/core/locationdb.py | |
| parent | a9f8b5d5939cd4359919f0fef40bdd5c1f9c6441 (diff) | |
| download | miasm-c22769c31f7fb7ecfdfd952757eb37d4d7e5dfbd.tar.gz miasm-c22769c31f7fb7ecfdfd952757eb37d4d7e5dfbd.zip | |
Binary: add more elf symbols
Diffstat (limited to 'miasm2/core/locationdb.py')
| -rw-r--r-- | miasm2/core/locationdb.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/miasm2/core/locationdb.py b/miasm2/core/locationdb.py index 6655f8ac..4c5da29e 100644 --- a/miasm2/core/locationdb.py +++ b/miasm2/core/locationdb.py @@ -204,6 +204,22 @@ class LocationDB(object): for name, loc_key in self._name_to_loc_key.iteritems(): assert name in self._loc_key_to_names[loc_key] + def find_free_name(self, name): + """ + If @name is not known in DB, return it + Else append an index to it corresponding to the next unknown name + + @name: string + """ + if self.get_name_location(name) is None: + return name + i = 0 + while True: + new_name = "%s_%d" % (name, i) + if self.get_name_location(new_name) is None: + return new_name + i += 1 + def add_location(self, name=None, offset=None, strict=True): """Add a new location in the locationDB. Returns the corresponding LocKey. If @name is set, also associate a name to this new location. |