Commit Graph

240 Commits

Author SHA1 Message Date
Jonas Maebe
d150869dea * record symbols that need to remain in their original order, and on Darwin
pass them to the linker so it does not reorder them
   o fixes resource strings on Darwin when using LTO (this used to reorder the
     resource string symbols, so they no longer all appeared between the START
     and END symbols for their compilation module)

git-svn-id: trunk@41907 -
2019-04-20 18:18:10 +00:00
Jonas Maebe
0b61b5d4cf * added extra header to ppu inside a subsection, so we won't run into
trouble when the ppu version hits 255
  * also moved several ppu flags to a set inside that section

git-svn-id: trunk@41846 -
2019-04-06 21:28:43 +00:00
Károly Balogh
7e630686e0 * do not use a wildcard while deleting smartlinked objects after linking stage in a script, conflicts with script filename quoting on Unix at least
git-svn-id: trunk@37918 -
2018-01-06 10:19:21 +00:00
Károly Balogh
4b113579a5 some tabs to spaces indentation cleanup. no functional change
git-svn-id: trunk@37599 -
2017-11-17 11:31:49 +00:00
Károly Balogh
e6aed467b5 renamed script unit to cscript to avoid namespace conflict with univint package on Darwin. this makes it possible to build the textmode IDE on Darwin
git-svn-id: trunk@37598 -
2017-11-17 11:27:19 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
Jonas Maebe
7a8079cfb4 * removed DLLsource global variable and replaced its uses with
current_module.islibrary

git-svn-id: trunk@32676 -
2015-12-17 15:23:05 +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
nickysn
d4a4b9a57b * refactored the internal linker ar object reader object creation to allow using
different 'ar' implementations under different platforms
* use the omflib reader instead of the ar reader in the msdos internal linker

git-svn-id: trunk@31322 -
2015-08-14 13:52:45 +00:00
nickysn
8206c6dbd0 * the code for determining the code, data and bss sizes in the internal linker
moved to virtual methods, to allow for platform specific overrides (e.g. for
  supporting section names, other than '.text', '.data' and '.bss', etc.)

git-svn-id: trunk@31321 -
2015-08-13 15:07:24 +00:00
nickysn
85cb180d80 * prepend "+" to each file name to be added to the library by wlib. This
indicates an "add" command, instead of "replace".

git-svn-id: trunk@30287 -
2015-03-23 01:19:19 +00:00
nickysn
931f5a0b54 * fixed passing of the wlib output file parameter (-o requires an equal sign)
git-svn-id: trunk@30286 -
2015-03-23 01:10:32 +00:00
nickysn
069fa51445 * use separate input and output files when invoking wlib to create a static
library. This resolves a problem with parallel building of a i8086 cross
  compiler, due to a race condition in wlib, when running several instances of
  wlib in the same directory. The problem is in the way wlib creates a temp file
  in the current directory using non-atomic operations and with a high
  probability of a name collision. Using separate input and output files avoids
  this temp file creation by wlib.

git-svn-id: trunk@30277 -
2015-03-22 17:42:19 +00:00
Károly Balogh
c421f4d91e do not include outputexedir in linker resname. it causes the path to be double-included when cross-compiling with -st and -FE on Liunuxes. also, be consistent between linking on host and target.
git-svn-id: trunk@29753 -
2015-02-18 14:09:15 +00:00
nickysn
eddab86312 * pass the -b option to wlib to avoid creating .bak files
git-svn-id: trunk@27270 -
2014-03-24 17:35:11 +00:00
pierre
754790f641 Use new static library not supproted message
git-svn-id: trunk@26598 -
2014-01-27 22:29:07 +00:00
pierre
bef22b2a6f Add scripted version of wlib call for msdos
git-svn-id: trunk@26442 -
2014-01-12 22:47:27 +00:00
sergei
38058505ba * Changed linking infrastructure to look like assembler one:
* Changed direct references to linker classes in TSystemInfo records to enumerated ids.
  * RegisterExtennalLinker and RegisterInternalLinker procedures replaced by single RegisterLinker procedure and moved to link.pas.
  - TAbstractLinker is no longer necessary, removed.

This change allows to register linker once per id, rather than once per target, and also allows TSystemInfo records to be read-only.

git-svn-id: trunk@25279 -
2013-08-18 12:01:21 +00:00
sergei
eec8129738 * TInternalLinker.Load_ReadStaticLibrary: exit if error has occurred while opening a static library or dynamic object, continuing can cause other errors/crashes in this case.
* t_linux.pas: use sysrootpath when specifying dynamic interpreter (for cross-linking).

git-svn-id: trunk@25277 -
2013-08-18 09:14:16 +00:00
Károly Balogh
a11c113429 reverted the link object search change
git-svn-id: trunk@24727 -
2013-06-01 15:35:59 +00:00
Károly Balogh
e7094cf1d6 fix redundant searches in FindObjectFile, if the object was found on the first try
git-svn-id: trunk@24725 -
2013-06-01 15:21:57 +00:00
nickysn
a1ee8ab9bc * suppress annoying wlib header
git-svn-id: branches/i8086@23967 -
2013-03-23 00:08:52 +00:00
nickysn
ac64663e70 + openwatcom wlib support added
git-svn-id: branches/i8086@23964 -
2013-03-22 23:44:33 +00:00
sergei
a1503b51f2 + chmod 755 on executable files produced by internal linker. I missed this "small" detail for half a year because all development was going on a NTFS drive where everything is executable.
git-svn-id: trunk@23374 -
2013-01-13 17:18:11 +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
7d19a6d551 * Propagate AS_NEEDED flag down the expression tree an assign it to TStaticLibrary objects.
git-svn-id: trunk@23116 -
2012-12-05 16:05:16 +00:00
sergei
49501413e1 + Support library grouping in internal linker script, use it to load C libraries.
git-svn-id: trunk@22962 -
2012-11-09 14:38:11 +00:00
sergei
6d70009f06 + ELF linker. Works on x86_64-linux and i386-linux good enough to pass the testsuite, but still requires a lot of work in nearly all aspects. In particular, no attempt to resolve symbols from shared libs is done, everything is just treated as imports. Symbol versioning isn't supported either.
x86_64 is the most elaborated, has some degree of indirect function (GNU_IFUNC) and TLS support, so it is even able to link with static libc/pthreads code (tw14265) and produce an executable that can launch (but still fails due to invalid DWARF unwind info).

i386 produces working shared libraries if they are compiled with -Cg, without one your mileage may vary. tw14265 does not link yet due to missing COMDAT group support.

git-svn-id: trunk@22775 -
2012-10-19 17:21:08 +00:00
sergei
d79511f96e + Basic ld script parsing capabilities (barely enough to parse glibc2.1 'libc.so' files, lacks any error handling).
+ Support linker input source grouping functionality.
* Promote TStaticLibrary to something like generic linker input statement, it can now hold regular ObjData or a group of other TStaticLibrary objects in addition to tarobjectreader.

git-svn-id: trunk@22155 -
2012-08-21 08:37: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
31d004e056 + Basic executable stack support in TExeOutput.
+ Two stubs (TExeOutput.Load_DynamicObject and TObjInput.CanReadObjData) to override in ELF linker.
+ Stop linking if errors were detected while loading object files.
* Changed TStaticLibrary to TObject. It is never looked up by name, so hashing is redundant; moreover its name has been changed to TCmdStr, which may be trimmed by TFPHashList. 

