@Override public Set<BuildDependency> getDependencies(Map<Element, LayoutDecisionMap> decisions) { // we can get away with minimal dependencies, because we have no // content-> size dependency by default return ObjectFile.minimalDependencies(decisions, getElement()); }
@Override public Element getOrCreateRelocationElement(boolean useImplicitAddend) { // FIXME: This looks suspicious: turning an Element back into an Impl? return ((RelocatableSectionImpl) getElement()).getOrCreateRelocationElement(useImplicitAddend); }
@Override public Iterable<BuildDependency> getDependencies(Map<Element, LayoutDecisionMap> decisions) { // we don't need a SIZE -> CONTENT dependency return ObjectFile.minimalDependencies(decisions, getElement()); }
public static LayoutDecisionMap defaultDecisions(Element e, LayoutDecisionMap copyingIn) { LayoutDecisionMap decisions = new LayoutDecisionMap(e); decisions.putUndecided(LayoutDecision.Kind.CONTENT); assert !decisions.getDecision(LayoutDecision.Kind.CONTENT).isTaken(); decisions.putUndecided(LayoutDecision.Kind.SIZE); decisions.putUndecided(LayoutDecision.Kind.OFFSET); if (e.isReferenceable()) { decisions.putUndecided(LayoutDecision.Kind.VADDR); } // any decisions present in copyingIn will be already "taken" // i.e. they're LayoutProperties decisions.putDecidedValues(copyingIn); return decisions; }
public Section newProgbitsSection(String name, int alignment, boolean writable, boolean executable, ProgbitsSectionImpl impl) { assert impl != null; final Segment segment = getOrCreateSegment(null, name, writable, executable); final int adaptedAlignment = lowestCommonMultiple(alignment, getWordSizeInBytes()); final Section result = newProgbitsSection(segment, name, adaptedAlignment, writable, executable, impl); return result; }
public static int defaultGetOrDecideOffset(Map<Element, LayoutDecisionMap> alreadyDecided, Element el, int offsetHint) { // FIXME: in this implementation, we must not have decided the vaddr already! // We should instead support both cases, and if the vaddr is decided, apply // the modulo constraint (if necessary) here! assert (alreadyDecided.get(el).getDecision(LayoutDecision.Kind.VADDR) == null || !alreadyDecided.get(el).getDecision(LayoutDecision.Kind.VADDR).isTaken()); // now we are free to worry about the modulo constraint during vaddr assignment only // we take the hint, but bumped up to proper alignment return defaultGetOrDecide(alreadyDecided, el, LayoutDecision.Kind.OFFSET, nextIntegerMultiple(offsetHint, el.getAlignment())); }
@Override public RelocationRecord markRelocationSite(int offset, int length, RelocationKind k, String symbolName, boolean useImplicitAddend, Long explicitAddend) { return ((RelocatableSectionImpl) getElement()).markRelocationSite(offset, length, ByteBuffer.wrap(getContent()).order(getOwner().getByteOrder()), k, symbolName, useImplicitAddend, explicitAddend); }
public ELFProgbitsSection(ELFObjectFile owner, String name, int alignment, ProgbitsSectionImpl impl, EnumSet<ELFSectionFlag> flags) { super(owner, name, alignment, ELFObjectFile.SectionType.PROGBITS, impl != null ? impl : new BasicProgbitsSectionImpl(new byte[0]), flags); // this *is* necessary because the newProgbitsSection helper doesn't see the impl if (impl == null) { // i.e. if *we* just created this.impl in the "? :" above this.impl.setElement(this); } }
public Object getDecidedValue(LayoutDecision.Kind key) { return getDecision(key).getValue(); }
Section getSection(int sectionIndex) { int elementIndex = sectionIndexToElementIndex(sectionIndex); if (elementIndex == -1) { return null; } Element found = get(elementIndex); assert found instanceof Section; return (Section) found; }
@Override public int getAlignment() { return getElement().getAlignment(); }
@Override public Iterable<BuildDependency> getDependencies(Map<Element, LayoutDecisionMap> decisions) { return ObjectFile.defaultDependencies(decisions, getElement()); }
@Override public int getAlignment() { return getElement().getAlignment(); }
@Override public MachOObjectFile getOwner() { return (MachOObjectFile) super.getOwner(); } }
public String getFilenameSuffix() { if (executable) { return ObjectFile.getNativeFormat() == ObjectFile.Format.PECOFF ? ".exe" : ""; } return ""; }
@Override public boolean removeAll(Collection<?> arg0) { boolean removed = false; for (Object o : arg0) { removed |= this.remove(o); } return removed; }
@Override public Iterator<Iterable<String>> iterator() { return impl.contentProvidersIterator(); } };
@Override public String getFormatDependentName(Format f) { final String result; if (f == Format.MACH_O) { result = "__const"; } else { result = super.getFormatDependentName(f); } return result; }
public PECoffProgbitsSection(PECoffObjectFile owner, String name, int alignment, ProgbitsSectionImpl impl, EnumSet<PECoffSectionFlag> flags) { super(owner, name, alignment, impl != null ? impl : new BasicProgbitsSectionImpl(new byte[0]), flags); // this *is* necessary because the newProgbitsSection helper doesn't see the impl if (impl == null) { // i.e. if *we* just created this.impl in the "? :" above this.impl.setElement(this); } }
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 }