Commit Graph

239 Commits

Author SHA1 Message Date
svenbarth
846775f4b6 Merged revision(s) 46875-46876 from trunk:
* generate an internal error if the section name should be larger than 8
........
* fix for Mantis #37745: section names where the string offset has more than 7 digits need to be Base64 encoded
........

git-svn-id: branches/fixes_3_2@47590 -
2020-11-25 22:25:26 +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
99a3855e6b * restored old default values for MajorOperatingSystemVersion, MajorSubsystemVersion and MinorSubsystemVersion, resolves issue #32492
git-svn-id: trunk@37381 -
2017-10-01 21:02:37 +00:00
svenbarth
9619576515 + add support for $SetPE{OS,SubSys,User}Version directives; Delphi compatible; Note: $SetPEUserVersion takes precedence to $Version
+ added test

git-svn-id: trunk@37364 -
2017-09-30 13:55:29 +00:00
svenbarth
e9c40f5b24 + correctly handle COMDAT sections in COFF files (at least as long as the COMDAT selection isn't IMAGE_COMDAT_SELECT_ASSOCIATIVE or IMAGE_COMDAT_SELECT_EXACT_MATCH), fixes the .refptr problems mentioned in Mantis #30614
git-svn-id: trunk@36197 -
2017-05-12 15:57:31 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
florian
0897bd154a + align(<int64>,<int64>) and align(<qword>,<qword>), resolves an issue reported on the mailing list with large records
+ tests
* trecordsymtable.insertunionst takes a asizeint parameter
* changed one aint into a asizeint

git-svn-id: trunk@35662 -
2017-03-26 09:35:56 +00:00
svenbarth
7af52f81a7 * initialize boheader to avoid a warning
git-svn-id: trunk@35392 -
2017-02-04 13:57:47 +00:00
svenbarth
669be1e4c2 * don't directly use sym.value as that is not necessarily initialized anymore
git-svn-id: trunk@35389 -
2017-02-04 13:49:44 +00:00
florian
23a02c9063 * fix arm compiler building
git-svn-id: trunk@35385 -
2017-02-04 13:20:45 +00:00
svenbarth
76445fd4b7 + add ability to generate Big Obj COFF files if required due to the section count being higher than $7fff
Note: such files can be linked GNU ld only starting from 2.25; then again the older versions would fail anyway as they'd complain about a too high section count...

git-svn-id: trunk@35380 -
2017-02-03 22:40:10 +00:00
svenbarth
95bea696ca + add ability to read Big Obj COFF files as generated by MSVC with /bigobj and GNU AS with -mbig-obj (starting from version 2.25); this format allows 2^31 sections per COFF file instead of 2^16, thus solving the problem of compiling packages\odata\src\sharepoint.pp
Note: the field names of tcoffbigobjheader and coffbigobjsymbol are inspired from the field names of the structs declared in LLVM

git-svn-id: trunk@35379 -
2017-02-03 22:36:58 +00:00
florian
78e945d471 - removed accidently added debug statement
git-svn-id: trunk@34907 -
2016-11-16 20:49:58 +00:00
florian
3f072b3e29 * workaround for issue #30348, FPC allowes now 65535 sections in coff object files, but as the section index is normally signed, this is only a dirty workaround
git-svn-id: trunk@34904 -
2016-11-15 22:06:00 +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
Jeppe Johansen
0251263234 Move some of the local reloc calculation out of aasmcpu, and into COFF and ELF writers.
git-svn-id: trunk@32867 -
2016-01-06 23:15:08 +00:00
yury
b26fa07f1a * Fixed notes "var is assigned but not used".
git-svn-id: trunk@31734 -
2015-09-17 13:03:04 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
Jonas Maebe
991e1f49bd * store a pointer to the used tasminfo record in every assembler writer, so
that we can use assembler writers with different conventions from the
    currently set target_asm (e.g. an x86 assembler writer for inline assembly
    in LLVM IR)

git-svn-id: trunk@31628 -
2015-09-12 23:32:13 +00:00
nickysn
d204aaab72 * refactored "ar" object writer creation in the internal assembler to allow
having different implementations of an internal "ar" writer

git-svn-id: trunk@30667 -
2015-04-19 16:35:16 +00:00
Jeppe Johansen
7f34ab27d2 Fixed issue with COFF linker. The addend wasn't shifted up by four before being added.
git-svn-id: trunk@30405 -
2015-04-02 22:06:14 +00:00
Jeppe Johansen
a3fd3ee3ab Fixed bug in ARM coff writer. Relocations just ORed the offset onto the instruction instead of adding, but they are emitted as bl 0xFFFFFE, and not bl 0x0.
git-svn-id: trunk@30403 -
2015-04-02 18:28:42 +00:00
Jeppe Johansen
9e5979e8be Implemented UAL syntax support in the ARM assembler reader. Can be toggled with a field for now, but not implemented yet. Still using pre-UAL syntax for now.
Switched codegeneration of VFPv2 and VFPv3 to use UAL mnemonics and syntax.
Updated VFP code in RTL to use UAL syntax too.
Added preliminary ELF support for ARM.
Added support for linking of WinCE COFF files. Should work for with a standard ARMv4-I target.

git-svn-id: branches/laksen/armiw@29247 -
2014-12-10 20:44:34 +00:00
sergei
8c61990078 * ogcoff.pas: when encountering symbol of unsupported type in input object file, give a meaningful error message instead of internal error. Mantis #27020.
- removed repeating check of section index.

git-svn-id: trunk@29062 -
2014-11-11 21:29:10 +00:00
nickysn
7cfd7a66cd + create a special 'heap' segment with reserved space equal to heapsize (i.e.
the value set by -Ch or the second parameter to the $M directive). This is
  equivalent to the heapmin value in Turbo Pascal 7 and ensures that the program
  has at least this amount of heap space available (otherwise DOS will show a
  'not enough memory' error and will refuse to load the program).

git-svn-id: trunk@28002 -
2014-06-19 14:14:01 +00:00
nickysn
3cc8ff11e3 + generate the stack segment for i8086 far data memory models from within fpc
itself (instead of having a fixed 16k stack in the startup code). This allows
  setting the stack size in these models with the -Cs option.

git-svn-id: trunk@27820 -
2014-05-27 23:29:50 +00:00
sergei
db621780d5 * x86_64-win64: fixed handling of RELOC_RELATIVE_1..RELOC_RELATIVE_5 COFF relocations, they were off by 4 bytes, causing failure in tests/test/tcalext.pp.
git-svn-id: trunk@27430 -
2014-04-01 16:26:56 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
sergei
1fea5a82c1 * Replaced oso_disabled flag by TExeSection.Disabled boolean property. Makes code a bit nicer to read.
git-svn-id: trunk@24361 -
2013-04-28 20:29:49 +00:00
sergei
9dc5b07a68 * COFF: fixed setting section flags. Content type and access bits must be set for non-loadable sections as well.
* Changed .reloc sections to be non-loadable, all Windows DLLs have it that way (and ld produces the same as well).

git-svn-id: trunk@24262 -
2013-04-17 19:51:38 +00:00
sergei
b86372ccec + Internal linker: process unreferenced .pdata sections on x86_64-win64, restores the possibility to use GAS on win64 (which got broken by introducing SEH).
git-svn-id: trunk@24235 -
2013-04-13 18:52:50 +00:00
sergei
999c3a0a02 * COFF linker: postpone import section generation until unreferenced sections (and imports) are removed, and put all remaining imports into a single section. This is much more efficient than generating multiple smart-linkable import sections and immediately discarding a good half of them.
git-svn-id: trunk@24123 -
2013-04-02 05:46:32 +00:00
sergei
d762ef9e78 + PECOFF targets: support more than 65535 relocations per object section, resolves #23752. DJCOFF targets: give a fatal error, since this object file format does not support extended relocations.
git-svn-id: trunk@23521 -
2013-01-26 16:15:59 +00:00
florian
db68214e88 + support setpeoptflags directive, resolves #23447
git-svn-id: trunk@23132 -
2012-12-10 19:17:25 +00:00
sergei
36859068f5 * Propagate AS_NEEDED flag further into Load_DynamicObject and handle it properly: shared objects marked with AS_NEEDED are added to dependencies only if they actually resolve some symbol.
* Dropped TObjInput.newObjData method. Instead, TObjData instances are created directly in ReadObjData, this gives possibility to create a different type of TObjData based on file header.
- Dropped TObjInput destructor, it does nothing except calling inherited.

git-svn-id: trunk@23118 -
2012-12-06 18:19:19 +00:00
sergei
0369a30f49 * Internal linker: made sec_rodata_norel read-only.
* For Win32 and Win64 targets made sec_rodata read-only, too (for these targets it doesn't matter if read-only section contains relocations).

git-svn-id: trunk@23025 -
2012-11-18 17:40:17 +00:00
pierre
b851a5a065 Accept range/overflow for address computation inside unit
git-svn-id: trunk@22507 -
2012-10-01 14:20:54 +00:00
sergei
fde944bf5d + Declare AT_TLS and AT_GNU_IFUNC symbol types, these are needed to handle object files created by gcc in ELF internal linker.
* TExeOutput.FixupSymbols:
  + Collect AT_GNU_IFUNC symbols in IndirectObjSymbols list for further processing by ELF back-end.
  * Do not overwrite bind and size while fixing AB_COMMON symbols, this removes need in storing symbol size in every relocation and dedicated handling of oso_common section.
  * Remove symbols with objsection<>nil from lists, so calling FixupSymbols several times skips already processed symbols.

git-svn-id: trunk@22393 -
2012-09-14 17:22:48 +00:00
sergei
c41b407119 * Changed TObjSection.WriteStr method to write a zero byte after the string.
+ Added TObjSection.WriteBytes method that writes just a string (without zero byte).
* ogelf.pas: Fixed st_value of COMMON symbols, it must contain required symbol alignment.
+ ogelf.pas: Some more definitions.

git-svn-id: trunk@22332 -
2012-09-06 06:06:04 +00:00
sergei
ec56677927 + Added method TObjSection.writeReloc_internal to write relocations to given section+offset without need to have a symbol at target location.
* Optimized COFF importing code using the new method.
  - Don't create .text sections for imported variables.
  - Don't create .idata$6 sections for imports by ordinal.

git-svn-id: trunk@22086 -
2012-08-15 12:22:07 +00:00
sergei
45d27ef82e * Relocating common symbols needs adjusting by symbol size only on DJCOFF targets, not on PECOFF ones.
git-svn-id: trunk@22068 -
2012-08-13 09:31:49 +00:00
sergei
95535ea845 - Do not create any default object sections. On targets with section-based smartlink these sections remain empty and only cause linker to do useless job of removing them. The same happens when loading object files because duplicate section names are allowed at that time. On targets without smartlink they don't stay empty, but the internal assembler creates sections when required, so not creating initial sections effectively doesn't change anything.
git-svn-id: trunk@22049 -
2012-08-09 17:12:39 +00:00
sergei
1d09005542 + Implemented two-stage removal of empty exe sections. Candidates for removal are first marked with oso_disabled flag, then actually removed. Descendants of TExeOutput that override MemPos_Start may modify list of sections pending removal. In particular, the COFF-specific .reloc section no longer has to be handled in base TExeOutput class.
git-svn-id: trunk@21971 -
2012-07-26 10:04:12 +00:00
sergei
06844fdb23 * Entirely moved relocation fixup functionality from TObjSection to TExeOutput.
git-svn-id: trunk@21944 -
2012-07-22 07:21:11 +00:00
sergei
3b3da49ad6 * Merged TElfObjSection.secshidx and TCoffObjSection.secidx into TObjSection.index.
git-svn-id: trunk@21848 -
2012-07-10 13:34:55 +00:00
sergei
712f5d1c26 - Removed oso_readonly and oso_noload section options, it is enough to have just oso_write and oso_load to express possible section states.
git-svn-id: trunk@21825 -
2012-07-09 12:58:37 +00:00
sergei
c65abdeeae * Implemented link map generation without involving TObjSection.ObjSymbolDefines, and removed the latter because it isn't used otherwise. The new approach uses CPU/memory only when map generation is requested.
git-svn-id: trunk@21737 -
2012-06-30 07:51:45 +00:00
sergei
0c32756ef3 - removed TCoffObjData.afteralloc, calculating MemPos there is useless because every call to afteralloc is immediately followed by call to TObjData.resetsections that resets all MemPos back to zero.
- PE_FILE_RELOCS_STRIPPED flag is meaningless for object files.
- Don't write PE_FILE_BYTES_REVERSED_LO as well, it is deprecated and GNU tools don't write it either.
- Don't set PE_FILE_32_BIT_MACHINE flag in x86_64 object files.

git-svn-id: trunk@21710 -
2012-06-25 23:26:07 +00:00
sergei
8c8883cc35 * Once TExeOutput is accessible in TObjSection.fixuprelocs, its ImageBase can be used directly, without a need to have a copy in every TObjSection.
* Also simplified COFF symbol loading, separate array of symbol sizes is not needed because these sizes never change during the load.

git-svn-id: trunk@21704 -
2012-06-25 18:39:46 +00:00
sergei
5be97c7c9e - Removed TDJCoffObjSection,TPECoffObjSection,TCoffExeSection,TPECoffExeSection,TDJCoffExeSection. These only add complication and no value.
git-svn-id: trunk@21684 -
2012-06-23 14:59:45 +00:00