public abstract class ObjectFile extends Object
LayoutDecision
), being computed on write-out (see WriteLayout
).Modifier and Type | Class and Description |
---|---|
class |
ObjectFile.Element
All headers and sections are subclasses of ObjectFile.Element.
|
static class |
ObjectFile.ElementComparatorByDecidedOffset |
static class |
ObjectFile.Format |
class |
ObjectFile.Header |
static class |
ObjectFile.IntegerDecisionComparator |
static interface |
ObjectFile.NobitsSectionImpl |
static interface |
ObjectFile.ProgbitsSectionImpl
Abstract notions of section.
|
static interface |
ObjectFile.RelocatableSectionImpl |
static class |
ObjectFile.RelocationKind |
static interface |
ObjectFile.RelocationMethod
Interface implemented by objects implementing a specific relocation method and size.
|
static interface |
ObjectFile.RelocationRecord
Interface for objects representing relocation sites in an object file's contents.
|
static interface |
ObjectFile.RelocationSiteInfo |
class |
ObjectFile.Section |
static interface |
ObjectFile.Segment |
static class |
ObjectFile.SizeTiebreakComparator |
static interface |
ObjectFile.Symbol
An abstraction of symbols within object files.
|
static interface |
ObjectFile.ValueEnum
An interface for power-of-two values.
|
Modifier and Type | Field and Description |
---|---|
protected ElementList |
elements |
protected Map<ObjectFile.Element,String> |
nameForElement |
Constructor and Description |
---|
ObjectFile(int pageSize) |
Modifier and Type | Method and Description |
---|---|
protected static Iterable<LayoutDecision> |
allDecisions(Map<ObjectFile.Element,LayoutDecisionMap> decisions) |
int |
bake(List<ObjectFile.Element> sortedObjectFileElements) |
static HashSet<BuildDependency> |
basicDependencies(Map<ObjectFile.Element,LayoutDecisionMap> decisions,
ObjectFile.Element el,
boolean sizeOnContent,
boolean vaddrOnOffset) |
abstract ObjectFile.Symbol |
createDefinedSymbol(String name,
ObjectFile.Element baseSection,
long position,
int size,
boolean isCode,
boolean isGlobal) |
protected ElementList |
createElementList() |
static ObjectFile |
createRuntimeDebugInfo(int pageSize) |
protected abstract SymbolTable |
createSymbolTable() |
abstract ObjectFile.Symbol |
createUndefinedSymbol(String name,
int size,
boolean isCode) |
void |
debugContext(String scopeName,
Consumer<org.graalvm.compiler.debug.DebugContext> action)
Allows a consumer to retrieve the debug context currently bound to this object file.
|
protected static Iterable<LayoutDecision> |
decisionsByKind(LayoutDecision.Kind kind,
Map<ObjectFile.Element,LayoutDecisionMap> decisions) |
static LayoutDecisionMap |
defaultDecisions(ObjectFile.Element e,
LayoutDecisionMap copyingIn) |
static HashSet<BuildDependency> |
defaultDependencies(Map<ObjectFile.Element,LayoutDecisionMap> decisions,
ObjectFile.Element el) |
static <T> T |
defaultGetOrDecide(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
ObjectFile.Element el,
LayoutDecision.Kind k,
T hint) |
static byte[] |
defaultGetOrDecideContent(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
ObjectFile.Element el,
byte[] contentHint) |
static int |
defaultGetOrDecideOffset(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
ObjectFile.Element el,
int offsetHint) |
static int |
defaultGetOrDecideSize(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
ObjectFile.Element el,
int sizeHint) |
static int |
defaultGetOrDecideVaddr(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
ObjectFile.Element el,
int vaddrHint) |
ObjectFile.Element |
elementForName(String s) |
protected boolean |
elementsCanSharePage(ObjectFile.Element s1,
ObjectFile.Element s2,
int offset1,
int offset2)
Returns whether, according to the semantics of the object file, two sections could reasonably
both be placed (partially) on the same page-sized region of virtual memory.
|
protected Iterable<ObjectFile.Element> |
elementsMappedOnPage(long vaddr,
Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided) |
ObjectFile.Segment |
findSegmentByName(String name) |
static <E extends Enum<E> & ObjectFile.ValueEnum> |
flagSetAsLong(EnumSet<E> flags)
Create a long integer representation of an EnumSet of bitflags.
|
static <E extends Enum<E> & ObjectFile.ValueEnum> |
flagSetFromLong(long flags,
Class<E> clazz)
Create an EnumSet representation of a long integer encoding a set of bitflags.
|
abstract ByteOrder |
getByteOrder() |
Map<ObjectFile.Element,LayoutDecisionMap> |
getDecisionsByElement() |
Map<ObjectFile.Element,LayoutDecisionMap> |
getDecisionsTaken() |
List<ObjectFile.Element> |
getElements() |
static String |
getFilenameSuffix() |
abstract ObjectFile.Format |
getFormat() |
ObjectFile.Header |
getHeader() |
protected abstract int |
getMinimumFileSize() |
static ObjectFile.Format |
getNativeFormat() |
static ObjectFile |
getNativeObjectFile(int pageSize) |
ObjectFile.Element |
getOffsetBootstrapElement()
Something of a HACK: we require that all ObjectFiles tell the build process one element whose
offset will be decided first.
|
protected abstract ObjectFile.Segment |
getOrCreateSegment(String maybeSegmentName,
String sectionName,
boolean writable,
boolean executable)
Return a Segment object which is appropriate for containing a section of the given name, if
such a segment is mandatory according to the object file format specification.
|
SymbolTable |
getOrCreateSymbolTable() |
int |
getPageSize() |
int |
getPageSizeShift() |
List<ObjectFile.Section> |
getSections() |
abstract Set<ObjectFile.Segment> |
getSegments() |
abstract SymbolTable |
getSymbolTable() |
abstract int |
getWordSizeInBytes() |
protected static int |
greatestCommonDivisor(int arg1,
int arg2) |
protected int |
initialVaddr() |
void |
installDebugInfo(DebugInfoProvider debugInfoProvider)
API method provided to allow a native image generator to provide details of types, code and
heap data inserted into a native image.
|
protected static int |
lowestCommonMultiple(int arg1,
int arg2) |
protected static List<LayoutDecision> |
maximalDecisionValues(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
LayoutDecision.Kind k,
Comparator<LayoutDecision> cmp) |
protected static List<LayoutDecision> |
minimalDecisionValues(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
LayoutDecision.Kind k,
Comparator<LayoutDecision> cmp) |
static HashSet<BuildDependency> |
minimalDependencies(Map<ObjectFile.Element,LayoutDecisionMap> decisions,
ObjectFile.Element el) |
String |
nameForElement(ObjectFile.Element e) |
ObjectFile.Section |
newDebugSection(String name,
ElementImpl impl) |
abstract ObjectFile.Section |
newNobitsSection(ObjectFile.Segment segment,
String name,
ObjectFile.NobitsSectionImpl impl) |
ObjectFile.Section |
newNobitsSection(String name,
ObjectFile.NobitsSectionImpl impl) |
abstract ObjectFile.Section |
newProgbitsSection(ObjectFile.Segment segment,
String name,
int alignment,
boolean writable,
boolean executable,
ObjectFile.ProgbitsSectionImpl impl) |
ObjectFile.Section |
newProgbitsSection(String name,
int alignment,
boolean writable,
boolean executable,
ObjectFile.ProgbitsSectionImpl impl) |
abstract ObjectFile.Section |
newUserDefinedSection(ObjectFile.Segment segment,
String name,
int alignment,
ElementImpl impl)
Create a new section for holding user data.
|
ObjectFile.Section |
newUserDefinedSection(String name,
ElementImpl impl) |
protected static int |
nextAvailableOffset(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided) |
protected static int |
nextAvailableVaddr(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
int base,
int defaultValue) |
static int |
nextIntegerMultiple(int start,
int multipleOf) |
static int |
nextIntegerMultipleWithCongruence(int start,
int multipleOf,
int congruentTo,
int modulo) |
int |
roundUpToPageSize(int x) |
abstract void |
setByteOrder(ByteOrder byteOrder) |
abstract boolean |
shouldRecordDebugRelocations()
Determines whether references between debug sections should be recorded for relocation.
|
protected static List<LayoutDecision> |
sortedDecisionValues(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided,
LayoutDecision.Kind k,
Comparator<LayoutDecision> cmp) |
void |
withDebugContext(org.graalvm.compiler.debug.DebugContext context,
String scopeName,
Runnable task)
Allows a task to be executed with a debug context in a named subscope bound to the object
file and accessible to code executed during the lifetime of the task.
|
void |
write(FileChannel outputChannel) |
void |
writeBuffer(List<ObjectFile.Element> sortedObjectFileElements,
ByteBuffer out) |
protected final ElementList elements
protected final Map<ObjectFile.Element,String> nameForElement
public abstract ObjectFile.Format getFormat()
public static <E extends Enum<E> & ObjectFile.ValueEnum> long flagSetAsLong(EnumSet<E> flags)
flags
- an EnumSet of flag elements, which must be an enum implementing PowerOfTwoValuedpublic static <E extends Enum<E> & ObjectFile.ValueEnum> EnumSet<E> flagSetFromLong(long flags, Class<E> clazz)
flags
- the long integer encoding the set of flagsclazz
- the enum class (implementing PowerOfTwoValued) representing elements of the setpublic abstract ByteOrder getByteOrder()
public abstract void setByteOrder(ByteOrder byteOrder)
protected int initialVaddr()
public static String getFilenameSuffix()
public static ObjectFile.Format getNativeFormat()
public static ObjectFile getNativeObjectFile(int pageSize)
public static ObjectFile createRuntimeDebugInfo(int pageSize)
protected abstract ObjectFile.Segment getOrCreateSegment(String maybeSegmentName, String sectionName, boolean writable, boolean executable)
maybeSegmentName
- either null, or the name of a segment which the caller would prefer
should contain the given section (in the case where multiple names would be
possible for the created segment, so the choice would be ambiguous)sectionName
- a platform-dependent section namewritable
- whether the segment contents should be writableexecutable
- whether the segment contents should be executablepublic abstract ObjectFile.Section newUserDefinedSection(ObjectFile.Segment segment, String name, int alignment, ElementImpl impl)
segment
- name
- impl
- public abstract ObjectFile.Section newProgbitsSection(ObjectFile.Segment segment, String name, int alignment, boolean writable, boolean executable, ObjectFile.ProgbitsSectionImpl impl)
public abstract ObjectFile.Section newNobitsSection(ObjectFile.Segment segment, String name, ObjectFile.NobitsSectionImpl impl)
public ObjectFile.Section newUserDefinedSection(String name, ElementImpl impl)
public ObjectFile.Section newDebugSection(String name, ElementImpl impl)
public ObjectFile.Section newProgbitsSection(String name, int alignment, boolean writable, boolean executable, ObjectFile.ProgbitsSectionImpl impl)
public ObjectFile.Section newNobitsSection(String name, ObjectFile.NobitsSectionImpl impl)
public ObjectFile.Segment findSegmentByName(String name)
public static int nextIntegerMultiple(int start, int multipleOf)
public static int nextIntegerMultipleWithCongruence(int start, int multipleOf, int congruentTo, int modulo)
protected static int greatestCommonDivisor(int arg1, int arg2)
protected static int lowestCommonMultiple(int arg1, int arg2)
protected static int nextAvailableVaddr(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, int base, int defaultValue)
protected static List<LayoutDecision> maximalDecisionValues(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, LayoutDecision.Kind k, Comparator<LayoutDecision> cmp)
protected static List<LayoutDecision> minimalDecisionValues(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, LayoutDecision.Kind k, Comparator<LayoutDecision> cmp)
protected static List<LayoutDecision> sortedDecisionValues(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, LayoutDecision.Kind k, Comparator<LayoutDecision> cmp)
protected static int nextAvailableOffset(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided)
public abstract int getWordSizeInBytes()
public abstract boolean shouldRecordDebugRelocations()
public static HashSet<BuildDependency> basicDependencies(Map<ObjectFile.Element,LayoutDecisionMap> decisions, ObjectFile.Element el, boolean sizeOnContent, boolean vaddrOnOffset)
public static HashSet<BuildDependency> minimalDependencies(Map<ObjectFile.Element,LayoutDecisionMap> decisions, ObjectFile.Element el)
public static HashSet<BuildDependency> defaultDependencies(Map<ObjectFile.Element,LayoutDecisionMap> decisions, ObjectFile.Element el)
public static <T> T defaultGetOrDecide(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, ObjectFile.Element el, LayoutDecision.Kind k, T hint)
public static int defaultGetOrDecideOffset(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, ObjectFile.Element el, int offsetHint)
public static byte[] defaultGetOrDecideContent(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, ObjectFile.Element el, byte[] contentHint)
public static int defaultGetOrDecideSize(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, ObjectFile.Element el, int sizeHint)
public static int defaultGetOrDecideVaddr(Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided, ObjectFile.Element el, int vaddrHint)
public static LayoutDecisionMap defaultDecisions(ObjectFile.Element e, LayoutDecisionMap copyingIn)
protected boolean elementsCanSharePage(ObjectFile.Element s1, ObjectFile.Element s2, int offset1, int offset2)
s1
- one sections2
- another sectionpublic void installDebugInfo(DebugInfoProvider debugInfoProvider)
debugInfoProvider
- an implementation of the provider interface that communicates
details of the relevant types, code and heap data.protected static Iterable<LayoutDecision> allDecisions(Map<ObjectFile.Element,LayoutDecisionMap> decisions)
protected static Iterable<LayoutDecision> decisionsByKind(LayoutDecision.Kind kind, Map<ObjectFile.Element,LayoutDecisionMap> decisions)
public Map<ObjectFile.Element,LayoutDecisionMap> getDecisionsTaken()
protected Iterable<ObjectFile.Element> elementsMappedOnPage(long vaddr, Map<ObjectFile.Element,LayoutDecisionMap> alreadyDecided)
protected ElementList createElementList()
public List<ObjectFile.Element> getElements()
public ObjectFile.Element elementForName(String s)
public String nameForElement(ObjectFile.Element e)
public List<ObjectFile.Section> getSections()
public abstract Set<ObjectFile.Segment> getSegments()
public ObjectFile.Header getHeader()
ObjectFile.Header
. Depending on the mode of the object file (read
or write), the header is newly created or read from the buffer.public ObjectFile.Element getOffsetBootstrapElement()
public final void write(FileChannel outputChannel)
public int bake(List<ObjectFile.Element> sortedObjectFileElements)
public Map<ObjectFile.Element,LayoutDecisionMap> getDecisionsByElement()
public void writeBuffer(List<ObjectFile.Element> sortedObjectFileElements, ByteBuffer out)
protected abstract int getMinimumFileSize()
public int getPageSize()
public int getPageSizeShift()
public int roundUpToPageSize(int x)
public abstract ObjectFile.Symbol createDefinedSymbol(String name, ObjectFile.Element baseSection, long position, int size, boolean isCode, boolean isGlobal)
public abstract ObjectFile.Symbol createUndefinedSymbol(String name, int size, boolean isCode)
protected abstract SymbolTable createSymbolTable()
public abstract SymbolTable getSymbolTable()
public final SymbolTable getOrCreateSymbolTable()
public void withDebugContext(org.graalvm.compiler.debug.DebugContext context, String scopeName, Runnable task)
ObjectFile.debugContext
.context
- a context to be bound to the object file for the duration of the task
execution.scopeName
- a name to be used to define a subscope current while the task is being
executed.task
- a task to be executed while the context is bound to the object file.public void debugContext(String scopeName, Consumer<org.graalvm.compiler.debug.DebugContext> action)
ObjectFile.withDebugContext(org.graalvm.compiler.debug.DebugContext, java.lang.String, java.lang.Runnable)
.scopeName
- a name to be used to define a subscope current while the consumer is active.action
- an action parameterised by the debug context.