/** * Constructs an PECoff section of given name, flags and section index. * * @param name the section name * @param flags the section's flags * @param sectionIndex the desired index in the PECoff section header table */ public PECoffSection(String name, int alignment, EnumSet<PECoffSectionFlag> flags, int sectionIndex) { // PECoff sections are aligned at least to a word boundary. super(name, alignment, (sectionIndex == -1) ? -1 : elements.sectionIndexToElementIndex(sectionIndex - 1)); this.flags = flags; }
/** * Constructs an ELF section of given name, type, flags and section index. * * @param name the section name * @param type the section type * @param flags the section's flags * @param sectionIndex the desired index in the ELF section header table */ public ELFSection(String name, int alignment, SectionType type, EnumSet<ELFSectionFlag> flags, int sectionIndex) { // ELF sections are aligned at least to a word boundary. super(name, alignment, (sectionIndex == -1) ? -1 : elements.sectionIndexToElementIndex(sectionIndex - 1)); this.type = type; this.flags = flags; }
Section getSection(int sectionIndex) { int elementIndex = sectionIndexToElementIndex(sectionIndex); if (elementIndex == -1) { return null; } Element found = get(elementIndex); assert found instanceof Section; return (Section) found; }
public PECoffSection getSectionByIndex(int i) { // if this cast fails, our sectionIndexToElementIndex logic is wrong return (PECoffSection) elements.get(elements.sectionIndexToElementIndex(i - 1)); // NOTE: two levels of translation here: PECoff (1-based) shndx to section index (0-based) // to // element index }
public ELFSection getSectionByIndex(int i) { // if this cast fails, our sectionIndexToElementIndex logic is wrong return (ELFSection) elements.get(elements.sectionIndexToElementIndex(i - 1)); // NOTE: two levels of translation here: ELF (1-based) shndx to section index (0-based) to // element index }