Recent

Author Topic: How to fix "Warning: Encountered an OMF reference to a section," from NASM code  (Read 427 times)

ecm

  • New Member
  • *
  • Posts: 12
I uploaded an example to https://pushbx.org/ecm/test/20250621/

This is built in this way:

Code: [Select]
test$ cat ../fpclarge.sh
#! /bin/bash

MYFPCDIR="$(dirname "$0")"
"$MYFPCDIR"/bin/ppcross8086 -vi -Tmsdos -WmLarge \
 -Fu"$MYFPCDIR"/lib/fpc/3.2.2/units/msdos/8086-large/rtl \
 "$@"
test$ nasm lzss.nas -o lzss.o -P nasm.mac -f obj
test$ ../fpclarge.sh test.pas

The lzss.nas and lzutil.pas files are from my LZEXE repo. lzutil.pas was changed slightly to build with FreePascal, in lzss.nas I only added the int3 instruction.

This displays 85 warnings all reading the same way:

Quote
Warning: Encountered an OMF reference to a section, that has been removed by smartlinking: DATA||

Running the application crashes, apparently because the assembly language code overwrites the function pointers that it uses to call into the main Pascal file's callbacks. I assume that this crash and the "an OMF reference" warnings are related and fixing one may fix the other too. If I delete everything except the LZCOMP public with an empty function from lzss.nas, then the warnings disappear. But I need it to declare and reserve space for its variables.

Searching the warning's text doesn't seem to give me any relevant results. On the wiki it tells me I should use smartlinking. Trying to disable smartlinking results in this:

Code: [Select]
test$ ../fpclarge.sh -XX- -CX- test.pas
Free Pascal Compiler version 3.2.2 [2021/05/17] for i8086
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: MS-DOS 16-bit real mode
Compiling test.pas
test.pas(42,1) Warning: Object system.o not found, Linking may fail !
test.pas(42,1) Warning: Object lzutil.o not found, Linking may fail !
Linking test.exe
test.pas(42,1) Warning: Object system.o not found, Linking may fail !
test.pas(42,1) Error: Can't open object file: system.o
test.pas(42,1) Warning: Object lzutil.o not found, Linking may fail !
test.pas(42,1) Error: Can't open object file: lzutil.o
test.pas(42,1) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted

Should I try to get it work without smartlinking? Or is there a way to make it work with DATA references in the lzss.nas file? Or do I need to put all variables into one of the .pas files and access them from the assembly file using extern?


ecm

  • New Member
  • *
  • Posts: 12
Got it, I needed to change this in lzss.nas:

Code: [Select]
section DATA public
To this:

Code: [Select]
section DATA class=DATA public
group DGROUP DATA

The group alone silences the warnings, but the class is required as well to make the linker allocate the space to our data. I used the compiler option -Xm to generate a map file which I then inspected. This eventually lead me to trying out the group and class changes.

ecm

  • New Member
  • *
  • Posts: 12
I ended up making the section directives conditional, building lzss.obj for TurboPascal and lzss.o for FreePascal. It seems TurboPascal doesn't like the group or class changes. Building lzutil.pas fails like this if I try the updated directives:

Code: [Select]
Turbo Pascal  Version 5.0  Copyright (c) 1983,88 Borland International
LZUTIL.PAS(73): Error 56: Invalid relocatable reference (LZSS.OBJ).
end.
   ^

 

TinyPortal © 2005-2018