-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linker puts the wrong source file path in symbol files #1354
Comments
The issue is probably with DIP which doesn't read properly source file name. |
#1350 analysis in more details, that probably issue is with Dwarf writer code which is used by code generator |
It can't be DIP. Both headers contain the same problem. Here are hex-dumps of the sym-file (wdump -B0 test.sym) old Watcom: offset = 00000000, length = 00000263 New Watcom: Open Watcom Executable Image Dump Utility offset = 00000000, length = 00000233 |
You are right, what I wrote before about DIP is non-sense. |
I've done a bit of debugging of wlink, and I can conclude that in the ProcPubsSect function in objcalc.c, the head element contains head->name.u.ptr (containing "test"), and it this element that is written to the symbol file in the DwarfAddModule function in dbgdwarf.c. |
It seems like if you compile the ASM source with the old Watcom, then wlink will add the correct path. So, the incorrect path appears to depend on contents of the obj file. It's the IdentifyObject() function called in DoPass1 in procfile.c that returns either the module name (new object file) or the correct path name (old object file), In objomf.c, PassCmd1 function, I can see that ProcTHREDR reads the correct pathname from the object file as one of the first actions, but then this must become overwritten since when this info is read with IdentifyObject, it instead contains the module name. |
I notice that ProcTHEADR actually doesn't do anything useful. It only reads the full pathname into a local variable, and then discards it. A fix that solves the problem is to use the name and link it to CurrMod->name.u.ptr. This works for a single file, but is not the final solution: static void ProcTHEADR( void )
} I can see that upon entry to PassCmd1, CurrMod->name.u.ptr is "test", which is the module name. The problem is that this is never overridden for the ASM source or when an object is not compiled for debugging. |
It is not as simple as it looks like. Multiple formats exists for debug info on input and on output. |
Actually, the line numbers generated for macros that are included in ASM source are wrong. The line numbers refer to another file, but the debugger think they relate to the current ASM file. Which creates strange behavior. Still, I'm used to that so it's not a big problem. The current problem with missing source is a big problem though. It makes it more or less impossible to debug device drivers and ASM source. Looking at the history of the ProcTHEADR, the current code was introduced in 1.7.0, but at that time did not use the name either. Anyway, from my understanding of how the debugger works, it cannot handle symbol files that have the module name as the source path. Therefore, the default that the linker use will ALWAYS malfunction if passed to the debugger. If the linker uses this information for internal operation, perhaps it would be better to add another name that always must be the pathname and that is written to the symbol file? |
Yes, I did it by multiple THEADR records for OMF format (first record is module name which can be different from source file name and second which should always contains full source file name. For DWARF it is not a problem there should be always source file name available. Problem can be if you have source OMF module (with line numbers only) and it is converted to DWARF output format by linker. This is current situation for ASM OMF modules. It looks like somewhere is bug and it lost source file name for output DWARF format. |
Since it works with old object files, I think something in ASM OMF modules has changed, which triggers a latent problem in the linker. I think the best solution would be to fix OMF modules in the linker rather than find out what change to the OMF modules triggered the issue. |
This solves the issue for any number of ASM sources (but results in memory leaks) #include "liballoc.h" static void ProcTHEADR( void )
} |
The correct function to get module name and source file name is IdentifyObject and GetOMFName function. |
I made a tempory fix in my build system that uses an old version of wasm until this is fixed, which appears to work correctly. |
OK. |
ASM source, and C suorce not compiled for debug gets the module name in the symbol file instead of the full path name. This results in the debugger not finding the source code. The linker writes the correct path to map-files, so the issue must be with the linker.
The text was updated successfully, but these errors were encountered: