Skip to content

emxbind: support a.out including os2_bind_header of old-EMX startup code #179

Description

@komh

Hi/2.

emxbind does not support a.out objs with old-EMX startup code, which is used by Free Pascal. For details, see komh/cross-os2emx#30.

Here is the patch:

0001-emxbind-support-a.out-including-os2_bind_header-of-o.patch

From cc66576989f8f09ec0031c2d7314cc67dfdfa072 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh78@gmail.com>
Date: Sat, 9 May 2026 17:55:48 +0900
Subject: [PATCH] emxbind: support a.out including os2_bind_header of old-EMX
 startup code

---
 src/emx/src/emxbind/fixup.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/emx/src/emxbind/fixup.c b/src/emx/src/emxbind/fixup.c
index 02b316d..1ba57f8 100644
--- a/src/emx/src/emxbind/fixup.c
+++ b/src/emx/src/emxbind/fixup.c
@@ -575,7 +575,15 @@ void os2_fixup (void)
   my_seek (&inp_file, data_base + data_off);
   my_read (&set_len, sizeof (set_len), &inp_file);
   if (set_len != DATASEG_MAGIC)
-    error ("invalid data segment (does not start with 0x%x)", DATASEG_MAGIC);
+    {
+      my_seek (&inp_file, data_base + data_off + sizeof (dword) * 13);
+      my_read (&set_len, sizeof (set_len), &inp_file);
+      /* Check if os2_bind_header of old-EMX startup code */
+      if (set_len != 0x02000000         /* flags: a.out application */
+          && set_len != 0x02000001)     /* flags: a.out DLL */
+        error ("invalid data segment (does not start with 0x%x)", DATASEG_MAGIC);
+      my_seek (&inp_file, data_base + data_off + sizeof (dword) * 10);
+    }
   /* Now read the offset to the __os2_dll set */
   my_read (&set_len, sizeof (set_len), &inp_file);
 
-- 
2.50.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions