The /include command line option is equivalent to Unix --undefined
option, which forces the linker to resolve the given symbol name
as if it's an unresolved symbol in one of its input files. This feature
is used to link an additional object file or a shared library that no
input files refer to.
llvm-svn: 187084
This is a follow up patch for r186336.
Reviewers: LegalizeAdulthood
CC: silvas, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1144
llvm-svn: 186384
Emit .reloc section. This is the first step to support DLL creation. The
executable doesn't need .reloc section, but the DLL does.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1126
llvm-svn: 186336
This patch adds a new pass, IdataPass, to transform shared atom references
to real references and to construct the .idata section data. With this patch
lld can produce a working Hello World program by linking it against
kernel32.dll and user32.dll.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1096
llvm-svn: 186071
Contents of ".reloc" section depends on the addresses of other sections, so
the section cannot be created until all the other sections are created and get
their memory addresses (RVAs). That means that computation of section size
needs to be at least two pass.
Techynically there's no reason to compute it all at once, but instead we can
compute the address of a section as added to the output file. Doing so helps
us to create ".reloc" section.
llvm-svn: 185902
This is a follow-up patch for r185524. Being assert enabled does not mean
that DEBUG() is enabled, so we need to check the existence of DEBUG() itself.
llvm-svn: 185619
The optional data directory header contains addresses to some atoms such
as the import address table in data section. Such fields can naturally
be set by relocation if we make the optional data driectory as an atom.
Currently we assume that atoms are always in a section, so we can't create
a file header with atoms. This patch separates section chunk from atom
chunk, to allow atom-based file header.
llvm-svn: 185521
A hint is an index of the export pointer table in a DLL, at which
PE/COFF loader starts looking for a symbol name. The import library
comes with hints and symbol pairs, and as long as hints are in sync
with the actual symbol table in DLL, the symbols will be resolved
quickly. So, we shouldn't ignore hints but propagate them to an output.
llvm-svn: 185516
In order to support linking against DLL, the linker needs to create defined
atoms for jump tables and etc. Because such atoms are not read from a file,
they lack some information such as an ordinal. With this patch, COFFDefinedAtom
is split into two classes; one is the base class of all COFF defined atoms, and
another is a concrete class for atoms read from file. More classes inheriting
COFFBaseDefinedAtom will be added for jump tables and etc.
llvm-svn: 185195
This renames variable name to reflect initial undefined symbols that are
defined by the linker -u option.
This doesnot change any functionality in lld, and updates code to reflect
Nick's comment.
llvm-svn: 184682
This change moves the functionality of undefinedSymbols that were created in
ELFTargetInfo into TargetInfo. Looks like MachO/Windows use similiar options
like in ELF for creating undefined symbols when the linker is invoked.
Address comment from Ruiu.
(No change in functionality, except moving the functionality from ELF to
TargetInfo, so that multiple architectures can use the same)
llvm-svn: 184398
Extract atom definitions as Atoms.h so that we can use them in other files.
Also applied clang-format to Atoms.h.
Reviewers: shankarke
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D995
llvm-svn: 184124
This is the first patch toward full DLL support. With this patch, lld can
read .lib file for a DLL.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D987
llvm-svn: 184101
This change adds functionality to add more sections like .gcc_except_table,
.data.rel.local, .data.rel.ro into the default section map, so that they are
all merged into appropriate output sections.
This also makes c++ static binaries comparable to what you get with the default
linker.
Adds a test for testing the functionality.
llvm-svn: 184071
With this patch, it can now resolve relocations in the same output file.
"Hello world" program does not still work because call to the DLL routine
is not supported yet.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D985
llvm-svn: 184063
Archive file in Windows has file extension of ".lib" but the file format is
in fact the same as Unix. It's an ar archive holding multiple .obj files.
The existing archive reader can read .lib files.
llvm-svn: 184036
Summary:
COFFReference class is defined to represent relocation information for
COFFDefinedAtom, as ELFReference for ELFDefinedAtom. ReaderCOFF can now
read relocation entries and create COFFReferences accordingly.
I need to make WriterPECOFF to handle the relocation references created by
the reader, but this patch is already big, so I think it's probably better
to get it reviewed now.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D976
llvm-svn: 183964
Architecture specific code should reside in architecture specific directory
not in Atom. Looks like there are no efforts being made at this moment to
support ARM, so let's remove it for now.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D959
llvm-svn: 183877
The yaml reader is not specific to any file format. This patch moves
it to TargetInfo and makes validate a non virtual interface so that it
can be constructed from a single location.
The same method will be used to create a reader for llvm bitcode
files.
llvm-svn: 183740
Split FileCOFF's constructor into mainly two private methods.
One method is responsible to iterate over symbol tables, and other
method is to atomize defined atoms. This is for readability and
no changes in functionality.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D940
llvm-svn: 183708
- Split createAtom() in lib/ReaderWriter/ELF/File.h into small methods.
- Added comments to code in other methods.
No functionality changes.
Reviewers: shankarke
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D921
llvm-svn: 183696
This fixes a recent regression (r183338). Stripped elf files (like installed
crtn.o for example), are not required to have a symbol table. Handle that
correctly.
llvm-svn: 183573
Found that having a method to check the strucutre of the followon graph makes
it easy to debug file readers. The method checks if there's no wrong edge in
followOnNexts and followOnRoots. It is called only when debuggging is enabled
for LayoutPass.
Reviewers: shankarke
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D922
llvm-svn: 183553
lld can now output a valid Windows executable with a text section that does nothing
but just returns immediately. It's not able to handle relocations, symbol tables,
data sections, etc, so it still can't do anything practical, though.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D892
llvm-svn: 183478
This is the parser for the ENTRY command. Note that because the parsing result
is currentlyd discarded, lld can parse but just ignore the command.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D833
llvm-svn: 183141
Users can override the default value of the dynamic linker to be set to the
one that appears in the command line. The path can even be empty!.
Added a test for the option.
llvm-svn: 182889
Add WinLinkDriver and connect it to the existing COFF reader. Remaining
parts are still stubs, so while it can now read a COFF file, it still
cannot link or output PE/COFF files yet.
Reviewers: Bigcheese
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D865
llvm-svn: 182784