Support for Delphi 6
The Delphi 6 linker produces MAP files that cannot be read by map2pdb out of the box. It reports overlapping segments via an exception, with no details as to what the offending segments are.
Is there any chance of getting this ancient IDE supported by this tool? It would help me immensely.
I’m attaching a sample Hello World application source, executable and map file produced.
Comments (5)
-
-
reporter Is there any definitive source on the format of the MAP files themselves, or is it just guesswork? Because I’d venture a guess that the files are valid, from Delphi’s point of view - the segments indices needn’t be identifiers, but rather pointers to the real EXE file’s sections (so the MAP file above would mean that the EXE file’s
.text
section contains segment0001
and the segment0002
spans the EXE file’s sections.data
and.bss
, from.data
's start offset of0
. -
repo owner No there’s no formal definition of the map file format. It’s not a file format that is consumed by Delphi itself so it’s perfectly possible for Delphi to produce garbage map files and never notice it.
While it might be possible to create a set of rules that will fit your map file, it will mean that large parts of the current design must be rewritten. I rely on segment indices being unique (it’s the key into the segment collection) and I rely on segment offsets and size being correct.
If you look at the map files of newer Delphi versions then you will see that no segments overlap and all indices are unique. The same applies for pdb files produced by for example VS.
Here’s the EXE sections of your application:
As you can see the
.text
,.data
and.bss
are three separate sections and they should have been tree separate segments in the map file. -
repo owner - changed status to resolved
Fixes
#1This change enables the map reader to parse Delphi 6 generated map files. Map reader: Fix for symbol name that does not start with module name causes error. Fix various related string indexing bugs.→ <<cset e09a9f4419f4>>
-
repo owner Added support for legacy map file (e.g Delphi 7) with invalid segment and module info.
→ <<cset dbd7fdb0fc67>>
- Log in to comment
Yes, it’s a bit inconvenient that the error message doesn’t state which the overlapping segments are (I’ll fix that) but in your case there’s no doubt - because they all overlap:
As you can see the
.data
and.bss
segments both overlap the.text
segment. On top of that you have two segments with the same index:0002
. This is also illegal.If I recalculate the segment offsets and make the indices unique:
Then the segments pass but now the symbol parser bugs out because the format of the symbol names is different from that of newer Delphi versions (and there’s also a few bugs in my symbol name parser). I’ll get the bugs fixed and modify the symbol name parser so it can handle the Delphi 6 format, but I think you will have to handle the invalid segment indices and offset values yourself.