Commit Graph

217 Commits

Author SHA1 Message Date
sergei
9cc0bdd6b9 + Missing part of internal ARM assembler, Mantis #26588. I'm not setting it as default for arm-wince yet, because testing reveals several points in generic code that need adjustments.
git-svn-id: trunk@29588 -
2015-01-30 22:45:05 +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
sergei
7cda919547 * Pass ExeOutput as argument to TObjSection.fixuprelocs, needed for ELF targets to relocate the complex GOT stuff.
* TExeSection.AddObjSection made virtual.
- TExeSymbol.ExeSection is nowhere used, removed.

git-svn-id: trunk@21626 -
2012-06-16 22:33:26 +00:00
sergei
4e95b50344 * Improved performance of COFF object reader: handle string table as array of chars instead of stream, use Pos instead of Copy to determine if name starts with the given chars.
git-svn-id: trunk@21577 -
2012-06-10 17:50:49 +00:00
sergei
7d3294b504 * Moved 4 procedures for basic reading/writing TObjSection contents into ogcoff.pas, so they don't have to be reimplemented for every output format.
git-svn-id: trunk@21492 -
2012-06-05 19:52:40 +00:00
sergei
1c271251f8 - Removed tcoffexeoutput.FCoffSyms, it is never used (symbols are written directly to the output)
* Improved TCoffObjOutput.ReadObjData to use one Seek less, also improved error messages.

git-svn-id: trunk@21440 -
2012-05-31 09:01:11 +00:00
sergei
3a89544cd6 + Internal linker for go32v2:
* Enable smart linking on go32v2
  * Adapted external linker script for long section names (ld 2.17 from fpcbuild repository does not seem to actually remove unused sections though)
  * Do not pass '-lc' twice to external linker
  * Pass -Map with correct filename to external linker if -Xm is specified on command line
  * Debug sections for DJCOFF must have zero memory position and flag COFF_STYP_INFO (not COFF_STYP_NOLOAD).

git-svn-id: trunk@21435 -
2012-05-30 13:45:36 +00:00
sergei
8814f56081 * Fixed oso_debug section attribute being not preserved while reading/writing DJCOFF object files.
* Fixed header data positions for DJCOFF executables, they need adjustment by stub size.
* Fixed symbol values in DJCOFF executables, they must be absolute.
* Fixed missing oso_common flag on TExeOutput.commonObjSection, causing incorrect COFF relocations to this section.

git-svn-id: trunk@21408 -
2012-05-28 11:46:52 +00:00
sergei
35e3e363dd * Changed writing section symbols to use storage class COFF_SYM_LOCAL (3), this is what is used by both GCC and MSVC. Previously used COFF_SYM_SECTION (104) is accepted by GNU binutils, but only for PE targets (and silently converted to COFF_SYM_LOCAL), for DJGPP it issues warnings.
* Assign section indexes independent from symbol indexing.
* Fixed section flags not assigned while reading DJGPP object files.
* Fixed objData type for TDJCoffexeoutput.
* Fixed entry point address of DJGPP executables.
* Fixed filling exe section headers for DJGPP.

git-svn-id: trunk@21396 -
2012-05-26 14:22:13 +00:00
sergei
bbb08bbf66 ogcoff.pas:
- removed empty destructor and checks for nil before .Free (they are done in tobject.free itself)
+ added COMDAT definitions.

git-svn-id: trunk@21383 -
2012-05-24 16:34:13 +00:00
sergei
dc03282cb7 + Support assembling expressions ".long L2-L1" where label L1 belongs to the current objsection and L2 comes from any objsection. This is done using relative relocations and is compatible with GNU AS.
* Also fixed ogcoff.pas to handle these relative relocations correctly.

git-svn-id: trunk@21362 -
2012-05-22 14:59:24 +00:00
Jonas Maebe
14cfe770a4 * replaced most (if not all) remaining fields/parameters in the compiler
that deal with paths/filenames with TPathStr (= ansistring) to prevent
    cutting off long paths (no change in speed when compiling the compiler,
    1% extra memory usage)

git-svn-id: trunk@21120 -
2012-04-29 17:36:23 +00:00
Jonas Maebe
ac43eb9b70 + generic implementation of ReplaceForbiddenAsmSymbolChars() instead
of the AVR-specific ifdef'ed variant
   o since the only special character we use in mangled names on all platforms
     is $, added a new field to tasminfo called "dollarsign" that holds the
     character $'s should be replaced with (if it doesn't have to be replaced,
     leave it at $)

git-svn-id: trunk@20801 -
2012-04-11 18:01:57 +00:00
sergei
0b16c3565a * Don't reject IMAGE_REL_ARM_SECREL relocations, Mantis #20467
git-svn-id: trunk@19472 -
2011-10-12 06:01:14 +00:00
florian
111d05c68f o patch by Alexander Shishkin, resolves #20409
* eliminate warnings in compiler (i386 & i368->x86_64) and minor refactorings
    - comment out unused vars and types
    - comment out unneeded comparisons (Longword <=> 0)
    - suppress some "comparison always true|false" warnings
    - tweak visiblity sections

git-svn-id: trunk@19385 -
2011-10-05 20:11:09 +00:00
sergei
6280ee2eed * Changed attributes of .pdata section so it is smart-linkable on x86_64.
* Changed alignment of .pdata section to 4.
+ Support saving RELOC_NONE relocations to .o files and reading them back on x86_64.

git-svn-id: trunk@19070 -
2011-09-15 15:22:03 +00:00
sergei
392dafd175 * Another attempt to align section raw data size in COFF headers. Without this, image modification WinAPIs like BeginUpdateResource/EndUpdateResource typically corrupt the image. Resolves #16852 (at least partially).
git-svn-id: trunk@18172 -
2011-08-11 16:42:24 +00:00
sergei
c9f92c0323 * Excluded oso_executable from attributes of user sections. User sections may currently be specified only for variables and typed consts, which are not executable.
* Fixed TLS directory size written to PE header when cross-compiling. It must be the value for target, not for host.

git-svn-id: trunk@18024 -
2011-07-27 14:10:22 +00:00
sergei
6a2e87121b * ogcoff.pas: sort all objsections having '$' in the name, not just .idata$*. This is a documented PECOFF feature and it is required for tls callback stuff to link correctly regardless of the order of declarations in source files.
git-svn-id: trunk@17968 -
2011-07-10 12:24:35 +00:00
sergei
5d5ddbbe3e * Revert rounding section data size, it should be done in a more sophisticated way
git-svn-id: trunk@17950 -
2011-07-07 11:34:57 +00:00
sergei
2d96c34b06 * Improvements to PE executable output:
* Clear bits in section flags, that are only valid for object files
  * Round section datasize up to filealignment (PECOFF v8 documentation requires this)
  * Zero datapos and datasize for all sections w/o data, not just for .bss
  * Produce IMPORT_ADDRESS_TABLE directory in exe header
  * Entirely smartlink away unused DLLs (these used to have two terminating thunks left)

git-svn-id: trunk@17949 -
2011-07-06 20:55:57 +00:00
pierre
372b16b2e6 * Look for __FPC_tls_callbacks, should be reset to nil for DLLs, not yet done
git-svn-id: trunk@17908 -
2011-07-01 19:28:32 +00:00
pierre
30feeff3c2 + TlsDirectory handling code
git-svn-id: trunk@17903 -
2011-07-01 14:30:32 +00:00
florian
f328b6d635 + user section type
+ parsing of section directive for variables
  + section test
  + write section names in the assembler/binary writers correctly
  * allow section only after ; and for embedded targets

git-svn-id: branches/usersections@17154 -
2011-03-20 15:42:28 +00:00