Declare most internal, constant tables as const, particularly the
"specifics" structures and the tables they point to.
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index 2ddb5c7..c9211c3 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -208,8 +208,8 @@
 struct e2v_key {
 	const char *start;
 	const char *stop;
-	asn_INTEGER_enum_map_t *vemap;
-	unsigned int *evmap;
+	const asn_INTEGER_enum_map_t *vemap;
+	const unsigned int *evmap;
 };
 static int
 INTEGER__compar_enum2value(const void *kp, const void *am) {
@@ -232,7 +232,7 @@
 
 static const asn_INTEGER_enum_map_t *
 INTEGER_map_enum2value(asn_INTEGER_specifics_t *specs, const char *lstart, const char *lstop) {
-	asn_INTEGER_enum_map_t *el_found;
+	const asn_INTEGER_enum_map_t *el_found;
 	int count = specs ? specs->map_count : 0;
 	struct e2v_key key;
 	const char *lp;
diff --git a/skeletons/INTEGER.h b/skeletons/INTEGER.h
index fe08b03..2813f0c 100644
--- a/skeletons/INTEGER.h
+++ b/skeletons/INTEGER.h
@@ -24,9 +24,9 @@
 } asn_INTEGER_enum_map_t;
 
 /* This type describes an enumeration for INTEGER and ENUMERATED types */
-typedef struct asn_INTEGER_specifics_s {
-	asn_INTEGER_enum_map_t *value2enum;	/* N -> "tag"; sorted by N */
-	unsigned int *enum2value;		/* "tag" => N; sorted by tag */
+typedef const struct asn_INTEGER_specifics_s {
+	const asn_INTEGER_enum_map_t *value2enum;	/* N -> "tag"; sorted by N */
+	const unsigned int *enum2value;		/* "tag" => N; sorted by tag */
 	int map_count;				/* Elements in either map */
 	int extension;				/* This map is extensible */
 	int strict_enumeration;			/* Enumeration set is fixed */
diff --git a/skeletons/NativeEnumerated.c b/skeletons/NativeEnumerated.c
index 1554220..bdf1102 100644
--- a/skeletons/NativeEnumerated.c
+++ b/skeletons/NativeEnumerated.c
@@ -145,7 +145,7 @@
 	asn_per_constraint_t *ct;
 	int inext = 0;
 	asn_INTEGER_enum_map_t key;
-	asn_INTEGER_enum_map_t *kf;
+	const asn_INTEGER_enum_map_t *kf;
 
 	if(!sptr) _ASN_ENCODE_FAILED;
 	if(!specs) _ASN_ENCODE_FAILED;
diff --git a/skeletons/OCTET_STRING.h b/skeletons/OCTET_STRING.h
index 8df9a18..013c7b1 100644
--- a/skeletons/OCTET_STRING.h
+++ b/skeletons/OCTET_STRING.h
@@ -63,7 +63,7 @@
  * Internally useful stuff. *
  ****************************/
 
-typedef struct asn_OCTET_STRING_specifics_s {
+typedef const struct asn_OCTET_STRING_specifics_s {
 	/*
 	 * Target structure description.
 	 */
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index 6b69942..f366f75 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -183,11 +183,11 @@
 		}
 
 		do {
-			asn_TYPE_tag2member_t *t2m;
+			const asn_TYPE_tag2member_t *t2m;
 			asn_TYPE_tag2member_t key;
 
 			key.el_tag = tlv_tag;
-			t2m = (asn_TYPE_tag2member_t *)bsearch(&key,
+			t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
 					specs->tag2el, specs->tag2el_count,
 					sizeof(specs->tag2el[0]), _search4tag);
 			if(t2m) {
diff --git a/skeletons/constr_CHOICE.h b/skeletons/constr_CHOICE.h
index 83404e6..e824a22 100644
--- a/skeletons/constr_CHOICE.h
+++ b/skeletons/constr_CHOICE.h
@@ -12,7 +12,7 @@
 extern "C" {
 #endif
 
-typedef struct asn_CHOICE_specifics_s {
+typedef const struct asn_CHOICE_specifics_s {
 	/*
 	 * Target structure description.
 	 */
@@ -24,7 +24,7 @@
 	/*
 	 * Tags to members mapping table.
 	 */
-	asn_TYPE_tag2member_t *tag2el;
+	const asn_TYPE_tag2member_t *tag2el;
 	int tag2el_count;
 
 	/* Canonical ordering of CHOICE elements, for PER */
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index c405a18..07dcedf 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -310,16 +310,16 @@
 			 * Resort to a binary search over
 			 * sorted array of tags.
 			 */
-			asn_TYPE_tag2member_t *t2m;
+			const asn_TYPE_tag2member_t *t2m;
 			asn_TYPE_tag2member_t key;
 			key.el_tag = tlv_tag;
 			key.el_no = edx;
-			t2m = (asn_TYPE_tag2member_t *)bsearch(&key,
+			t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
 				specs->tag2el, specs->tag2el_count,
 				sizeof(specs->tag2el[0]), _t2e_cmp);
 			if(t2m) {
-				asn_TYPE_tag2member_t *best = 0;
-				asn_TYPE_tag2member_t *t2m_f, *t2m_l;
+				const asn_TYPE_tag2member_t *best = 0;
+				const asn_TYPE_tag2member_t *t2m_f, *t2m_l;
 				int edx_max = edx + elements[edx].optional;
 				/*
 				 * Rewind to the first element with that tag,
diff --git a/skeletons/constr_SEQUENCE.h b/skeletons/constr_SEQUENCE.h
index 5f589d5..c2aeb66 100644
--- a/skeletons/constr_SEQUENCE.h
+++ b/skeletons/constr_SEQUENCE.h
@@ -11,7 +11,7 @@
 extern "C" {
 #endif
 
-typedef struct asn_SEQUENCE_specifics_s {
+typedef const struct asn_SEQUENCE_specifics_s {
 	/*
 	 * Target structure description.
 	 */
@@ -21,14 +21,14 @@
 	/*
 	 * Tags to members mapping table (sorted).
 	 */
-	asn_TYPE_tag2member_t *tag2el;
+	const asn_TYPE_tag2member_t *tag2el;
 	int tag2el_count;
 
 	/*
 	 * Optional members of the extensions root (roms) or additions (aoms).
 	 * Meaningful for PER.
 	 */
-	int *oms;		/* Optional MemberS */
+	const int *oms;		/* Optional MemberS */
 	int  roms_count;	/* Root optional members count */
 	int  aoms_count;	/* Additions optional members count */
 
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index e8410a8..1fcbc2e 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -175,7 +175,7 @@
 		 * for optimization.
 		 */
 	  for(;; ctx->step = 0) {
-		asn_TYPE_tag2member_t *t2m;
+		const asn_TYPE_tag2member_t *t2m;
 		asn_TYPE_tag2member_t key;
 		void *memb_ptr;		/* Pointer to the member */
 		void **memb_ptr2;	/* Pointer to that pointer */
@@ -225,7 +225,7 @@
 		}
 
 		key.el_tag = tlv_tag;
-		t2m = (asn_TYPE_tag2member_t *)bsearch(&key,
+		t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
 				specs->tag2el, specs->tag2el_count,
 				sizeof(specs->tag2el[0]), _t2e_cmp);
 		if(t2m) {
@@ -439,7 +439,8 @@
 	size_t computed_size = 0;
 	asn_enc_rval_t er;
 	int t2m_build_own = (specs->tag2el_count != td->elements_count);
-	asn_TYPE_tag2member_t *t2m;
+	const asn_TYPE_tag2member_t *t2m;
+	asn_TYPE_tag2member_t *t2m_build;
 	int t2m_count;
 	ssize_t ret;
 	int edx;
@@ -448,17 +449,16 @@
 	 * Use existing, or build our own tags map.
 	 */
 	if(t2m_build_own) {
-		t2m = (asn_TYPE_tag2member_t *)alloca(
-				td->elements_count * sizeof(t2m[0]));
-		if(!t2m) _ASN_ENCODE_FAILED; /* There are such platforms */
+		t2m_build = (asn_TYPE_tag2member_t *)alloca(
+				td->elements_count * sizeof(t2m_build[0]));
+		if(!t2m_build) _ASN_ENCODE_FAILED; /* There are such platforms */
 		t2m_count = 0;
 	} else {
+		t2m_build = NULL;
 		/*
 		 * There is no untagged CHOICE in this SET.
 		 * Employ existing table.
 		 */
-		t2m = specs->tag2el;
-		t2m_count = specs->tag2el_count;
 	}
 
 	/*
@@ -479,8 +479,8 @@
 					/* Mandatory elements missing */
 					_ASN_ENCODE_FAILED;
 				if(t2m_build_own) {
-					t2m[t2m_count].el_no = edx;
-					t2m[t2m_count].el_tag = 0;
+					t2m_build[t2m_count].el_no = edx;
+					t2m_build[t2m_count].el_tag = 0;
 					t2m_count++;
 				}
 				continue;
@@ -499,8 +499,8 @@
 		 * Remember the outmost tag of this member.
 		 */
 		if(t2m_build_own) {
-			t2m[t2m_count].el_no = edx;
-			t2m[t2m_count].el_tag = asn_TYPE_outmost_tag(
+			t2m_build[t2m_count].el_no = edx;
+			t2m_build[t2m_count].el_tag = asn_TYPE_outmost_tag(
 				elm->type, memb_ptr, elm->tag_mode, elm->tag);
 			t2m_count++;
 		} else {
@@ -513,18 +513,21 @@
 	/*
 	 * Finalize order of the components.
 	 */
-	assert(t2m_count == td->elements_count);
 	if(t2m_build_own) {
 		/*
 		 * Sort the underlying members according to their
 		 * canonical tags order. DER encoding mandates it.
 		 */
-		qsort(t2m, t2m_count, sizeof(specs->tag2el[0]), _t2e_cmp);
+		qsort(t2m_build, t2m_count, sizeof(specs->tag2el[0]), _t2e_cmp);
+		t2m = t2m_build;
 	} else {
 		/*
 		 * Tags are already sorted by the compiler.
 		 */
+		t2m = specs->tag2el;
+		t2m_count = specs->tag2el_count;
 	}
+	assert(t2m_count == td->elements_count);
 
 	/*
 	 * Encode the TLV for the sequence itself.
@@ -803,7 +806,7 @@
 	asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics;
 	asn_enc_rval_t er;
 	int xcan = (flags & XER_F_CANONICAL);
-	asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer;
+	const asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer;
 	int t2m_count = specs->tag2el_cxer_count;
 	int edx;
 
diff --git a/skeletons/constr_SET.h b/skeletons/constr_SET.h
index 0c78ed5..6a3a1aa 100644
--- a/skeletons/constr_SET.h
+++ b/skeletons/constr_SET.h
@@ -12,7 +12,7 @@
 #endif
 
 
-typedef struct asn_SET_specifics_s {
+typedef const struct asn_SET_specifics_s {
 	/*
 	 * Target structure description.
 	 */
@@ -25,21 +25,21 @@
 	 * Sometimes suitable for DER encoding (untagged CHOICE is present);
 	 * if so, tag2el_count will be greater than td->elements_count.
 	 */
-	asn_TYPE_tag2member_t *tag2el;
+	const asn_TYPE_tag2member_t *tag2el;
 	int tag2el_count;
 
 	/*
 	 * Tags to members mapping table, second edition.
 	 * Suitable for CANONICAL-XER encoding.
 	 */
-	asn_TYPE_tag2member_t *tag2el_cxer;
+	const asn_TYPE_tag2member_t *tag2el_cxer;
 	int tag2el_cxer_count;
 
 	/*
 	 * Extensions-related stuff.
 	 */
 	int extensible;				/* Whether SET is extensible */
-	unsigned int *_mandatory_elements;	/* Bitmask of mandatory ones */
+	const unsigned int *_mandatory_elements;	/* Bitmask of mandatory ones */
 } asn_SET_specifics_t;
 
 /*
diff --git a/skeletons/constr_SET_OF.h b/skeletons/constr_SET_OF.h
index bcd0966..75e18cf 100644
--- a/skeletons/constr_SET_OF.h
+++ b/skeletons/constr_SET_OF.h
@@ -11,7 +11,7 @@
 extern "C" {
 #endif
 
-typedef struct asn_SET_OF_specifics_s {
+typedef const struct asn_SET_OF_specifics_s {
 	/*
 	 * Target structure description.
 	 */
diff --git a/skeletons/constr_TYPE.h b/skeletons/constr_TYPE.h
index 88c8803..a9cd86d 100644
--- a/skeletons/constr_TYPE.h
+++ b/skeletons/constr_TYPE.h
@@ -83,8 +83,8 @@
  * The definitive description of the destination language's structure.
  */
 typedef struct asn_TYPE_descriptor_s {
-	char *name;	/* A name of the ASN.1 type. "" in some cases. */
-	char *xml_tag;	/* Name used in XML tag */
+	const char *name;	/* A name of the ASN.1 type. "" in some cases. */
+	const char *xml_tag;	/* Name used in XML tag */
 
 	/*
 	 * Generalized functions for dealing with the specific type.
@@ -108,10 +108,10 @@
 	 * Tags that are expected to occur.
 	 */
 	asn_outmost_tag_f  *outmost_tag;	/* <optional, internal> */
-	ber_tlv_tag_t *tags;	/* Effective tags sequence for this type */
-	int tags_count;		/* Number of tags which are expected */
-	ber_tlv_tag_t *all_tags;/* Every tag for BER/containment */
-	int all_tags_count;	/* Number of tags */
+	const ber_tlv_tag_t *tags;	/* Effective tags sequence for this type */
+	int tags_count;			/* Number of tags which are expected */
+	const ber_tlv_tag_t *all_tags;	/* Every tag for BER/containment */
+	int all_tags_count;		/* Number of tags */
 
 	asn_per_constraints_t *per_constraints;	/* PER compiled constraints */
 
@@ -125,7 +125,7 @@
 	 * Additional information describing the type, used by appropriate
 	 * functions above.
 	 */
-	void *specifics;
+	const void *specifics;
 } asn_TYPE_descriptor_t;
 
 /*
@@ -147,7 +147,7 @@
 	asn_constr_check_f *memb_constraints;	/* Constraints validator */
 	asn_per_constraints_t *per_constraints;	/* PER compiled constraints */
 	int (*default_value)(int setval, void **sptr);	/* DEFAULT <value> */
-	char *name;			/* ASN.1 identifier of the element */
+	const char *name;			/* ASN.1 identifier of the element */
 } asn_TYPE_member_t;
 
 /*
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index 6c859e1..1c01480 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -80,8 +80,8 @@
 		ber_tlv_tag_t tag,	/* EXPLICIT or IMPLICIT tag */
 		asn_app_consume_bytes_f *cb,
 		void *app_key) {
-	ber_tlv_tag_t *tags;	/* Copy of tags stream */
-	int tags_count;		/* Number of tags */
+	const ber_tlv_tag_t *tags;	/* Copy of tags stream */
+	int tags_count;			/* Number of tags */
 	size_t overall_length;
 	ssize_t *lens;
 	int i;
@@ -102,8 +102,9 @@
 		 * and initialize it appropriately.
 		 */
 		int stag_offset;
-		tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
-		if(!tags) {	/* Can fail on !x86 */
+		ber_tlv_tag_t *tags_buf;
+		tags_buf = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
+		if(!tags_buf) {	/* Can fail on !x86 */
 			errno = ENOMEM;
 			return -1;
 		}
@@ -111,10 +112,11 @@
 			+ 1	/* EXPLICIT or IMPLICIT tag is given */
 			- ((tag_mode == -1) && sd->tags_count);
 		/* Copy tags over */
-		tags[0] = tag;
+		tags_buf[0] = tag;
 		stag_offset = -1 + ((tag_mode == -1) && sd->tags_count);
 		for(i = 1; i < tags_count; i++)
-			tags[i] = sd->tags[i + stag_offset];
+			tags_buf[i] = sd->tags[i + stag_offset];
+		tags = tags_buf;
 	} else {
 		tags = sd->tags;
 		tags_count = sd->tags_count;
diff --git a/skeletons/tests/check-PER-INTEGER.c b/skeletons/tests/check-PER-INTEGER.c
index 0d971b3..1cb853b 100644
--- a/skeletons/tests/check-PER-INTEGER.c
+++ b/skeletons/tests/check-PER-INTEGER.c
@@ -24,7 +24,7 @@
 check_per_encode_constrained(int lineno, int unsigned_, long value, long lbound, unsigned long ubound, int bit_range) {
 	INTEGER_t st;
 	INTEGER_t *reconstructed_st = 0;
-	asn_INTEGER_specifics_t specs;
+	struct asn_INTEGER_specifics_s specs;
 	asn_per_constraints_t cts;
 	asn_enc_rval_t enc_rval;
 	asn_dec_rval_t dec_rval;