diff options
author | Artem Pyanykh <artempyanykh@gmail.com> | 2019-02-11 14:05:26 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-03-20 19:52:39 -0400 |
commit | 78c61acf15c66a17df63da60226acff3a2dda585 (patch) | |
tree | 6278c767c639f571511e07d2cba9410000b69aac /rts/LinkerInternals.h | |
parent | 368187591a5454e47c4e08dae90d39d2af1fad40 (diff) | |
download | haskell-78c61acf15c66a17df63da60226acff3a2dda585.tar.gz |
Use segments for section layout
Diffstat (limited to 'rts/LinkerInternals.h')
-rw-r--r-- | rts/LinkerInternals.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h index 81a09fe3ae..cd36fd55d2 100644 --- a/rts/LinkerInternals.h +++ b/rts/LinkerInternals.h @@ -62,6 +62,11 @@ typedef } SectionAlloc; +typedef enum { + SEGMENT_PROT_RX, + SEGMENT_PROT_RW +} SegmentProt; + /* * Note [No typedefs for customizable types] * Some pointer-to-struct types are defined opaquely @@ -103,6 +108,18 @@ typedef } ProddableBlock; +typedef struct _Segment { + void *start; /* page aligned start address of a segment */ + size_t size; /* page rounded size of a segment */ + SegmentProt prot; /* mem protection to set after all symbols were + * resolved */ + + int *sections_idx; /* an array of section indexes assigned to this segment */ + int n_sections; +} Segment; + +/* todo (AP): add freeSegments */ + /* * We must keep track of the StablePtrs that are created for foreign * exports by constructor functions when the module is loaded, so that @@ -179,9 +196,14 @@ typedef struct _ObjectCode { /* The section-kind entries for this object module. Linked list. */ + /* fixme (AP): doesn't look like a linked list. On MachO it's an array, and + * generally Section struct doesn't have pointers to next. */ int n_sections; Section* sections; + int n_segments; + Segment *segments; + /* Allow a chain of these things */ struct _ObjectCode * next; @@ -312,6 +334,9 @@ ObjectCode* mkOc( pathchar *path, char *image, int imageSize, int misalignment ); +void initSegment(Segment *s, void *start, size_t size, SegmentProt prot, int n_sections); +void freeSegments(ObjectCode *oc); + /* MAP_ANONYMOUS is MAP_ANON on some systems, e.g. OS X (before Sierra), OpenBSD etc */ #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) |