Commit Graph

2795 Commits

Author SHA1 Message Date
Pete Cooper 52db793d33 Improved debugging printing. NFC
llvm-svn: 256805
2016-01-05 01:56:59 +00:00
Pete Cooper bd364ce694 Sort sections in relocatable files.
The final section order in relocatable files was just a side effect
of the atom sorter.  This meant that sections like __data were before
__text because __data has RW permissions and __text RX and RW was less
than RX in our enum.

Final linked images had an actual section/segment sorter.  There was no
reason for the difference, so simplify a bunch of code and just use the
same sorted for everything.

Reviewed by Lang Hames.

http://reviews.llvm.org/D15868

llvm-svn: 256786
2016-01-04 22:29:36 +00:00
Pete Cooper 9942bd025d Fix x86_64 delta*Anon relocs.
The encoded value should be an offset from the fixup location, which
means that it should take in to account the fixup offset in its section.

We weren't subtracting the base address of the atom, which meant that when
we parsed the file again for a round trip, we had 2x the atom address in our
target address.

I've also improved comments for these to try and describe what is going on.

There's no test case right now, as the bug is only exhibited when __data is at
a non-zero address in a -r link.  A commit will soon sort the sections differently
and move __data to after __text.  Then these relocations in
test/mach-o/parse-data-relocs-x86_64.yaml will test for this bug.

llvm-svn: 256779
2016-01-04 21:23:12 +00:00
Pete Cooper 9092eca155 Fix negDelta32 relocatable fixups for arm64 in mach-o.
negDelta32 is only ever implicitly generated as the FDE->CIE reference.
We therefore don't emit a relocation for it in the object file in -r mode.

The value we write in to the FDE location therefore needs to point to the
final target address of the CIE, and not the inAtomAddress as it was currently
doing.

llvm-svn: 255835
2015-12-16 22:50:16 +00:00
Pete Cooper e5fa5a3c29 Add more debugging output to MachO lld. NFC.
In debug builds there's now a dump method on Section and improved
printing of atoms.

llvm-svn: 255826
2015-12-16 22:03:21 +00:00
Pete Cooper 7bf3a85e2b Move parsing of LLVM options to parse() method.
We used to parse the LLVM options in Driver::link.  However, that is
after parse() where we load files.  By moving the LLVM option handling
earlier, we can add DEBUG() to code such as MachONormalizedFileToAtoms.cpp
and have it enabled correctly by '-mllvm --debug'.

llvm-svn: 255819
2015-12-16 20:53:27 +00:00
Pete Cooper 3e8f56565d Added some DEBUG() prints to make it clearer what the mach-o passes are doing. NFC.
We had some DEBUG prints these passes, but add more so that its clear where we are dumping
things, and what state we are in when we do so.

I'll be adding more and more DEBUG printing to try make it easier to observe whats going on
without having to attach a debugger.

llvm-svn: 255805
2015-12-16 19:12:49 +00:00
Lang Hames ac2adce66b [lld][MachO] Recognize __thread_bss sections as zero-fill and set all the
appropriate bits.

This fixes the remaining clang regression test failures when linking clang with
lld on Darwin.

llvm-svn: 255390
2015-12-11 23:25:09 +00:00
Pete Cooper 5cd12580fd Verify that macho-o delta64 relocs have the same offset.
The delta64 relocation is represented as the pair ARM64_RELOC_SUBTRACTOR and ARM64_RELOC_UNSIGNED.

Those should always have the same offset, so this adds a check and tests to ensure this is the case.

Also updated the error printing in this case to shows both relocs when erroring on pair.

llvm-svn: 255274
2015-12-10 18:48:52 +00:00
Lang Hames 201c08f811 [lld][MachO] Always reserve space for the empty string in the mach-o symbol
table.

The first entry in the MachO symbol table is always the empty string: make sure
we reserve space for it, or we will overflow the symbol table by one byte.

No test case - this manifests as an occasional memory error. In the near future
I hope to set up a bot building and runnnig LLD with sanitizers - that should
catch future instances of this issue.

llvm-svn: 255178
2015-12-10 00:12:24 +00:00
Pete Cooper 466d4b006b Don't bypass the GOT for delta32toGOT references.
The gcc_except_tab was generating these references to point to the typeinfo in the data section.

gcc_except_tab also had the DW_EH_PE_indirect flag set which means that at runtime we are going
to dereference this entry as if it is in the GOT.

Reviewed by Nick Kledzik in http://reviews.llvm.org/D15360.

llvm-svn: 255085
2015-12-09 00:46:02 +00:00
Rafael Espindola 9c8904fb38 Rename ld.lld2 to ld.lld since it is the default.
llvm-svn: 253437
2015-11-18 06:11:01 +00:00
Rafael Espindola 7477e99af7 Make ELF2 the default.
With this the only way to get the old elf linker is "-flavor old-elf".

llvm-svn: 253318
2015-11-17 07:19:44 +00:00
Rafael Espindola 97a8695aa1 Rename gnu2 to gnu.
This is the second step in making ELF2 the default.

llvm-svn: 253270
2015-11-16 23:21:55 +00:00
Rafael Espindola 7467461ccc Rename the gnu flavour to gnu old.
This is the first step in making ELF2 the default.

llvm-svn: 253188
2015-11-16 08:54:19 +00:00
Eugene Zelenko 4154794892 Fix Clang-tidy modernize-use-auto warnings, other minor fixes.
Differential revision: http://reviews.llvm.org/D14553

llvm-svn: 252661
2015-11-10 22:37:38 +00:00
Kevin Enderby 35dfc95efe These are the matching changes needed to the lld project for the changes to llvm
in r252192 that changed the Archive and Child interfaces in libObject. These include
Rafael Espindola’s many suggested updates.

llvm-svn: 252193
2015-11-05 19:25:47 +00:00
Eugene Zelenko 6e43b499d2 Fix Clang-tidy modernize-use-override warnings, other minor fixes.
Differential revision: http://reviews.llvm.org/D14310

llvm-svn: 252034
2015-11-04 02:11:57 +00:00
Lang Hames 2ed3bf9527 [lld][MachO] Make sure LC_RPATH command size is a multiple of the pointer size.
llvm-svn: 251637
2015-10-29 16:50:26 +00:00
Lang Hames ac416d42fc [lld][MachO] Use a std::string rather than a StringRef for the section name in
MachODefinedCustomSectionAtom.

The section names for these atoms are initialized from temporaries (e.g.
segName + "/" + sectName), so we can't use StringRef here.

llvm-svn: 251610
2015-10-29 03:57:31 +00:00
Simon Atanasyan 069b2dd66c [Driver] Ignore -G option in both new and old ELF linker
This is optimization option that make sense for MIPS targets. We can
safely ignore it now.

llvm-svn: 251519
2015-10-28 14:50:58 +00:00
Simon Atanasyan 07fe7a943f [Driver] Accept both -m <emulation> and -m<emulation>
GNU linkers accept both variants and at least for MIPS target gcc passes
joined variant of the '-m' option.

Differential Revision: http://reviews.llvm.org/D14133

llvm-svn: 251497
2015-10-28 05:13:12 +00:00
Lang Hames b1b67f4daf [lld][Darwin] Add support for the -sectcreate option.
llvm-svn: 251183
2015-10-24 08:20:51 +00:00
Lang Hames 5e7cfe4e2b [lld][MachO] Prune unused EH frames.
llvm-svn: 251095
2015-10-23 05:39:16 +00:00
Craig Topper f88d22970d Update lld to match llvm r250901. OptTable constructor now takes an ArrayRef. NFC
llvm-svn: 250904
2015-10-21 16:31:56 +00:00
Lang Hames 2483d8f4a7 [lld][MachO] Fix indentation.
llvm-svn: 250863
2015-10-20 21:47:19 +00:00
Lang Hames 650c00be89 [lld][MachO] Fix typo in comment.
llvm-svn: 250861
2015-10-20 21:44:30 +00:00
Rafael Espindola 7d76847da3 Simplify. NFC.
llvm-svn: 249128
2015-10-02 13:23:29 +00:00
Rafael Espindola 98efd89e7e Use ld.lld2 as a argv[0] alias.
The reason for the name is so that we can run

./build/bin/clang -fuse-ld=lld2 test.o -o t

llvm-svn: 249122
2015-10-02 12:57:34 +00:00
Rui Ueyama 43155d0d48 [LLD] Fix Clang-tidy modernize-use-nullptr warnings; other minor cleanups.
Patch from Eugene Zelenko!

