MCPcopy Create free account
hub / github.com/apache/tvm / get_global_symbol_section_map

Function get_global_symbol_section_map

python/tvm/support/cc.py:181–223  ·  view source on GitHub ↗

Get global symbols from a library via nm -g Parameters ---------- path : str The library path nm: str The path to nm command Returns ------- symbol_section_map: Dict[str, str] A map from defined global symbol to their sections

(path, *, nm=None)

Source from the content-addressed store, hash-verified

179
180
181def get_global_symbol_section_map(path, *, nm=None) -> dict[str, str]:
182 """Get global symbols from a library via nm -g
183
184 Parameters
185 ----------
186 path : str
187 The library path
188
189 nm: str
190 The path to nm command
191
192 Returns
193 -------
194 symbol_section_map: Dict[str, str]
195 A map from defined global symbol to their sections
196 """
197 if nm is None:
198 if not _is_linux_like():
199 raise ValueError("Unsupported platform")
200 nm = "nm"
201
202 symbol_section_map = {}
203
204 if not os.path.isfile(path):
205 raise FileNotFoundError(f"{path} does not exist")
206
207 cmd = [nm, "-gU", path]
208 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
209 (out, _) = proc.communicate()
210
211 if proc.returncode != 0:
212 msg = "Runtime error:\n"
213 msg += out.decode("utf-8", errors="replace")
214 raise RuntimeError(msg)
215
216 for line in out.decode("utf-8", errors="replace").split("\n"):
217 data = line.strip().split()
218 if len(data) != 3:
219 continue
220 symbol = data[-1]
221 section = data[-2]
222 symbol_section_map[symbol] = section
223 return symbol_section_map
224
225
226def get_target_by_dump_machine(compiler):

Callers

nothing calls this directly

Calls 3

_is_linux_likeFunction · 0.85
decodeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…