MCPcopy Create free account
hub / github.com/FastLED/FastLED / list_symbols_and_sizes

Function list_symbols_and_sizes

ci/util/elf.py:141–179  ·  view source on GitHub ↗

List all symbols and their sizes from the ELF file using objdump. Args: objdump_path (Path): Path to the objdump executable. cppfilt_path (Path): Path to the c++filt executable. elf_file (Path): Path to the ELF file.

(objdump_path: Path, cppfilt_path: Path, elf_file: Path)

Source from the content-addressed store, hash-verified

139
140
141def list_symbols_and_sizes(objdump_path: Path, cppfilt_path: Path, elf_file: Path):
142 """
143 List all symbols and their sizes from the ELF file using objdump.
144
145 Args:
146 objdump_path (Path): Path to the objdump executable.
147 cppfilt_path (Path): Path to the c++filt executable.
148 elf_file (Path): Path to the ELF file.
149 """
150 command = [
151 str(objdump_path),
152 "-t",
153 str(elf_file),
154 ] # "-t" option lists symbols with sizes.
155 print(f"Listing symbols and sizes in ELF file: {elf_file}")
156 output = run_command(command, show_output=False)
157
158 symbols: list[dict[str, Any]] = []
159 for line in output.splitlines():
160 parts = line.split()
161 # Expected parts length can vary, check if size and section index (parts[2] & parts[4]) are valid
162 if len(parts) > 5 and parts[2].isdigit() and parts[4].startswith("."):
163 symbol = {
164 "name": parts[-1],
165 "size": int(parts[2], 16), # size is in hex format
166 "section": parts[4],
167 "type": parts[3],
168 }
169 symbols.append(symbol)
170
171 if symbols:
172 print("\nSymbols and Sizes in ELF File:")
173 for symbol in symbols:
174 demangled_name = demangle_symbol(cppfilt_path, symbol["name"])
175 print(
176 f"Symbol: {demangled_name}, Size: {symbol['size']} bytes, Type: {symbol['type']}, Section: {symbol['section']}"
177 )
178 else:
179 print("No symbols found or unable to parse symbols correctly.")
180
181
182def check_elf_format(objdump_path: Path, elf_file: Path):

Callers 1

analyze_elf_fileFunction · 0.85

Calls 4

run_commandFunction · 0.70
demangle_symbolFunction · 0.70
printFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected