Commit Graph

2322 Commits

Author SHA1 Message Date
Nick Kledzik e5da30cbd3 [mach-o] fix leak in atoms -> normalized
llvm-svn: 223530
2014-12-05 22:03:28 +00:00
Nick Kledzik b7ec8ae2ab [mach-o] Switch MachOFile and MachODylibFile to use BumpPtr in lld::File
llvm-svn: 223529
2014-12-05 22:03:26 +00:00
Nick Kledzik de9563d31b Add BumpPtrAllocator to lld::File. Switch SimpleDefinedAtom to allocate
its SimpleRefernces using the BumpPtrAllocator.

llvm-svn: 223528
2014-12-05 22:03:23 +00:00
Nick Kledzik 290cfc6ba5 [mach-o] Pass vectors by reference and name empty vector.
llvm-svn: 223527
2014-12-05 22:03:20 +00:00
Rui Ueyama be68a99f20 [PECOFF] Fix exported symbols in an import library.
Looks like if you have symbol foo in a module-definition file
(.def file), and if the actual symbol name to match that export
description is _foo@x (where x is an integer), the exported
symbol name becomes this.

  - foo in the .dll file
  - foo@x in the .lib file

I have checked in a few fixes recently for exported symbol name mangling.
I haven't found a simple rule that governs all the mangling rules.
There may not ever exist. For now, this is a patch to improve .lib
file compatibility.

llvm-svn: 223524
2014-12-05 21:52:02 +00:00
Will Newton 0b7f842592 ELF: Use ELF reloc .def files to reduce duplication
Tested with check-lld with no regressions.

llvm-svn: 223462
2014-12-05 12:43:26 +00:00
Rui Ueyama c2576d5464 Remove extra semicolon.
llvm-svn: 223411
2014-12-04 23:26:11 +00:00
Eric Christopher e9a36eab1e Fix a bunch of -Winconsistent-missing-override warnings.
llvm-svn: 223400
2014-12-04 22:26:07 +00:00
Rui Ueyama 5ae2050420 Revert "Rewrite InputGraph's Group"
This reverts commit r223330 because it broke Darwin and ELF
linkers in a way that we couldn't have caught with the existing
test cases.

llvm-svn: 223373
2014-12-04 18:29:03 +00:00
Simon Atanasyan c9bcffd201 [ELF] Adjust ELF header entry symbol value if this symbol is microMIPS encoded
To find an AtomLayout object for the given symbol I replace the
`Layout::findAtomAddrByName` method by `Layout::findAtomLayoutByName` method.

llvm-svn: 223359
2014-12-04 13:43:35 +00:00
Rui Ueyama 0152732ef4 [PECOFF] Improve /export compatibility.
Looks like the rule of /export is more complicated than
I was thinking. If /export:foo, for example, is given, and
if the actual symbol name in an object file is _foo@<number>,
we need to export that symbol as foo, not as the mangled name.

If only /export:_foo@<number> is given, the symbol is exported
as _foo@<number>.

If both /export:foo and /export:_foo@<number> are given,
they are considered as duplicates, and the linker needs to
choose the unmangled name.

The basic idea seems that the linker needs to export a symbol
with the same name as given as /export.

We exported mangled symbols. This patch fixes that issue.

llvm-svn: 223341
2014-12-04 06:09:39 +00:00
Rui Ueyama 60df72ff61 Rewrite InputGraph's Group
The aim of this patch is to reduce the excessive abstraction from
the InputGraph. We found that even a simple thing, such as sorting
input files (Mach-O) or adding a new file to the input file list
(PE/COFF), is nearly impossible with the InputGraph abstraction,
because it hides too much information behind it. As a result,
we invented complex interactions between components (e.g.
notifyProgress() mechanism) and tricky code to work around that
limitation. There were many occasions that we needed to write
awkward code.

This patch is a first step to make it cleaner. As a first step,
this removes Group class from the InputGraph. The grouping feature
is now directly handled by the Resolver. notifyProgress is removed
since we no longer need that. I could have cleaned it up even more,
but in order to keep the patch minimum, I focused on Group.

SimpleFileNode class, a container of File objects, is now limited
to have only one File. We shold have done this earlier.
We used to allow putting multiple File objects to FileNode.
Although SimpleFileNode usually has only one file, the Driver class
actually used that capability. I modified the Driver class a bit,
so that one FileNode is created for each input File.

We should now probably remove SimpleFileNode and directly store
File objects to the InputGraph in some way, because a container
that can contain only one object is useless. This is a TODO.

Mach-O input files are now sorted before they are passe to the
Resolver. DarwinInputGraph class is no longer needed, so removed.

PECOFF still has hacky code to add a new file to the input file list.
This will be cleaned up in another patch.

llvm-svn: 223330
2014-12-04 01:09:06 +00:00
Rui Ueyama a5e2a66dda [PECOFF] Improve compatibility of /export option.
llvm-svn: 223326
2014-12-04 00:31:34 +00:00
Rui Ueyama d31cf6065f [PECOFF] Fix a bug in /export option handler.
/export option can be given multiple times to specify multiple
symbols to be exported. /export accepts both decorated and
undecorated name.

If you give both undecorated and decorated name of the same symbol
to /export, they are resolved to the same symbol. In this case,
we need to de-duplicate the exported names, so that we don't have
duplicated items in the export symbol table in a DLL.

We remove duplicate items from a vector. The bug was there.
Because we had pointers pointing to elements of the vector,
after an item is removed, they would point wrong elements.

This patch is to remove these pointers. Added a test for that case.

llvm-svn: 223200
2014-12-03 04:34:20 +00:00
Zachary Turner 392b715caf Disable warning 4530 for MSVC builds.
We compile with exceptions off for LLVM and all other LLVM
subprojects, so this brings parity to LLD and disables this
warning.

Reviewed by: Rui Ueyama

llvm-svn: 223131
2014-12-02 17:57:54 +00:00
Nick Kledzik 07ba5121a1 [mach-o] Fix TrieEdge leak
In PR21682 Jean-Daliel Dupas found a leak in the trie builder and suggested
a fix was to use a list instead of SmallVector so that the list elements
could be allocated in the BumpPtrAllocator.

llvm-svn: 223104
2014-12-02 01:50:44 +00:00
Nick Kledzik a441b7b050 [mach-o] add support for arm64 compact unwind info
Tim previously added generic compact unwind processing and x86_64 support.
This patch adds arm64 support.

llvm-svn: 223103
2014-12-02 01:50:38 +00:00
Shankar Easwaran 7a64ec24d6 [Core] Remove function to not override RoundTripPasses.
RoundTripPasses should always be called in DEBUG mode if the environment
variable "LLD_RUN_ROUNDTRIP_TEST" is set.

Flavors should not be able to override this behavior.

llvm-svn: 223073
2014-12-01 20:28:54 +00:00
Shankar Easwaran 2895527ec2 [Core] Add flag to check if RoundTripPasses need to be run.
This would allow other flavor specific contexts to override the default value,
if they want to optionally run the round trip passes.

There is some information lost like the original file owner of the atom with
RoundTripPasses. The Gnu flavor needs this information inorder to implement
LinkerScript matching and for other diagnostic outputs such as Map files.

The flag also can be used to record information in the Atom if the information
to the Writer needs to be conveyed through References too.

llvm-svn: 222983
2014-12-01 01:04:11 +00:00
Shankar Easwaran a0184368d6 [ELF] Fix layout of output sections.
The AtomSections were improperly merging sections from various input files. This
patch fixes the problem, with an updated test that was provided by Simon.

Thanks to Simon Atanasyan for catching this issue.

llvm-svn: 222982
2014-11-30 22:36:29 +00:00
Shankar Easwaran 52a53fe591 [ELF] Rename align2 to alignment.
No change in functionality.

llvm-svn: 222975
2014-11-30 04:17:06 +00:00
Shankar Easwaran 25c33d60c2 [ELF] Fix creation of segments.
Linker was creating a separate output segment in some cases if input sections
had huge alignments. This patch fixes the issue.

llvm-svn: 222974
2014-11-30 04:01:14 +00:00
Shankar Easwaran aa00539aa5 [ELF] Create input and output section names
No change in functionality.

llvm-svn: 222973
2014-11-30 03:43:38 +00:00
Shankar Easwaran 2d382c6943 [ELF] Rename MergedSection to OutputSection.
No change in functionality.

llvm-svn: 222972
2014-11-30 03:18:08 +00:00
Will Newton 2db4107a36 Rename R_AARCH64_TLSDESC_ADR_PAGE to R_AARCH64_TLSDESC_ADR_PAGE21
llvm-svn: 222823
2014-11-26 11:00:03 +00:00
Will Newton ee5772faaa Fix comment in AArch64 ELF backend
llvm-svn: 222814
2014-11-26 09:51:54 +00:00
Rui Ueyama b12191aaf9 Use SafelyCloseFileDescriptor instead of close.
Opening a file using openFileForWrite and closing it using close
was asymmetric. It also had a subtle portability problem (details are
described in the commit message for r219189).

llvm-svn: 222802
2014-11-26 01:45:24 +00:00
Rui Ueyama 65e0ca1bde [PECOFF] Properly close a file descriptor.
This was basically benign resource leak on Unix, but on Windows
it could cause builds to fail because opened file descriptor
prevents other processes from moving or removing the file.

llvm-svn: 222799
2014-11-26 00:21:27 +00:00
Rui Ueyama 24a7f7eed8 [PECOFF] Ignore /maxilkfile option.
.ilk file is a file for incremental linking. We don't create nor use
that file.

/MAXILKFILE is an undocumented option to specify the maximum size
of the .ilk file, IIUC. We should just ignore the option.

llvm-svn: 222777
2014-11-25 19:51:28 +00:00
Rui Ueyama 0d9a181d9d [PECOFF] Create an empty PDB file if debug option is enabled.
There are many build files in the wild that depend on the fact that
link.exe produces a PDB file if /DEBUG option is given. They fail
if the file is not created.

