Sections with LOAD flag — these are what get written into firmware.bin.
()
| 25 | |
| 26 | |
| 27 | def loadable_progbits_ranges() -> list[tuple[int, int, str]]: |
| 28 | """Sections with LOAD flag — these are what get written into firmware.bin.""" |
| 29 | out_objdump = subprocess.check_output( |
| 30 | [str(TC / "xtensa-esp32s3-elf-objdump"), "-h", str(ELF)], text=True |
| 31 | ) |
| 32 | ranges: list[tuple[int, int, str]] = [] |
| 33 | lines = out_objdump.splitlines() |
| 34 | i = 0 |
| 35 | while i < len(lines): |
| 36 | m = re.match( |
| 37 | r"\s*\d+\s+(\S+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+[0-9a-f]+\s+[0-9a-f]+", |
| 38 | lines[i], |
| 39 | ) |
| 40 | if m and i + 1 < len(lines): |
| 41 | name, size_hex, vma_hex = m.groups() |
| 42 | flags = lines[i + 1] |
| 43 | size = int(size_hex, 16) |
| 44 | addr = int(vma_hex, 16) |
| 45 | if size > 0 and "LOAD" in flags: |
| 46 | ranges.append((addr, addr + size, name)) |
| 47 | i += 2 |
| 48 | else: |
| 49 | i += 1 |
| 50 | return ranges |
| 51 | |
| 52 | |
| 53 | def in_loaded(addr: int, ranges: list[tuple[int, int, str]]) -> str | None: |