diff --git a/omf/base-borland-debug.obj b/omf/base-borland-debug.obj new file mode 100644 index 0000000..bc192d9 Binary files /dev/null and b/omf/base-borland-debug.obj differ diff --git a/omf/base-borland.obj b/omf/base-borland.obj new file mode 100644 index 0000000..81fa573 Binary files /dev/null and b/omf/base-borland.obj differ diff --git a/omf/base-watcom-debug.obj b/omf/base-watcom-debug.obj new file mode 100644 index 0000000..93ae2e1 Binary files /dev/null and b/omf/base-watcom-debug.obj differ diff --git a/omf/base-watcom.obj b/omf/base-watcom.obj new file mode 100644 index 0000000..48bfce2 Binary files /dev/null and b/omf/base-watcom.obj differ diff --git a/omf/base.c b/omf/base.c new file mode 100644 index 0000000..d8da413 --- /dev/null +++ b/omf/base.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, world"); + return 0; +} diff --git a/omf/base.sh b/omf/base.sh new file mode 100644 index 0000000..d4281c8 --- /dev/null +++ b/omf/base.sh @@ -0,0 +1,7 @@ +#!/bin/sh +bcc32 -c -obase-borland.obj base.c +bcc32 -c -v -obase-borland-debug.obj base.c +wcc386 base.c +mv base.obj base-watcom.obj +wcc386 -d3 base.c +mv base.obj base-watcom-debug.obj diff --git a/omf/comdat-borland-debug.obj b/omf/comdat-borland-debug.obj new file mode 100644 index 0000000..bd2db2a Binary files /dev/null and b/omf/comdat-borland-debug.obj differ diff --git a/omf/comdat-borland.obj b/omf/comdat-borland.obj new file mode 100644 index 0000000..8e497fc Binary files /dev/null and b/omf/comdat-borland.obj differ diff --git a/omf/comdat-watcom-debug.obj b/omf/comdat-watcom-debug.obj new file mode 100644 index 0000000..7cb9428 Binary files /dev/null and b/omf/comdat-watcom-debug.obj differ diff --git a/omf/comdat-watcom.obj b/omf/comdat-watcom.obj new file mode 100644 index 0000000..c21ad68 Binary files /dev/null and b/omf/comdat-watcom.obj differ diff --git a/omf/comdat.cc b/omf/comdat.cc new file mode 100644 index 0000000..475fee0 --- /dev/null +++ b/omf/comdat.cc @@ -0,0 +1,21 @@ +typedef int (*f)(int); + +inline int foo1(int x) { + return x * x; +} + +inline int foo2(int x) { + return x + x; +} + +f bar1(void) { + return foo1; +} + +f bar2(void) { + return foo2; +} + +int main() { + return 0; +} diff --git a/omf/comdat.sh b/omf/comdat.sh new file mode 100644 index 0000000..c4e5c31 --- /dev/null +++ b/omf/comdat.sh @@ -0,0 +1,7 @@ +#!/bin/sh +bcc32 -P -c -ocomdat-borland.obj comdat.cc +bcc32 -P -c -v -ocomdat-borland-debug.obj comdat.cc +wpp386 comdat.cc +mv comdat.obj comdat-watcom.obj +wpp386 -d3 comdat.cc +mv comdat.obj comdat-watcom-debug.obj diff --git a/omf/comprehensive_test.asm b/omf/comprehensive_test.asm new file mode 100644 index 0000000..ffb9e4a --- /dev/null +++ b/omf/comprehensive_test.asm @@ -0,0 +1,150 @@ +; Comprehensive OMF test file that demonstrates all identified parser issues +; Build with: wasm -ml -fo=comprehensive_test.obj comprehensive_test.asm + +.model small +.386 + +; ======================================== +; Segment definitions for various test scenarios +; ======================================== + +_TEXT segment word public 'CODE' +_TEXT ends + +_DATA segment word public 'DATA' +_DATA ends + +CONST segment word public 'DATA' +CONST ends + +_BSS segment word public 'BSS' +_BSS ends + +; Group definition to test GROUP handling +DGROUP group _DATA, CONST, _BSS + +; ======================================== +; Code segment with various relocation types +; ======================================== + +_TEXT segment + assume cs:_TEXT, ds:DGROUP + +; Test 1: Thread subrecords and F/T bit handling +; This generates FIXUPP with thread definitions +test_threads proc near + ; Establish thread subrecords + mov ax, seg DGROUP ; Group reference + mov ds, ax + + ; External references that may use threads + mov bx, offset external_var + call external_func + + ; Far pointer that should generate fixup + les di, dword ptr far_ptr + ret +test_threads endp + +; Test 2: M-bit (segment-relative vs PC-relative) +test_mbit proc near + ; PC-relative jumps (M=0) + jmp short next_label +next_label: + call near_func + + ; Segment-relative offsets (M=1) + mov ax, offset data_item + mov bx, offset test_threads + + ; Direct memory reference (M=1) + mov cx, [data_item] + + ret +test_mbit endp + +near_func proc near + xor ax, ax + ret +near_func endp + +; Test 3: Frame Method 3 (would need special encoding) +; Note: OpenWatcom assembler may optimize this differently +test_frame proc near + ; Attempt to generate explicit frame references + db 0EAh ; Far JMP opcode + dw 0 ; Offset + dw 0040h ; Frame number < 0x80 + + db 0EAh ; Far JMP + dw 0 ; Offset + dw 1234h ; Frame number > 0x80 + + ret +test_frame endp + +_TEXT ends + +; ======================================== +; Data segment with various patterns +; ======================================== + +_DATA segment + +; Test data for relocations +data_item dw 1234h +far_ptr dd test_threads ; Far pointer + +; Test for LIDATA generation (if supported by assembler) +; Note: WASM typically generates LEDATA, not LIDATA +buffer1 db 100 dup(0) ; Repeated pattern +buffer2 dw 50 dup(0FFFFh) ; Repeated words + +; References that generate fixups +code_refs dw offset test_threads + dw offset test_mbit + dw seg _TEXT + +_DATA ends + +; ======================================== +; BSS segment (uninitialized data) +; ======================================== + +_BSS segment +uninit_data dw 100 dup(?) +_BSS ends + +; ======================================== +; COMDEF - Common definitions +; ======================================== + +; These generate COMDEF records +comm near shared_var:word:1 +comm far shared_array:byte:256 + +; ======================================== +; Absolute symbols - these should generate PUBDEF with segment_index == 0 +; ======================================== + +; BIOS data area addresses +BIOS_TIMER_TICKS EQU 046Ch ; Absolute address 0040:006C +BIOS_KEYBOARD_FLAGS EQU 0417h ; Absolute address 0040:0017 +VIDEO_MEMORY EQU 0B800h ; Video memory segment (frame number) + +; ======================================== +; External declarations for fixup generation +; ======================================== + +extern external_var:word +extern external_func:near + +; ======================================== +; Public symbols +; ======================================== + +public test_threads +public test_mbit +public data_item + + end test_threads diff --git a/omf/comprehensive_test.obj b/omf/comprehensive_test.obj new file mode 100644 index 0000000..4abef11 Binary files /dev/null and b/omf/comprehensive_test.obj differ diff --git a/omf/test_comdat.cpp b/omf/test_comdat.cpp new file mode 100644 index 0000000..2eff141 --- /dev/null +++ b/omf/test_comdat.cpp @@ -0,0 +1,69 @@ +// test_comdat.cpp - Test file to generate COMDAT records +// Compile with: wpp386 -d3i test_comdat.cpp + +#include + +// Template function - should generate COMDAT +template +T max_value(T a, T b) { + return (a > b) ? a : b; +} + +// Inline function - should generate COMDAT with -d3i +inline int add(int a, int b) { + return a + b; +} + +// Another inline function +inline int multiply(int x, int y) { + return x * y; +} + +// Template class with inline methods +template +class Container { +private: + T value; +public: + Container(T v) : value(v) {} + + inline T get() const { return value; } + inline void set(T v) { value = v; } +}; + +// Regular function +void regular_function() { + printf("Regular function\n"); +} + +int main() { + // Use template functions to force instantiation + int a = 5, b = 10; + int max_int = max_value(a, b); + + float f1 = 3.14f, f2 = 2.71f; + float max_float = max_value(f1, f2); + + // Use inline functions + int sum = add(3, 4); + int product = multiply(5, 6); + + // Use template class + Container int_container(100); + int_container.set(200); + int val = int_container.get(); + + Container double_container(3.14); + double_container.set(2.71); + double dval = double_container.get(); + + // Use regular function + regular_function(); + + printf("Max int: %d\n", max_int); + printf("Max float: %f\n", max_float); + printf("Sum: %d, Product: %d\n", sum, product); + printf("Container values: %d, %f\n", val, dval); + + return 0; +} diff --git a/omf/test_comdat.obj b/omf/test_comdat.obj new file mode 100644 index 0000000..a0db33c Binary files /dev/null and b/omf/test_comdat.obj differ diff --git a/omf/test_lidata.c b/omf/test_lidata.c new file mode 100644 index 0000000..b49747e --- /dev/null +++ b/omf/test_lidata.c @@ -0,0 +1,26 @@ +// Simple C file to generate LIDATA records +// OpenWatcom C compiler generates LIDATA for large initialized arrays +// Build with: wcc -ms -bt=DOS -fo=test_lidata.obj test_lidata.c + +// Arrays with >= 50 elements of the same value generate LIDATA +char zeros[100] = {0}; // 100 zero bytes -> LIDATA +int pattern[75] = {0x5555}; // 75 ints with same value -> LIDATA +unsigned short ffs[50] = {0xFFFF}; // 50 shorts -> LIDATA + +// Smaller arrays use LEDATA +char small[10] = {0}; // Too small, uses LEDATA + +// Mixed patterns don't generate LIDATA +char mixed[] = {1, 2, 3, 4, 5}; // Different values, uses LEDATA + +// Function to reference the data +void use_arrays() { + zeros[0] = 1; + pattern[0] = 2; + ffs[0] = 3; +} + +int main() { + use_arrays(); + return 0; +} diff --git a/omf/test_lidata.obj b/omf/test_lidata.obj new file mode 100644 index 0000000..4f443c1 Binary files /dev/null and b/omf/test_lidata.obj differ