summaryrefslogtreecommitdiff
path: root/rts/LinkerInternals.h
diff options
context:
space:
mode:
authorArtem Pyanykh <artempyanykh@gmail.com>2019-02-11 14:05:26 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-20 19:52:39 -0400
commit78c61acf15c66a17df63da60226acff3a2dda585 (patch)
tree6278c767c639f571511e07d2cba9410000b69aac /rts/LinkerInternals.h
parent368187591a5454e47c4e08dae90d39d2af1fad40 (diff)
downloadhaskell-78c61acf15c66a17df63da60226acff3a2dda585.tar.gz
Use segments for section layout
Diffstat (limited to 'rts/LinkerInternals.h')
-rw-r--r--rts/LinkerInternals.h25
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)