/** * Return a "suggested" segment name for sections of this name, given an object file format. * Some object file formats (Mach-O) require that all sections exist within a segment. Others * (ELF) impose no such requirement. For the latter formats, this will return null (noting that * ELF does not even have segment names). For the former, it will return some segment name. By * default, Mach-O segment names are the section name uppercased. Note that the value returned * by this function is designed to be passed to the (String, String, ...) overload of * new{UserDefined,Progbits,Nobits}Section in ObjectFile. * * @param f * @return a segment name, or null if none is necessary */ public String getSegmentName(ObjectFile.Format f) { // default implementation switch (f) { case MACH_O: return getFormatDependentName(f).toUpperCase(); default: case ELF: return null; } }
private Element getRodataSection() { return getElement().getOwner().elementForName(SectionName.RODATA.getFormatDependentName(getElement().getOwner().getFormat())); }
final String textSectionName = SectionName.TEXT.getFormatDependentName(objectFile.getFormat()); textSection = objectFile.newProgbitsSection(textSectionName, objectFile.getPageSize(), false, true, textImpl); final String roDataSectionName = SectionName.RODATA.getFormatDependentName(objectFile.getFormat()); roDataSection = objectFile.newProgbitsSection(roDataSectionName, objectFile.getPageSize(), false, false, roDataImpl); final String rwDataSectionName = SectionName.DATA.getFormatDependentName(objectFile.getFormat()); rwDataSection = objectFile.newProgbitsSection(rwDataSectionName, objectFile.getPageSize(), true, false, rwDataImpl); final String heapSectionName = SectionName.SVM_HEAP.getFormatDependentName(objectFile.getFormat()); heapSection = objectFile.newProgbitsSection(heapSectionName, objectFile.getPageSize(), writable, false, heapSectionImpl); objectFile.createDefinedSymbol(heapSection.getName(), heapSection, 0, 0, false, true);