llvm-svn: 249111
2015-10-02 00:36:00 +00:00
Lang Hames 9a4c94ec5a [lld][MachO] Fix a think-o to get the twolevel/dynamic_lookup test passing.
llvm-svn: 248736
2015-09-28 20:52:21 +00:00
Lang Hames 5c692009bc [lld][MachO] Initial implementation of -flat_namespace and -undefined.
This is a basic initial implementation of the -flat_namespace and
-undefined options for LLD-darwin. It ignores several subtlties,
but the result is close enough that we can now link LLVM (but not
clang) on Darwin and pass all regression tests.

llvm-svn: 248732
2015-09-28 20:25:14 +00:00
Tom Stellard d0626804fc ELF/AMDGPU: Text section should be called .hsatext
Reviewers: atanasyan, ruiu

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12447

llvm-svn: 248621
2015-09-25 21:42:30 +00:00
Rui Ueyama 1392d8b5fe Fix memory leak in FileArchive::find().
Patch from George Rimar!

llvm-svn: 248525
2015-09-24 18:59:26 +00:00
Lang Hames c803442890 [LLD][MachO] Fix a FIXME: Subtract base address from atom address when building
export trie.

llvm-svn: 248217
2015-09-21 22:06:02 +00:00
Simon Atanasyan 92480f9a20 [Mips] Rejects all --hash-style arguments except 'sysv' in case of MIPS target
MIPS ABI supports only --hash-style=sysv variant.

llvm-svn: 247796
2015-09-16 13:36:32 +00:00
Simon Atanasyan 49c67236f1 [Mips] Do not show an error if R_MIPS_GPREL32 relocation has a non-local target
This matches GNU linker behaviour.

llvm-svn: 247795
2015-09-16 13:36:24 +00:00
Rui Ueyama 9071e4a6fa Fix Clang-tidy misc-use-override warnings, other minor fixes.
Patch from Eugene Zelenko!

llvm-svn: 247323
2015-09-10 18:51:36 +00:00
Rui Ueyama 6b0af3c832 Fix -Wcovered-switch-default warnings.
llvm-svn: 246419
2015-08-31 06:46:00 +00:00
Rui Ueyama 692f8683d7 ELF: Fix "not all control paths return a value" warning.
llvm-svn: 246417
2015-08-31 06:32:25 +00:00
Simon Atanasyan e235d45026 [Mips] Support grouping of multiple consecutive relocations in case of N32 and 64-bit MIPS ABIs
llvm-svn: 246337
2015-08-28 21:39:21 +00:00
Simon Atanasyan 9638d7d162 [Mips] Support two more MIPS linking emulation options elf32btsmipn32/elf32ltsmipn32
llvm-svn: 246336
2015-08-28 21:39:13 +00:00
Simon Atanasyan f12120cfe9 [Mips] Make "emulation" option less dependent on the "-target" option.
Now it is possible to have mips-linux-gnu-ld executable and link MIPS 64-bit
little-endian binaries providing -melf64ltsmip command line argument.

llvm-svn: 246335
2015-08-28 21:39:06 +00:00
Simon Atanasyan 6d39140b6e [Mips] Initial support of the MIPS N32 ABI
llvm-svn: 246334
2015-08-28 21:39:00 +00:00
Tom Stellard 8251f978d3 ELF/AMDGPU: Add more misssing: using namespace lld;
Hopefully, this will resolve the remaining windows bot errors.

llvm-svn: 246181
2015-08-27 18:43:12 +00:00
Tom Stellard 39b3d71177 ELF/AMDGPU: Add missing: using namespace lld; to try to fix windows bot
llvm-svn: 246179
2015-08-27 18:27:52 +00:00
Tom Stellard fbbbc01caa ELF/AMDGPU: Remove another unused private member variable
llvm-svn: 246164
2015-08-27 17:11:10 +00:00
Tom Stellard 36c6f6b874 ELF/AMDGPU: Remove unused private member variable
This should fix the one of the failing bots.

llvm-svn: 246160
2015-08-27 16:52:58 +00:00
Tom Stellard ff8dfbd965 ELF/AMDGPU: Attempt to fix windows bots
Broken by r246155.

llvm-svn: 246159
2015-08-27 16:48:46 +00:00
Tom Stellard 15d1fa1bcc ELF: Add AMDGPU ReaderWriter
This is a basic implementation that allows lld to emit binaries
consumable by the HSA runtime.

Differential Revision: http://reviews.llvm.org/D11267

llvm-svn: 246155
2015-08-27 15:55:44 +00:00