Commit Graph

271 Commits

Author SHA1 Message Date
nickysn
295daf4a7f + recognize stack segments and fill the total stack size in the NewExe header
git-svn-id: trunk@42589 -
2019-08-06 00:40:43 +00:00
nickysn
a86623b97a + initialize the flags for the code and data segments in the NewExe header
git-svn-id: trunk@42588 -
2019-08-06 00:23:31 +00:00
nickysn
7132973847 + added the missing NewExe segment attributes as properties to the
TNewExeSection class and create the NewExe segment table into the .exe file.
  Not all of the properties are initialized yet, though.

git-svn-id: trunk@42587 -
2019-08-05 17:08:18 +00:00
nickysn
d7c24c05d0 + fill the segment table start offset in the NewExe header
git-svn-id: trunk@42584 -
2019-08-05 13:30:01 +00:00
nickysn
c70f2c63cd + set the initial SS:SP in the NewExe header
git-svn-id: trunk@42572 -
2019-08-03 01:04:32 +00:00
nickysn
dbafff24fe + fill the program entry point address in the NewExe header
git-svn-id: trunk@42571 -
2019-08-03 00:59:02 +00:00
nickysn
901dde5fa5 + fill the auto data segment number in the NewExe header
git-svn-id: trunk@42570 -
2019-08-03 00:42:56 +00:00
nickysn
34b3af7e92 * reset CurrMemPos after each NewExeSection to ensure each segment starts at 0 offset
git-svn-id: trunk@42569 -
2019-08-02 23:22:59 +00:00
nickysn
868030b3fe + adapted TOmfObjSection.MemPosStr to output segment:offset for NewExe executables
git-svn-id: trunk@42568 -
2019-08-02 23:01:39 +00:00
nickysn
2c176be2fd + adapted TOmfObjSymbol.AddressStr to show correct segment:offset for NewExe files as well
git-svn-id: trunk@42567 -
2019-08-02 22:47:44 +00:00
nickysn
b739d79f9b * combine the data, bss, stack and heap into the same NewExe segment
git-svn-id: trunk@42566 -
2019-08-02 16:53:16 +00:00
nickysn
1258439767 + added an TNewExeSection.MemPosStr override that outputs a segment:offset string
git-svn-id: trunk@42565 -
2019-08-02 16:14:54 +00:00
nickysn
8e436e6335 + add a segment number (MemBasePos) to TNewExeSection
git-svn-id: trunk@42563 -
2019-08-02 14:47:19 +00:00
nickysn
30e7406be3 * override MemPos_Start for the NewExe exe output and perform the whole MemPos
stage inside of it, because the linker script contains only dummy section
  names and thus none of the sections get their MemPos set, while using the
  default implementation

git-svn-id: trunk@42562 -
2019-08-02 14:32:40 +00:00
nickysn
c32ddf42eb * create NewExe sections, corresponding to 64kb segments
git-svn-id: trunk@42561 -
2019-08-02 14:20:02 +00:00
nickysn
5d01d53a96 * don't crash in TOmfObjSection.MemPosStr if MZExeUnifiedLogicalSegment isn't set
git-svn-id: trunk@42553 -
2019-08-01 16:44:46 +00:00
nickysn
93a08aaebd + write the NewExe header in TNewExeOutput.writeData
git-svn-id: trunk@42552 -
2019-08-01 16:43:39 +00:00
nickysn
d10fb705e4 + added an TNewExeOutput.Order_ObjSectionList override and sort obj sections by
class name first, then by name, then by initial order

git-svn-id: trunk@42551 -
2019-08-01 15:52:19 +00:00
nickysn
05c420fad5 + create a TNewExeSection class
git-svn-id: trunk@42546 -
2019-07-31 13:47:14 +00:00
nickysn
83861799ae + also add and resolve import symbols coming from OMF object modules
git-svn-id: trunk@42545 -
2019-07-31 13:32:43 +00:00
nickysn
d77a8fb5f4 + call TOmfObjData.AddImportSymbol for every ImpDef record read from an object file
git-svn-id: trunk@42543 -
2019-07-31 01:19:51 +00:00
nickysn
fcb6072fae + added method TOmfObjData.AddImportSymbol, which adds symbols, imported from an
external dll to TOmfObjData.ImportLibraryList (similar to
  TInternalLinker.AddImportSymbol)

git-svn-id: trunk@42542 -
2019-07-31 01:12:00 +00:00
nickysn
d2371f4176 + added an ImportLibraryList property to TOmfObjData
git-svn-id: trunk@42541 -
2019-07-31 01:05:53 +00:00
nickysn
2b6ee838f9 + implemented TNewExeOutput.GenerateLibraryImports, based on the ogcoff implementation
git-svn-id: trunk@42535 -
2019-07-30 16:34:41 +00:00
nickysn
0a94f8fc08 + parse the IMPDEF record in TOmfObjInput.ReadImpDef
git-svn-id: trunk@42346 -
2019-07-09 12:31:11 +00:00
nickysn
eea3eb1a8e + introduced the TOmfRecord_COMENT_IMPDEF class. Use it to encode the IMPDEF
records instead of encoding them directly.

git-svn-id: trunk@42236 -
2019-06-14 23:50:48 +00:00
nickysn
9fe80d7416 + use the new CC_OmfExtension_IMPDEF constant instead of the direct magic value
when writing IMPDEF records

git-svn-id: trunk@42234 -
2019-06-14 23:11:25 +00:00
nickysn
0db19546ef + dispatch the IMPDEF and EXPDEF records to the newly introduced ReadImpDef and
ReadExpDef methods (not implemented yet)

git-svn-id: trunk@42232 -
2019-06-14 23:06:58 +00:00
nickysn
d3c3f2742c + added class TNewExeOutput. Not functional yet.
git-svn-id: trunk@42225 -
2019-06-14 16:23:23 +00:00
nickysn
7871ccd054 + initialize some defaults in the TNewExeHeader constructor
git-svn-id: trunk@42224 -
2019-06-14 15:51:25 +00:00
nickysn
1474db42e4 + added class TNewExeHeader that encapsulates a NewExe header and allows writing it to a file
git-svn-id: trunk@42223 -
2019-06-14 14:16:22 +00:00
nickysn
2487fa7605 + added set TNewExeSegmentFlags
git-svn-id: trunk@42203 -
2019-06-10 13:06:58 +00:00
nickysn
465e8a99e0 + added type TNewExeAdditionalHeaderFlags
git-svn-id: trunk@42188 -
2019-06-07 14:15:07 +00:00
nickysn
ded3dec22a + added enum TNewExeTargetOS
git-svn-id: trunk@42187 -
2019-06-07 13:09:35 +00:00
nickysn
4dbccce43c + added TNewExeHeaderFlags type, describing the flags in the header of win16 executables
git-svn-id: trunk@42179 -
2019-06-06 16:00:29 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
pierre
22ea2bd624 Avoid warnings with -O4 option
git-svn-id: trunk@40821 -
2019-01-09 22:48:08 +00:00
nickysn
635a6c7ef8 * fixed msdos .com file generation
git-svn-id: trunk@40720 -
2018-12-31 17:41:31 +00:00
florian
6a2cb0bbbd * more compilation fixes
git-svn-id: trunk@39350 -
2018-06-30 12:48:54 +00:00
nickysn
f036e67d8f * fixed the reading of OMF groups by the internal linker. Previously, it only
worked, when the files had only one group, called 'DGROUP'.

git-svn-id: trunk@39279 -
2018-06-22 17:00:23 +00:00
nickysn
45337b67fe + when using the i8086 with section based smartlinking, create OMF section
groups, named 'CGROUP' or 'CGROUP_UNITNAME', which include all the code
  sections, that need to be put in the same segment

git-svn-id: trunk@39277 -
2018-06-22 15:02:39 +00:00
nickysn
f07658d3dc * get rid of TOmfRelocation.GetGroupIndex; instead, read the index property of
the group object. This adds support for groups, other than DGROUP, when
  writing omf relocations.

git-svn-id: trunk@39276 -
2018-06-22 14:29:09 +00:00
nickysn
c8fc7c84c8 * avoid adding a section to a group twice in TOmfObjData.createsection
* add all sections, belonging to a group directly inside TOmfObjOutput.AddGroup,
  based on the TObjSectionsGroup.members array

git-svn-id: trunk@39275 -
2018-06-21 21:14:54 +00:00
nickysn
8a34bd22b8 * pass a TObjSectionGroup object as parameter to TOmfObjOutput.AddGroup, instead
of the group name

git-svn-id: trunk@39273 -
2018-06-21 20:45:52 +00:00
nickysn
d3db9e101a * don't check for the presence of the group in TOmfObjOutput.AddSegmentToGroup,
because, it is no longer possible for it to not be present (all the groups
  are added beforehand now)

git-svn-id: trunk@39272 -
2018-06-21 20:33:24 +00:00
nickysn
9a0eca52cb * changed the type of TOmfObjSection.PrimaryGroup from string to
TObjSectionGroup, so instead of holding the group's name, it now points to the
  TObjSectionGroup object, from which you can retrieve its name or any of the
  other fields and properties it contains

git-svn-id: trunk@39271 -
2018-06-21 16:28:06 +00:00
nickysn
42f06acaeb + also create the primary section group and add the newly created section to it
in TOmfObjData.createsection

git-svn-id: trunk@39270 -
2018-06-21 16:14:42 +00:00
nickysn
f4e26f382f + added an 'index' field to TObjSectionGroup, specifying the index of the group
in the object file (similar to TObjSection.index, but for groups, instead of
  sections). Set the new index field, when writing .obj files with the internal
  omf object writer.

git-svn-id: trunk@39269 -
2018-06-21 15:51:58 +00:00
nickysn
ab47c8b899 + introduce the omf_section_primary_group function. Use it instead of
section_belongs_to_dgroup, to allow sections to belong to groups, other than
  dgroup.

git-svn-id: trunk@39268 -
2018-06-21 13:21:53 +00:00
nickysn
5eb69edf9e + support segments (sections) with a primary group, other than 'DGROUP' in the
OMF internal object writer

git-svn-id: trunk@39245 -
2018-06-20 14:57:20 +00:00
nickysn
7fcec8460f + parse OMF COMENT records when reading object files and produce error messages
for the records that are not supported, but are important for the executable
  being produced (such as weak/lazy externals, etc.)

git-svn-id: trunk@39241 -
2018-06-18 14:48:04 +00:00
nickysn
3aff9d6735 * set MemPos to 0 for each debug .MZ section. This fixes all references within
the debug sections themselves.

git-svn-id: trunk@39235 -
2018-06-15 14:49:43 +00:00
nickysn
84b5265312 + append a TIS trailer after the debug ELF (this helps the watcom debugger find
the beginning of the ELF debug image)

git-svn-id: trunk@39229 -
2018-06-15 13:41:40 +00:00
nickysn
480eedac9f * fix/pretty print the segment and group list with too long segment/group/class
names in the linker map file, produced by the i8086 internal linker

git-svn-id: trunk@39228 -
2018-06-15 00:03:58 +00:00
nickysn
8af56ad6c8 * fixed silly (caused by copy/paste) bug when writing elf section contents in the dwarf debug binary, produced by TMZExeOutput.writeDebugElf
git-svn-id: trunk@39227 -
2018-06-14 16:29:25 +00:00
nickysn
11cf2a6996 * emit a warning, when encountering an omf reference to a section, that has been
removed due to smartlinking

git-svn-id: trunk@39226 -
2018-06-14 16:22:47 +00:00
nickysn
c41f736958 + allow MemPos_EndExeSection to be called with an empty section name
git-svn-id: trunk@39225 -
2018-06-14 16:17:00 +00:00
nickysn
97365abbcf + set the oso_debug flag to dwarf MZ exe sections
git-svn-id: trunk@39224 -
2018-06-14 16:15:11 +00:00
nickysn
239fb25179 + assign an MZExeUnifiedLogicalSegment object to the OMF dwarf sections, so that
OMF relocations work on them too

git-svn-id: trunk@39223 -
2018-06-14 16:03:05 +00:00
nickysn
7103e3cb5c + set the oso_debug section flags when reading an OMF section, which belongs to
the 'DWARF' class

git-svn-id: trunk@39222 -
2018-06-14 15:27:08 +00:00
nickysn
c56ebad183 + implemented writing of dwarf debug info (by calling writeDebugElf) in
TMZExeOutput.writeData. Note that writing i8086 debug info with the internal
  linker is still disabled (i.e. it switches to external linking) in 
  options.TOption.checkoptionscompatibility

git-svn-id: trunk@39219 -
2018-06-14 14:30:59 +00:00
nickysn
29b3ec3fdb * call MaybeSwapHeader and MaybeSwapSecHeader in TMZExeOutput.writeDebugElf, so
the debug ELF file is generated with the correct endianness

git-svn-id: trunk@39218 -
2018-06-14 13:02:54 +00:00
nickysn
daa47f4b7f + completed the internal debug ELF writer in TMZExeOutput.writeDebugElf (not
enabled yet)

git-svn-id: trunk@39216 -
2018-06-13 16:08:54 +00:00
nickysn
420a57ddc6 * use upper case OMF section names when using i8086 section-based smart linking
git-svn-id: trunk@39212 -
2018-06-12 00:14:08 +00:00
nickysn
b9ab9e5782 + initial (experimental) implementation of section-based smartlinking for i8086.
Use -dI8086_SMARTLINK_SECTIONS to enable.

git-svn-id: trunk@39211 -
2018-06-11 16:56:33 +00:00
nickysn
bfdd75eabf + support AB_LOCAL symbols in OMF object files, by implementing support for
LPUBDEF/LPUBDEF32 OMF records

git-svn-id: trunk@39210 -
2018-06-11 15:29:23 +00:00
nickysn
e6a8c058e0 * moved the handling of LIDATA OMF records (which currently only produces a
'LIDATA records are not supported' error) to TOmfObjInput.ReadLeOrLiDataAndFixups

git-svn-id: trunk@39171 -
2018-06-04 14:20:07 +00:00
nickysn
02fc2827e0 * TOmfObjInput.ReadLEDataAndFixups renamed ReadLeOrLiDataAndFixups
git-svn-id: trunk@39170 -
2018-06-04 14:10:11 +00:00
nickysn
e410a0aefb + support OMF FIXUPP records, containing only THREAD subrecords to occur without
a preceding LEDATA or LIDATA record (this is allowed by the OMF spec)

git-svn-id: trunk@39169 -
2018-06-04 14:00:36 +00:00
nickysn
002b116322 * use a case statement, instead of 'if', based on the OMF record type in
TOmfObjInput.ReadLEDataAndFixups. This is to allow (in the future) handling of
  LIDATA records and FIXUPP records without preceding LEDATA/LIDATA. No
  functional changes in this commit.

git-svn-id: trunk@39166 -
2018-06-04 13:11:55 +00:00
nickysn
98634899f2 + support OMF fixups, determined by thread
git-svn-id: trunk@39151 -
2018-05-30 15:49:27 +00:00
nickysn
2fb73de404 + support reading OMF files with THREAD FIXUPP subrecords; note that fixups,
determined by thread are still not yet implemented

git-svn-id: trunk@39150 -
2018-05-30 14:30:54 +00:00
nickysn
ebecfb1ce9 + added a FFixupThreads property with a TOmfThreads object to TOmfObjInput
git-svn-id: trunk@39149 -
2018-05-30 14:10:12 +00:00
nickysn
f505718e6c + started implementing TMZExeOutput.writeDebugElf; nothing is written yet, only
the elf header fields are filled with the values, generated by wlink

git-svn-id: trunk@39115 -
2018-05-25 14:20:13 +00:00
pierre
f80e73eac2 Remove references to sym variable when not set (revealed warning generated when compiling with -O4 option)
git-svn-id: trunk@39101 -
2018-05-23 20:45:21 +00:00
nickysn
8c842c1337 * changed the type of the 'size' parameter of TOmfObjOutput.AddSegment to
TObjSectionOfs instead of aword

git-svn-id: trunk@39093 -
2018-05-22 13:48:55 +00:00
nickysn
f5862efcd4 + support writing 32-bit LEDATA OMF records
git-svn-id: trunk@39092 -
2018-05-22 13:23:56 +00:00
nickysn
ca50b14e21 * set the omf section size limit to 32-bit for the dwarf debug sections
git-svn-id: trunk@39088 -
2018-05-22 12:41:51 +00:00
nickysn
600b460ecd + added new debug output option -godwarfomflinnum for generating line number
information in OMF LINNUM records, in addition to the DWARF debug information.
  This enables source level debugging on i8086-msdos, when using the Open Watcom
  Debugger, provided the source was compiled with this option and the external
  linker (wlink) was used for generating the executable (the internal linker
  does not yet support generating debug information).

git-svn-id: trunk@39014 -
2018-05-17 14:38:50 +00:00
nickysn
3d6d020fca + implemented the actual writing of LINNUM OMF records
git-svn-id: trunk@39008 -
2018-05-16 17:37:28 +00:00
nickysn
b80642c384 + started implementing support for generating Microsoft CodeView debug
information. Only enabled on i8086 (for now). Does not do much yet, but
  hopefully, soon it'll start emitting line number information for i8086-msdos
  that is usable by DOS debuggers.

git-svn-id: trunk@39006 -
2018-05-16 15:25:33 +00:00
nickysn
718e83954f * merge duplicate strings in the LNAMES section, when writing OMF object
modules. This results in slightly smaller obj files.

git-svn-id: trunk@38967 -
2018-05-10 13:07:32 +00:00
nickysn
65c2575883 + added win16stub const array (small dos exe, which prints 'This program
requires Microsoft Windows.'). Will be used by the future win16 internal
  linker.

git-svn-id: trunk@37775 -
2017-12-21 15:00:43 +00:00
nickysn
7763942907 * fixed the 'Unsupported fixup location type' error messages in the MZ internal
linker

git-svn-id: trunk@37631 -
2017-11-28 02:29:28 +00:00
nickysn
2af5c9d508 * changed type used for section alignment from byte/shortint to longint, so the
internal object writer and the internal linker support object files with
  sections with alignment >=256

git-svn-id: trunk@37518 -
2017-10-25 15:47:29 +00:00
florian
e7fd71db36 + write name of segment/group which is too large
git-svn-id: trunk@35456 -
2017-02-19 19:15:18 +00:00
nickysn
c2305809dc + added an i8086-embedded target support to the compiler (RTL and makefile
support are not done yet)

git-svn-id: trunk@33999 -
2016-06-17 19:15:24 +00:00
florian
90b284e169 + generate .debug_aranges sections for dwarf debug info: enables faster address to debug info translation
git-svn-id: trunk@33454 -
2016-04-08 20:19:59 +00:00
nickysn
db5e67c3fe + introduced a new type TRelocDataInt for use as the 'data' parameter for
TObjData.writeReloc; on i8086 it was changed to longint to allow using 32-bit
  relocations
+ added support for writing 32-bit OMF relocations

git-svn-id: trunk@32936 -
2016-01-13 17:57:36 +00:00
nickysn
4f8baf29c6 + handle RELOC_FARPTR48 relocations as well in TOmfObjData.writeReloc; this is
not used yet, but is added for completeness (and might be useful, if we add an
  i386 target, that uses the OMF object format)

git-svn-id: trunk@32935 -
2016-01-13 15:07:41 +00:00
nickysn
e628729e1d + support 48-bit (16:32) far pointer relocations in the OMF internal linker
git-svn-id: trunk@32928 -
2016-01-11 17:50:27 +00:00
nickysn
02a6b77e32 + added support for 32-bit offset OMF relocations (fltOffset32) in the OMF internal linker
git-svn-id: trunk@32927 -
2016-01-11 17:34:56 +00:00
nickysn
c8e20dfe74 + added i8086-specific consts RELOC_ABSOLUTE16 and RELOC_RELATIVE16, which are
aliases for RELOC_ABSOLUTE and RELOC_RELATIVE
* use RELOC_ABSOLUTE16 and RELOC_RELATIVE16, instead of RELOC_ABSOLUTE and
  RELOC_RELATIVE in the linker-related parts of the OMF support (OMF object
  reader and MZ exe output). This will make the code more readable, when 32-bit
  relocation support is added to the linker. It will also make easier to reuse
  this code for i386, in case we add an i386 target, that uses the OMF object
  format.

git-svn-id: trunk@32923 -
2016-01-11 15:24:34 +00:00
nickysn
b9ca24d4df + added property to the omf object reader, specifying whether symbol names
should be case sensitive (on by default, for now)

git-svn-id: trunk@32435 -
2015-11-21 15:35:42 +00:00
nickysn
d5428ee210 * the CaseSensitive property in TOmfObjInput renamed CaseSensitiveSegments,
because it only applies to segments/groups/overlays and not symbols.

git-svn-id: trunk@32389 -
2015-11-21 11:25:21 +00:00
nickysn
e4b77c7aab * accept omf object modules, containing LINNUM and LINNUM32 records in the
i8086-msdos internal linker

git-svn-id: trunk@32382 -
2015-11-20 17:41:35 +00:00
nickysn
30a7875d56 + added hack for supporting linking with .obj files, generated by Borland's
binobj tool with the i8086-msdos internal linker

git-svn-id: trunk@32381 -
2015-11-20 17:40:34 +00:00
nickysn
0d48e5f6c7 + added support to the omf/i8086-msdos internal linker for omf relocation with
location type 3 (fltFarPointer). This isn't generated by nasm, nor by the
  internal object writer (yet), but may be generated by other
  assemblers/compilers - TASM generates it (tested with it), MASM probably also
  does.

git-svn-id: trunk@32346 -
2015-11-16 14:51:05 +00:00
nickysn
b744c83581 + implemented support for omf fixup records with target group other than 'DGROUP' in the i8086-msdos internal linker
git-svn-id: trunk@32294 -
2015-11-12 16:40:17 +00:00
nickysn
7d41d19150 + added an error message when trying to compile a tiny model DOS .COM file with
segment relocations

git-svn-id: trunk@32276 -
2015-11-08 21:13:16 +00:00