Commit Graph

188 Commits

Author SHA1 Message Date
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
pierre
fd2b777435 * ogcoff.pas:
{ Direct 32 bit sign extended,
        win64 mingw GNU compiler
        also generates this type
        inside coff objects
        We assume they are equivalent to
        IMAGE_REL_AMD64_ADDR32  PM 2010-11-27 }

git-svn-id: trunk@16454 -
2010-11-26 23:46:49 +00:00
pierre
fa4b4906e6 * ogcoff.pas: Add support for RELOC_SECREL32.
* cfidwarf.pas: Fix CIE pointer inside dwarf-FDE entry which must be
    a section relative offset.

git-svn-id: trunk@16062 -
2010-09-29 12:58:21 +00:00
pierre
7c04d8d13b From patch submitted by Willibald Krenn in Bug Report 17500.
* assemble.pas (TInternalAssembler.WriteStab): Use RELOC_ABSOLUTE32 for
   32-bit stab entry.
 * ogcoff.pas: Add check for correct generated reloc section size.
 * systems/t_win.pas: Use 0x400000 image base for x86_64 programs using
   stabs debug information format.

git-svn-id: trunk@16056 -
2010-09-28 10:06:54 +00:00
florian
c1f3d8dcaa * unified names of system_*/systems_* sets
git-svn-id: trunk@14566 -
2010-01-07 18:16:20 +00:00
florian
34227e811d + patch by Sven Barth to add native NT rtl support to the compiler, resolves #14886
git-svn-id: trunk@14565 -
2010-01-07 17:42:11 +00:00
Jonas Maebe
edacea82be * changed assembler directives for darwin lazy/non-lazy symbol pointers
and init/fini routines into their section equivalents (based on patch
    by Dmitry Boyarintsev, mantis #15037)

git-svn-id: trunk@14128 -
2009-11-09 22:20:01 +00:00
Jonas Maebe
0c675a4039 * the objc1 unit has been renamed to objc
* the objc unit links against the Foundation instead of against the Cocoa
    framework, and inludes an interface to either the fragile or non-fragile
    obj-c run time depending on the target platform
  + support for the non-fragile Objective-C runtime/ABI, as used on Mac OS X
    for ARM (iPhone) 64 bit (PowerPC/64, x86_64) -- all these targets now
    are now also supported for the objectivec1 modeswitch
  + support for private_extern symbol bindings, required for the above
  * mark objcclasses that are declared in the implementation section of a
    unit as "hidden" (not sure what the effect is, since the Objective-C
    runtime does not seem to do anything with this flag)
  * enabled all obj-c tests for the newly supported platforms

git-svn-id: branches/objc@13763 -
2009-09-27 15:24:50 +00:00
yury
bf00b3e94b * Replaced some ifdef x86_64 by ifdef cpu64bitaddr, since it is more correct.
git-svn-id: trunk@13159 -
2009-05-17 12:43:58 +00:00
yury
ede93974bc * Fixed writing of external debug info when reloc section should be created.
git-svn-id: trunk@13146 -
2009-05-15 22:30:52 +00:00
yury
c4439e4e39 * Properly write 64-bit relocations into .reloc section.
* Warning when 64-bit object file contains 32-bit absolute relocations. In such case an executable image can be loaded into lower 4Gb of address space only.

git-svn-id: trunk@13110 -
2009-05-07 10:46:56 +00:00
yury
5cd83b26d9 * More proper check for executable image size limits.
* Proper handling of 64-bit COFF relocations.
* Use jumps with 32-bit relative addressing in imports on win64.
* This fixes are related to bug #13657. The bug is not fully fixed yet...

git-svn-id: trunk@13104 -
2009-05-06 18:07:07 +00:00
yury
99917e034d * Fixed visibility notes of some overrode methods.
git-svn-id: trunk@13095 -
2009-05-04 10:24:47 +00:00
yury
9d78ca3f19 * RELOC_SECREL32 must be relative to EXE section, not to object file section.
* Write zero to relocs in debug sections, which point to unused sections, eliminated by linker.
* It seems internal linker creates correct dwarf debug info now.

git-svn-id: trunk@13093 -
2009-05-04 09:42:51 +00:00
yury
50060dfd52 * Do not assume sizeof(pint) section alignment if no alignment is specified for the section.
git-svn-id: trunk@13092 -
2009-05-04 08:27:36 +00:00
yury
070fa422b5 * Partially reverted r12648. PE flags should be set in main PE header (and it is done already). LoaderFlags in optional header are obsolete.
git-svn-id: trunk@13088 -
2009-05-03 14:43:46 +00:00
florian
442333d05f * fixed string length which makes ObjC section names fit
git-svn-id: trunk@12889 -
2009-03-14 20:26:31 +00:00
Jonas Maebe
6165536b5e + added {$modeswitch objectivec1}/-Mobjectivec1 mode switch to enable
the use of Objective-C 1.0 constructs. Because it is a mode switch, it
    can be used cumulatively with every syntax mode. Note that a {$mode xxx}
    statement resets all mode switches as well, so you cannot use the
    -Mobjectivec1 variant if you have such a statement in a unit. This
    modeswitch is currently only enabled for Darwin/PowerPC and Darwin/i386,
    as the backend support is not yet implemented for other platforms.
  + implemented selector() statement that can be used to create an Objective-C
    selector for the message with the specified *constant* name (in the future,
    it will also work for Objective-C method identifiers)
  + added SEL type to the system unit (the selector() statement returns it)
  + added all Objective-C segments to the assembler writers
  + (currently mostly dummy) objc1 unit that is automatically included if the
    {$modeswitch objectivec1} statement is used
  + some tests for the selector() statement

git-svn-id: trunk@12870 -
2009-03-08 18:40:32 +00:00
yury
89d466a3dc * Fixed writing debug link for external symbols file. Bug #13041.
git-svn-id: trunk@12686 -
2009-02-05 11:44:52 +00:00
florian
a3d784b8e5 * internal coff linker takes care of min./max. stack size as well as pe flags
git-svn-id: trunk@12648 -
2009-02-01 18:22:18 +00:00
Jonas Maebe
b1c3f76ff9 * changed the supported targets for assembler writers to a set, and
(hopefully correctly) limited all assembler writers to only the
    OSes they support (mantis #11801)

git-svn-id: trunk@12622 -
2009-01-28 15:12:43 +00:00
yury
9cc15bd994 * Do not write COFF string table into EXE if COFF symbol table is not present. It fixes loading of stripped DLL on Win9x. Bug #12629.
git-svn-id: trunk@12352 -
2008-12-12 14:54:14 +00:00
yury
4cabbe0e39 * Fixed compiler cycling with enabled range and overflow checking.
git-svn-id: trunk@11489 -
2008-07-29 21:11:03 +00:00
yury
eb9c9c77d8 * More correct fix for overflow check for RELOC_RELATIVE_24.
* Fixed 2007062701 while linking DLL.

git-svn-id: trunk@11484 -
2008-07-29 08:44:05 +00:00
yury
c92c034882 * Fixed overflow check for RELOC_RELATIVE_24.
git-svn-id: trunk@11483 -
2008-07-28 22:30:46 +00:00
yury
4cb3fef484 * Fixed executable size limit for wince.
git-svn-id: trunk@11482 -
2008-07-28 22:06:15 +00:00
yury
c84aa860bd * Added error message if resulting executable image size is too big to fit in memory. bug #11702.
git-svn-id: trunk@11481 -
2008-07-28 21:54:18 +00:00
yury
5e11e697b4 * Use unsigned integers for sizes and positions to break 2GB limit in tdynamicarray, object writer, internal linker, coff and PE headers.
git-svn-id: trunk@11480 -
2008-07-28 20:29:25 +00:00
yury
0bcaf8845f * Fixed 'mixed signed/unsigned' warnings.
* Suppressed 2 unreachable code warnings.
* Now x86 compiler compiles without warnings and notes! It will be great to keep such state in future...

git-svn-id: trunk@11455 -
2008-07-23 13:16:46 +00:00
yury
491f0fa1d8 * Replaced all user defined warnings by TODO comments to reduce compiler noise.
git-svn-id: trunk@11443 -
2008-07-23 11:00:03 +00:00