Return a list of sections the same length and order of the input list
(elf, name_type_pairs)
| 183 | |
| 184 | |
| 185 | def _find_sections(elf, name_type_pairs): |
| 186 | """Return a list of sections the same length and order of the input list""" |
| 187 | sections = [None] * len(name_type_pairs) |
| 188 | for section in elf.iter_sections(): |
| 189 | section_name = section.name |
| 190 | section_type = section["sh_type"] |
| 191 | for i, name_and_type in enumerate(name_type_pairs): |
| 192 | if name_and_type != (section_name, section_type): |
| 193 | continue |
| 194 | if sections[i] is not None: |
| 195 | raise Exception("Elf contains duplicate section %s attr %s" % |
| 196 | (section_name, section_type)) |
| 197 | sections[i] = section |
| 198 | return sections |
| 199 | |
| 200 | |
| 201 | def _algo_fill_zi_if_missing(ro_rw_zi): |