+Segment* GetSegment (const char* Name, unsigned char Type, const char* ObjName)
+/* Search for a segment and return an existing one. If the segment does not
+ * exist, create a new one and return that. ObjName is only used for the error
+ * message and may be NULL if the segment is linker generated.
+ */
+{
+ /* Create a hash over the name and try to locate the segment in the table */
+ unsigned HashVal = HashStr (Name) % HASHTAB_SIZE;
+ Segment* S = SegFindInternal (Name, HashVal);
+
+ /* If we don't have that segment already, allocate it using the type of
+ * the first section.
+ */
+ if (S == 0) {
+ /* Create a new segment */
+ S = NewSegment (Name, HashVal, Type);
+ } else {
+ /* Check if the existing segment has the requested type */
+ if (S->Type != Type) {
+ /* Allow an empty object name */
+ if (ObjName == 0) {
+ ObjName = "[linker generated]";
+ }
+ Error ("Module `%s': Type mismatch for segment `%s'", ObjName, Name);
+ }
+ }
+
+ /* Return the segment */
+ return S;
+}
+
+
+
+Section* NewSection (Segment* Seg, unsigned char Align, unsigned char Type)