git-svn-id: trunk@21968 -
2012-07-25 11:08:54 +00:00
sergei
1a25aed68d * Renamed a method for consistency (let script building methods start with ScriptAdd).
git-svn-id: trunk@21814 -
2012-07-07 22:49:05 +00:00
sergei
346fbef445 * Factored a common linker script building block into separate method.
git-svn-id: trunk@21730 -
2012-06-28 17:18:02 +00:00
sergei
80bbd388f9 * Made removal of unused ExeSymbols a separate procedure, call it earlier and regardless of presence of the 'SYMBOLS' directive in the linker script.
git-svn-id: trunk@21727 -
2012-06-27 20:26:49 +00:00
sergei
a2f0e54dc6 * Fixed internal linker entering infinite loop if script contains empty lines or comments.
git-svn-id: trunk@21650 -
2012-06-18 17:03:35 +00:00
sergei
6571b4d140 * Factored code to create internal link script for debug sections into a separate procedure.
git-svn-id: trunk@21410 -
2012-05-28 13:28:21 +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
02413c8a57 * moved maybequoted() from cutils to cfileutl and let its behaviour vary
based on the actual target platform rather than always on the host
    platform
  * on Unix, use single rather than double quotes for quoting, so it also
    properly handles $, ! and `, which keep their special meaning when
    appearing in scripts inside double quotes
  * since sysutils.executeprocess() can only deal with double-quoted
    strings in parameters, re-quote parameters on Unix when they turn
    out not to be for scripts but for direct execution (which is most
    of the time, but unfortunately doing the reverse is not possible
    because parameters used in scripts sometimes contain script-specific
    code that must not be quoted, such as `cat link.res`)
   -> always use cfileutl.RequotedExecuteProcess() rather than
    sysutils.ExecuteProcess() in the compiler (added a bunch of dummy
    ExecuteProcess string constants to common units to prevent accidental
    usage)

git-svn-id: branches/jvmbackend@20901 -
2012-04-16 19:52:36 +00:00
Jonas Maebe
ddde9760c2 * ignore tf_no_backquote_support in source_info.flags in case we will link
on the target system (-St command line option during cross-compiling)

git-svn-id: trunk@20817 -
2012-04-11 18:04:36 +00:00
pierre
5d6a7dc03d + TExternalLinker.CatFileContent method and tf_no_backquote_support tsystemflags enum value
git-svn-id: trunk@19648 -
2011-11-18 21:32:25 +00:00
paul
7a74d2c2f8 compiler: reduce amount of hints and notes
git-svn-id: trunk@19293 -
2011-09-30 08:56:05 +00:00
pierre
bcb2bb9e5b Add removal of braces for parameters in linker script
git-svn-id: trunk@17902 -
2011-07-01 14:28:18 +00:00
pierre
f328836cad + Add checks for internal linker script
git-svn-id: trunk@17882 -
2011-06-30 13:16:04 +00:00
pierre
239944f8d0 + Use DLL name in assembler labels used to import DLL functions/variables
in Windows, Emx and OS2 targets.
    This fixes test failures: test/library/tlib1b.pp and lib2b.pp

    link unit TLinker.AddImportSymbol: Added symmangledname parameter.
    ogbase unit TImportSymbol.Create: Add AMangledName parameter.
    fmodule unit TModule.AddExternalImport: Add symmangledname parameter.
    fppu unit: Also put mangled name string for imported symbol.
    ppu unit: Increase PPUVersion
    utils/ppudump.pp: Adapt to PPU change above.
    systems/T_OS units: Use ImportSymbol.MangledName property to create
    import libraries or .idata sections.

git-svn-id: trunk@17804 -
2011-06-23 11:38:57 +00:00
pierre
1a9f4ba314 * Improve ogbase linker script support, add warnings for unknown entries
git-svn-id: trunk@17784 -
2011-06-21 16:49:50 +00:00
florian
81bd7867b3 * it makes no sense to search the windows dirs for dlls when cross compiling
git-svn-id: trunk@17687 -
2011-06-07 19:24:53 +00:00
florian
0c62133d38 * patch by Mattias Gaertner to allow to override how the compiler reads source/ppu files, resolves #18740
git-svn-id: trunk@17255 -
2011-04-05 20:10:09 +00:00
armin
7eace122dc internal linker support for creating novell netware loadable modules
git-svn-id: trunk@17192 -
2011-03-27 14:47:25 +00:00
florian
26fbfaf5a7 + introduce the usage of asizeint/asizeuint for cpus with sizeof("alu")<>sizeof(pointer)
git-svn-id: trunk@17011 -
2011-02-26 20:10:03 +00:00
Jonas Maebe
1f6ec379de * moved field definitions before method/property definitions (see mantis
#13971)

git-svn-id: trunk@13330 -
2009-06-27 11:27:31 +00:00