Commit Graph

2294 Commits

Author SHA1 Message Date
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
Simon Atanasyan ff903f385c [Mips] Move setup of LLD_R_MIPS_STO_PLT relocation to the getPLTEntry() routine
No functional changes.

llvm-svn: 222320
2014-11-19 05:50:47 +00:00
Shankar Easwaran 2d946283f9 [ELF] Handle ctors/dtors sections
Move functionality from MIPS target to DefaultLayout.

No change in functionality.

llvm-svn: 222313
2014-11-19 03:51:50 +00:00
Shankar Easwaran 294cca1e8c [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: 222312
2014-11-19 03:51:48 +00:00
Shankar Easwaran e35660ebe7 [ELF] Create input and output section names
No change in functionality.

llvm-svn: 222311
2014-11-19 03:51:45 +00:00
Shankar Easwaran 4eb1f9c01f [ELF] Rename MergedSection to OutputSection.
No change in functionality.

llvm-svn: 222310
2014-11-19 03:51:43 +00:00
Shankar Easwaran e490f38a5b [ELF] Sectionkey should also contain path.
No change in functionality.

llvm-svn: 222309
2014-11-19 03:51:41 +00:00
Nick Kledzik 5b9e48b4ce [mach-o] propagate dylib version numbers
Mach-o does not use a simple SO_NEEDED to track dependent dylibs.  Instead,
the linker copies four things from each dylib to each client: the runtime path
(aka "install name"), the build time, current version (dylib build number), and
compatibility version  The build time is no longer used (it cause every rebuild
of a dylib to be different).  The compatibility version is usually just 1.0
and never changes, or the dylib becomes incompatible.

This patch copies that information into the NormalizedMachO format and
propagates it to clients.

llvm-svn: 222300
2014-11-19 02:21:53 +00:00
Rui Ueyama 81b73f3020 Fix MSVC warning.
This patch fixes the following MSVC warning.

  warning C4334: '<<' : result of 32-bit shift implicitly
  converted to 64 bits (was 64-bit shift intended?)

llvm-svn: 222293
2014-11-19 00:48:06 +00:00
Nick Kledzik 2020efb9fe [mach-o] for 32-bit arm, in -r mode support B (not BL) to undefined symbol
When fixing up BL instructions, the linker has to compare the thumbness of the
target to decide if the instruction needs to be converted to BLX.  But with B
instruction there is no BX, so the linker asserts if the target is not the
same thumbness. This assert was firing in -r mode when the target was undefined
which it interpreted as being non-thumb.

Test case change is to add a B (in both thumb and arm code) to an undefined
symbol and round trip through -r mode.

llvm-svn: 222266
2014-11-18 22:08:50 +00:00
David Majnemer 471d4f894b Update to match LLVM r222216
llvm-svn: 222218
2014-11-18 03:06:52 +00:00
Nick Kledzik b072c3673a [mach-o] zero-fill sections have no file offset
In mach-o, sections of type S_ZEROFILL are special cased and to always have
their section.offset field be zero.

llvm-svn: 222202
2014-11-18 00:30:29 +00:00
Nick Kledzik 63adb08c2c [mach-o] extract atom alignment information from mach-o files
llvm-svn: 222201
2014-11-18 00:30:25 +00:00
Nick Kledzik f6e5ace974 [mach-o] enhance arm64 reloc parser to support local pointer relocations
The arm64 assembler almost always uses r_extern=1 relocations in which the
r_symbolnum field is the index of the symbol the relocation references.  But
sometimes it will set r_extern=0 in which case the linker needs to read the
content of the reloction to determine the target.

Add test case that the r_extern=0 relocation round trips.

llvm-svn: 222200
2014-11-18 00:30:22 +00:00
Nick Kledzik 68c42ecae0 [mach-o] fix typos. No function change
llvm-svn: 222199
2014-11-18 00:30:20 +00:00
Nick Kledzik 60db3549e2 [mach-o] enhance arm64 reloc parser to support local pointer relocations
The arm64 assembler almost always uses r_extern=1 relocations in which the
r_symbolnum field is the index of the symbol the relocation references.  But
sometimes it will set r_extern=0 in which case the linker needs to read the
content of the reloction to determine the target.

Add test case that the r_extern=0 relocation round trips.

llvm-svn: 222198
2014-11-18 00:30:17 +00:00
Nick Kledzik 218f7199ca [mach-o] fix typos. No function change
llvm-svn: 222197
2014-11-18 00:30:14 +00:00
Rui Ueyama 5552de51d5 [PECOFF] Fix 32-bit delay-import table.
llvm-svn: 222116
2014-11-17 02:04:54 +00:00
Rui Ueyama 71aa1a9355 [PECOFF] Fix section alignment.
If you have something like

  __declspec(align(8192)) int foo = 1;

in your code, the compiler makes the data to be aligned to 8192-byte
boundary, and the linker align the section containing the data to 8192.

LLD always aligned the section to 4192. So, as long as alignment
requirement is smaller than 4192, it was correct, but for larger
requirements, it's wrong.

This patch fixes the issue.

llvm-svn: 222043
2014-11-14 21:33:07 +00:00
Rui Ueyama ad8188e0b6 [PECOFF] Remove dead code
AddressOfEntryPoint is overridden after we layout all atoms (until then,
we don't know the entry point address for obvious reason.)
I believe this code is leftover from very early version of the
PE/COFF port that we only had an entry function in a test object file.

llvm-svn: 222026
2014-11-14 19:21:06 +00:00
Eric Christopher fe455041b9 Silence inconsistent override warnings.
llvm-svn: 222021
2014-11-14 18:44:53 +00:00
Simon Atanasyan 55c2699d29 Follow-up to r221913. Fix some -Wcast-qual warning reasons.
llvm-svn: 221974
2014-11-14 07:15:43 +00:00
Shankar Easwaran c37f8af577 [ELF] Dynamic section was not aligned properly.
The dynamic section was not aligned properly. The alignment of the section is
determined by the word size of the architecture.

llvm-svn: 221972
2014-11-14 04:57:21 +00:00
Simon Atanasyan ec2914e0f0 [Mips] Add comment to the test case
No functional changes.

llvm-svn: 221893
2014-11-13 15:29:37 +00:00
Shankar Easwaran 0769c0ed0d [ELF] Fix the fileoffset according to the ELF spec.
With --no-align-segments, there is a bug that the fileoffset may not be
congruent to virtual address modulo page alignment.

This patch fixes the problem.

llvm-svn: 221890
2014-11-13 14:30:21 +00:00
Simon Atanasyan c77f5fa4f4 [ELF] Add CodeModel attribute to the DefinedAtom class
MIPS ELF symbols might contain some additional MIPS-specific flags
in the st_other field besides visibility ones. These flags indicate
code properties like microMIPS / MIPS16 encoding, position independent
code etc. We need to transfer the flags from input objects to the
output linked file to write them into the symbol table, adjust symbols
addresses etc.

I add new attribute CodeModel to the DefinedAtom class to hold target
specific flag and to get over YAML/Native format conversion barrier.
Other architectures/targets can extend CodeModel enumeration by their
own flags.

MIPS specific part of this patch adds support for STO_MIPS_MICROMIPS
flag. This flag marks microMIPS symbols. Such symbol should:
a) Has STO_MIPS_MICROMIPS in the corresponding .symtab record.
b) Has adjusted (odd) address in the corresponding .symtab
   and .dynsym records.

llvm-svn: 221864
2014-11-13 07:03:41 +00:00
Shankar Easwaran 74ce86cb83 [ELF] Fix segment alignment.
The segment alignment for PT_LOAD segments is set to page size by default, but
if any of the sections require an alignment more than the page size, the segment
alignment property is set to the maximum alignment of the sections that are part
of the segment.

llvm-svn: 221862
2014-11-13 04:33:06 +00:00
Shankar Easwaran 2e20049260 [ELF] Fix conditions for max-page-size.
Fix comments from Rui, also adds a test.

llvm-svn: 221860
2014-11-13 04:03:46 +00:00
Shankar Easwaran b43804b6f4 [ELF] Fix max-page-size option.
The user can use the max-page-size option and set the maximum page size. Dont
check for maximum allowed values for page size, as its what the kernel is
configured with.

Fix the test as well.

llvm-svn: 221858
2014-11-13 03:25:38 +00:00