This patch is to make LLD create an empty (dummy) file to satisfy
such build targets. This doesn't do anything other than "touching"
the file.

If a target depends on the content of the PDB file, this workaround
is no help, of course. Otherwise this patch should help build some
stuff.

llvm-svn: 222773
2014-11-25 19:01:01 +00:00
David Majnemer 86903b70fc Silence a -Wcast-qual warning
llvm-svn: 222598
2014-11-22 00:45:01 +00:00
Simon Atanasyan cff9efb52f [Mips] Use endian::read() for relocation addendum reading
llvm-svn: 222574
2014-11-21 21:26:32 +00:00
Rui Ueyama 4a259cf4a5 [PECOFF] Enable dead-stripping even if /debug option is given.
/debug makes MSVC link.exe to not remove unused sections from
the resulting executable. We did the same thing before. However,
I realized that the removal of associative section depends on
the dead-stripping pass in LLD, so we cannot disable that. Or
LLD may produce slightly broken executables that have too much
data in it (which could result in nasty subtle bugs).

This patch is a temporary measure to create correct executable.
Currently /debug does not have any real effect for LLD anyway.

I'll improve associative section handling in another patch, so that
they are removed from output without depending on the dead-stripping
pass.

llvm-svn: 222483
2014-11-20 23:59:40 +00:00
Simon Atanasyan 8489349fdc [Mips] Simplify the code calculates HI16/LO16 relocations
No functional changes.

llvm-svn: 222470
2014-11-20 22:29:55 +00:00
Simon Atanasyan f2da06b774 [Mips] Remove duplicated relocation calculation routines
No functional changes.

llvm-svn: 222469
2014-11-20 22:29:49 +00:00
Simon Atanasyan de672148dd [Mips] Remove unused function argument
No functional changes.

llvm-svn: 222468
2014-11-20 22:29:43 +00:00
Simon Atanasyan 8a8282a8bb [Mips] Use endian::read/write function to load/save MIPS32 instructions
No functional changes.

llvm-svn: 222467
2014-11-20 22:29:37 +00:00
Nick Kledzik f78c64c6ae [mach-o] fix whitespace
llvm-svn: 222457
2014-11-20 21:41:53 +00:00
Nick Kledzik 9d98f7e454 [mach-o] use reference with "auto" to prevent copies
Patch by Jean-Daniel Dupas

llvm-svn: 222455
2014-11-20 21:19:58 +00:00
Rui Ueyama 2343e65b14 [PECOFF] Sort export table properly.
Export table entries need to be sorted in ASCII-betical order,
so that the loader can find an entry for a function by binary search.

We sorted the entries by its mangled names. That can be different
from their exported names. As a result, LLD produces incorrect export
table, from which the loader complains that a function that actually
exists in a DLL cannot be found.

This patch fixes that issue.

llvm-svn: 222452
2014-11-20 21:05:05 +00:00
Simon Atanasyan eeea5f88aa [Mips] Configure GOTPLT entries in the corresponding constructor
No functional changes.

llvm-svn: 222415
2014-11-20 06:34:04 +00:00
Shankar Easwaran dc23dad2b7 Revert "[ELF] Sectionkey should also contain path."
This reverts commit r222309.

Reverting because of failures on darwin bot.

llvm-svn: 222332
2014-11-19 06:47:29 +00:00
Shankar Easwaran b508eb269f Revert "[ELF] Rename MergedSection to OutputSection."
This reverts commit r222310.

Not sure which commit is the cause of the failure on the darwin bot. Will need
to revert my changes and commit one change at a time.

llvm-svn: 222330
2014-11-19 06:24:53 +00:00
Shankar Easwaran f994868b65 Revert "[ELF] Create input and output section names"
This reverts commit r222311.

Reverting because of failure in the darwin bot.

llvm-svn: 222329
2014-11-19 06:24:51 +00:00
Shankar Easwaran f552996fb3 Revert "[ELF] Fix creation of segments."
This reverts commit r222312.

There looks to be an intermittent failure in the darwin buildbot.

llvm-svn: 222326
2014-11-19 05:53:13 +00:00
Simon Atanasyan bd7187c8d4 [Mips] Remove unnecessary debug logging code
No functional changes

llvm-svn: 222325
2014-11-19 05:51:16 +00:00
Simon Atanasyan 863f32f70d [Mips] Configure PLT and LA25 entries in the corresponding constructors
No functional changes.

llvm-svn: 222324
2014-11-19 05:51:10 +00:00
Simon Atanasyan a50af747eb [Mips] Inline the configurePLTReference method
No functional changes.

llvm-svn: 222323
2014-11-19 05:51:05 +00:00
Simon Atanasyan 6a33f94dd1 [Mips] Remove redundant const_cast
No functional changes.

llvm-svn: 222322
2014-11-19 05:50:59 +00:00
Simon Atanasyan cd69b04381 [Mips] Make the function return type constant pointer
No functional changes.

llvm-svn: 222321
2014-11-19 05:50:53 +00:00