This patch adds support for converting normalized mach-o to and from binary
mach-o. It also changes WriterMachO (which previously directly wrote a
mach-o binary given a set of Atoms) to instead do it in two steps. The first
step uses normalizedFromAtoms() to convert Atoms to normalized mach-o, and the
second step uses writeBinary() which to generate the mach-o binary file.
llvm-svn: 194167
These fields are for /align option. Section alignment can be set per-section
basis with /section option too. In order to avoid name conflicts, rename the
existing identifiers to become more specific. No functionality change.
llvm-svn: 194160
/section command line option is to set/reset attributes of the Characteristics
field in the section header. You can set non-default values with this option.
You can make .data section executable with this, for example.
This patch implements the parser of the command line option. The code to use
the parsed values will be committed in a separate patch.
llvm-svn: 194133
I'm not sure if it is really an alias for /nodefaultlib, but I can say that
they are at least similar. Making it an alias would be better than ignoring it.
llvm-svn: 194131
/defaultlib options can be specified implicitly via the .drectve section, and
it's pretty common that multiple object files add the same library, such as
user32.lib, to the input. We shouldn't add the same library multiple times.
llvm-svn: 194129
msvcrt.lib contains "/disallowlib" command line option in its .drectve section.
I couldn't spot any documentation for the option. Ignore it for now so that we
can link the library without error.
llvm-svn: 194114
/merge:<from>=<to> option makes the linker to combine "from" section to "to"
section. This patch is to parse the option. The actual feature will be
implemented in a subsequent patch.
llvm-svn: 193454
/manifestfile:<path> specifies an alternative manifest file output path.
Default is "<output-path>.manifest" where <output-path> is the executable's
path.
llvm-svn: 193195
The manifest file is an XML file that conveys some information to the loader,
such as whether the executable needs to run as Administrator or not. This patch
is to parse command line option for manifest file.
Actual XML file generation will be done in a separate patch.
llvm-svn: 193141
Dead-strip root symbols can be undefined atoms, but should not really be
nonexistent, because dead-strip root symbols should be added to initial
undefined atoms at startup. Whenever you look up its name in the symbol
table, some type of atom will always exist.
llvm-svn: 192831
This is the first step in how I plan to get mach-o object files support into
lld. We need to be able to test the mach-o Reader and Write on systems without
a mach-o tools. Therefore, we want to support a textual way (YAML) to represent
mach-o files.
MachONormalizedFile.h defines an in-memory abstraction of the content of mach-o
files. The in-memory data structures are always native endianess and always
use 64-bit sizes. That internal data structure can then be converted to or
from three different formats: 1) yaml (text) encoded mach-o, 2) binary mach-o
files, 3) lld Atoms.
This patch defines the internal model and uses YAML I/O to implement the
conversion to and from the model to yaml. The next patch will implement
the conversion from normalized to binary mach-o.
This patch includes unit tests to validate the yaml conversion APIs.
llvm-svn: 192147
Changes :-
a) Functionality in InputGraph to insert Input elements at any position
b) Functionality in the Resolver to use nextFile
c) Move the functionality of assigning file ordinals to InputGraph
d) Changes all inputs to MemoryBuffers
e) Remove LinkerInput, InputFiles, ReaderArchive
llvm-svn: 192081
This patch inverts the return value of these functions, so that they return
"true" on success and "false" on failure. The meaning of boolean return value
was mixed in LLD; for example, InputGraph::validate() returns true on success.
With this patch they'll become consistent.
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1748
llvm-svn: 191341
/PDBALTPATH:<path> is an option to embed a different path for the PDB file to
the binary than the actual PDB file location. Because we don't support PDB
file, we'll just ignore the option for now.
llvm-svn: 191273
We used to support both Windows and Unix style command line options. In Windows
style, an option and its value are separated by ":" (colon). In Unix, separator
is a space. Accepting both styles were convenient, but we can no longer allow
Unix style because I found that can be ambiguous.
For example, /nodefaultlib option takes an optional argument. In Windows style
it's going to be something like "/nodefaultlib:foo". There's no ambiguity what
"foo" means. However, if the option is "/nodefaultlib foo", "foo" can be
interpreted either an optional argument for "/nodefaultlib" or an input file
"foo.obj". We should just stop accepting the non-standard command line style.
llvm-svn: 191247
These options are to enable DLL delay loading. If enabled, DLL is loaded
at run time by a helper routine when a function in the DLL is actually called
for the first time, instead of making the Windows loader to load all DLLs at
startup time. This should shorten startup delay if an executable have many
imported symbols.
The linker needs to create a "delayed import table" and link delayimp.lib in
which helper functions are defined to support the feature.
For now, we just ignore the options, so that the linker does not complain when
it sees these options. We want to support them in the future.
llvm-svn: 191232
This adds an option --output-filetype that can be set to either
YAML/Native(case insensitive). The linker would create the outputs
associated with the type specified by the user.
Changes all the tests to use the new option.
llvm-svn: 191183
/incremental is an option to enable incremental linking. We will eventually
want to implement the feature for better performance, but in the meantime,
we want to just ignore the option so that the linker does not output unknown
option error when it sees /incremental option.
llvm-svn: 191063
/errorReport is a command line option to let the linker to report internal
linker error information to Microsoft. For LLD that option doesn't make any
sense, so it just ignores the option.
llvm-svn: 191044
So that we can determine what the target architecture is. Adding this
field does not mean that we are going to support non-i386 architectures
soon; there are many things to do to support them, and I'm focusing on
i386 now. But this is the first step toward multi architecture support.
llvm-svn: 190627
attribute in LinkerInput to isWholeArchive and use that for deciding
whether library archives should be expanded. Implement the -all_load
option of the Darwin linker using this flag and drop the support for it
in GNU mode.
llvm-svn: 190275
This changes the interface of createLinkerInput to use ErrorOr, so that
errors from the linker can be captured.
Also adds a convenience function for error strings to be returned from
file nodes.
llvm-svn: 189871
This adds an API to the LinkingContext for flavors to add Internal files
containing atoms that need to appear in the YAML output as well, when -emit-yaml
switch is used.
Flavors can add more internal files for other options that are needed.
llvm-svn: 189718
With this patch the entry symbol is treated as an undefined symbol, to force
the resolver to resolve the entry symbol.
Differential Revision: http://llvm-reviews.chandlerc.com/D1524
llvm-svn: 189307
This used to be handled automagically by the option parsing library,
but after LLVM r188314, we should handle it ourselves.
No functionality change, but adds a test.
llvm-svn: 188318
Also change some local variable names: "ti" -> "context" and
"_targetInfo" -> "_context".
Differential Revision: http://llvm-reviews.chandlerc.com/D1301
llvm-svn: 187823
This reverts commit r187390 because we should not handle argv's quotes ourselves.
In Windows, unlike Unix, quotes are not processed by the shell. Instead the C
startup routine parses it as described in
http://msdn.microsoft.com/en-us/library/a1y7w461.aspx and pass the results to
main(). So, at the time when the control reaches main(), quotes that should be
removed has already been removed.
We still need to handle quotes in the response file and in .drectve section
ourselves. That will be addressed in different patches.
llvm-svn: 187534
Missing files will be reported as errors in the later pass, so this patch
does not change the behavior of the LLD linker, but it helps writing unit
tests for the driver.
llvm-svn: 187256
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