| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
Differential Revision: https://reviews.llvm.org/D50577
llvm-svn: 339477
|
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that postThunkContents() is only used for
sorting symbols in .symtab.
Though we can instead move the logic to SymbolTableBaseSection::finalizeContents(),
postpone calling it and then get rid of postThunkContents completely.
Differential revision: https://reviews.llvm.org/D49547
llvm-svn: 339413
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a crash issue when handling the empty -defsym.
For parsing this option we are using ScriptParser class which is used
generally for reading the linker script. For empty defsym case, we
pass the empty memory buffer and crash in the place removed in https://reviews.llvm.org/rL336436.
But reverting of the above patch would not help here (we would still crash but a bit later). And
even after fixing the crash we would report something like
"lld.exe: error: -defsym:1: unexpected EOF"
It is probably not the appropriate message because mentions EOF.
I think the issue should be handled on a higher level like this patch does.
So we do not want to pass the empty memory buffer first of all I believe.
Differential revision: https://reviews.llvm.org/D50498
llvm-svn: 339412
|
|
|
|
|
|
| |
Differential Revision: https://reviews.llvm.org/D50520
llvm-svn: 339371
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Patch by PkmX.
This patch makes lld recognize RISC-V target and implements basic
relocation for RV32/RV64 (and RVC). This should be necessary for static
linking ELF applications.
The ABI documentation for RISC-V can be found at:
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md.
Note that the documentation is far from complete so we had to figure out
some details from bfd.
The patch should be pretty straightforward. Some highlights:
- A new relocation Expr R_RISCV_PC_INDIRECT is added. This is needed as
the low part of a PC-relative relocation is linked to the corresponding
high part (auipc), see:
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#pc-relative-symbol-addresses
- LLVM's MC support for RISC-V is very incomplete (we are working on
this), so tests are given in objectyaml format with the original
assembly included in the comments. Once we have complete support for
RISC-V in MC, we can switch to llvm-as/llvm-objdump.
- We don't support linker relaxation for now as it requires greater
changes to lld that is beyond the scope of this patch. Once this is
accepted we can start to work on adding relaxation to lld.
Differential Revision: https://reviews.llvm.org/D39322
llvm-svn: 339364
|
|
|
|
|
|
|
| |
It covers the following line with a test:
https://github.com/llvm-mirror/lld/blob/master/ELF/OutputSections.cpp#L383
llvm-svn: 339348
|
|
|
|
|
|
|
|
|
| |
link.exe ignores REL32 relocations on 32-bit x86, as well as relocations
against non-function symbols such as labels. This makes lld do the same.
Differential Revision: https://reviews.llvm.org/D50430
llvm-svn: 339345
|
|
|
|
|
|
| |
This adds a test for https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L1289.
llvm-svn: 339342
|
|
|
|
|
|
|
| |
This covers the following line:
https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L415
llvm-svn: 339333
|
|
|
|
|
|
|
|
|
| |
This is a larger patch. This relocation has irregular immediate
masks that require a lookup to find the correct mask.
Differential Revision: https://reviews.llvm.org/D50450
llvm-svn: 339332
|
|
|
|
|
|
|
| |
This covers the following line with a test:
https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L415
llvm-svn: 339327
|
|
|
|
|
|
|
| |
This adds a coverage for the following line of the code:
https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L274
llvm-svn: 339326
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adding all libcall symbols to the link can have undesired consequences.
For example, the libgcc implementation of __sync_val_compare_and_swap_8
on 32-bit ARM pulls in an .init_array entry that aborts the program if
the Linux kernel does not support 64-bit atomics, which would prevent
the program from running even if it does not use 64-bit atomics.
This change makes it so that we only add libcall symbols to the
link before LTO if we have to, i.e. if the symbol's definition is in
bitcode. Any other required libcall symbols will be added to the link
after LTO when we add the LTO object file to the link.
Differential Revision: https://reviews.llvm.org/D50475
llvm-svn: 339301
|
|
|
|
|
|
| |
Differential Revision: https://reviews.llvm.org/D50424
llvm-svn: 339279
|
|
|
|
|
|
|
|
| |
Add REQUIRES to tests that fail when an x86 backend is not present.
Differential Revision: https://reviews.llvm.org/D50440
llvm-svn: 339253
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If /subsystem:windows is passed, link.exe only looks for WinMain and wWinMain,
and if /subsystem:console is passed it only looks for main and wmain. lld-link
used to look for all 4 in both cases. This patch makes lld-link match
link.exe's behavior.
This requires that the subsystem is known by the time findDefaultEntry() gets
called. findDefaultEntry() is called before the main link loop, so that the
loop can mark the entry point as undefined. That means inferSubsystem() has to
be called above the main loop as well. This in turn means /subsystem: from
.drectve sections only has an effect on entry point inference for obj files
passed to lld-link directly (and not in obj files found later in .lib files).
link.exe seems to ignore /subsystem: for obj files from lib files completely
(while in lld it's ignored only for entry point detection but it still
overrides /subsystem: flags passed on the command line for the value that gets
written in the output file).
Also, if the subsytem isn't needed (e.g. when only writing a /def: lib file and
not writing a coff file), link.exe doesn't complain if the subsystem isn't
known, so both subsystem and entry point handling should be below the early
return lld has for that case.
Fixes PR36523.
https://reviews.llvm.org/D50316
llvm-svn: 339165
|
|
|
|
|
|
|
|
| |
This 2 test cases covers the following code:
https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L185
https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L189
llvm-svn: 339137
|
|
|
|
|
|
|
| |
This covers the following line:
https://github.com/llvm-mirror/lld/blob/master/ELF/InputSection.cpp#L1032
llvm-svn: 339124
|
|
|
|
|
|
|
|
|
| |
This covers the following piece with a test.
https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L830
Thanks to Peter Collingbourne for providing the reproducer sample!
llvm-svn: 339114
|
|
|
|
|
|
|
|
| |
module. NFC.
Differential Revision: https://reviews.llvm.org/D50357
llvm-svn: 339100
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: To be consistent with other files where only SignExtend64 is used.
Reviewers: ruiu, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D50366
llvm-svn: 339083
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
The issue with the python path is that the path to python on Windows can contain spaces. To make the tests always work, the path to python needs to be surrounded by quotes.
This is a companion change to: https://reviews.llvm.org/D50206
Reviewers: asmith, zturner, espindola
Subscribers: emaste, sbc100, arichardson, aheejin, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D50282
llvm-svn: 339075
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
GNU ld's manual says that TARGET(foo) is basically an alias for
`--format foo` where foo is a BFD target name such as elf64-x86-64.
Unlike GNU linkers, lld doesn't allow arbitrary BFD target name for
--format. We accept only "default", "elf" or "binary". This makes
situation a bit tricky because we can't simply make TARGET an alias for
--target.
A quick code search revealed that the usage number of TARGET is very
small, and the only meaningful usage is to switch to the binary mode.
Thus, in this patch, we handle only TARGET(elf.*) and TARGET(binary).
Differential Revision: https://reviews.llvm.org/D48153
llvm-svn: 339060
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MinGW configurations don't use associative comdats, as GNU ld doesn't
support that. Instead they produce normal comdats named .text$sym,
.xdata$sym and .pdata$sym.
GNU ld doesn't discard any comdats starting with .xdata or .pdata,
even if --gc-sections is used (while it does discard other unreferenced
comdats), regardless of what symbol name is used after the $ separator.
For LLD, treat any such comdat as implicitly associative to the base
symbol. This requires maintaining a map from symbol name to section
number, but that is only maintained when the MinGW flag has been
enabled.
Differential Revision: https://reviews.llvm.org/D49700
llvm-svn: 339058
|
|
|
|
|
|
|
|
| |
This allows safe ICF to work when linking with LTO.
Differential Revision: https://reviews.llvm.org/D50221
llvm-svn: 339050
|
|
|
|
|
|
|
|
|
|
|
| |
It's not an error if a common symbol (uninitialized data, with alignment
specified via the aligncomm directive) is replaced with a regular
one with initialized data (with alignment specified via the section
chunk).
Differential Revision: https://reviews.llvm.org/D50268
llvm-svn: 339049
|
|
|
|
|
|
|
|
|
|
|
| |
--export now implies --undefined
This is really a requirement from emscripten but I think it
makes sense in general too.
Differential Revision: https://reviews.llvm.org/D50287
llvm-svn: 339047
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
During copy relocation of a variable defined in a DSO, if a TLS variable in that DSO happens to have the same st_value, it would also be copied. This was unnecessary because the addresses of TLS variables are relative to TLS segment. They don't interfere with non-TLS variables.
This copying behavior can be harmful in the following scenario:
For function-scope thread-local variables with non-trivial constructors,
they have guard variables. In the case of x86_64 general-dynamic model:
template <int N>
void foo() {
thread_local std::string a;
}
GOT[n] R_X86_64_DTPMOD64 guard variable for a
GOT[n+1] R_X86_64_DTPOFF64 guard variable for a
GOT[n+2] R_X86_64_DTPMOD64 a
GOT[n+3] R_X86_64_DTPOFF64 a
a and its guard variable are both represented as TLS variables, which
should be within the same module. If one is copy relocated to the main
module while the other is not, their module ID will mismatch and can
cause access without prior construction.
Reviewers: ruiu, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D50289
llvm-svn: 339042
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some parts of the code changed are a bit old. I found traces in 2016.
Initiall commits has test cases and perhaps reasonable comments.
For example, we had segfaults earlier and had the code to fix them.
Now, in 2018, I think it is excessive to have these parts, because
we do not have segfaults and our code was changed a lot (softly saying).
I reviewed the current sources and I think that at this point of the
execution flow, we should never face with
the conditions checked and so I removing them in this patch.
This helps to cleanup the code.
llvm-svn: 339003
|
|
|
|
|
|
|
|
|
|
| |
Add a test for the R_ARM_THM_JUMP11 relocation to an undefined symbol. We
have to use yaml2obj as llvm-mc relaxes the narrow branch to a b.w which
uses the R_ARM_THM_JUMP24 relocation instead.
Differential Revision: https://reviews.llvm.org/D50234
llvm-svn: 338999
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Optimization remark format is slightly changed by LLVM patch D49412.
One test is fixed with expected messages changed.
Frankly speaking I have not tested this change yet. I will test when manage to setup the project.
Reviewers: xbolva00, espindola
Reviewed By: xbolva00
Subscribers: emaste, arichardson, steven_wu, dexonsmith
Differential Revision: https://reviews.llvm.org/D50242
llvm-svn: 338970
|
|
|
|
|
|
|
|
|
|
| |
case when we fail to write the output."
It broke BB:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/34382/steps/test/logs/stdio
http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/21932/steps/test_lld/logs/stdio
llvm-svn: 338960
|
|
|
|
|
|
|
|
| |
output.
We did not report the file name and had no test for that case.
llvm-svn: 338959
|
|
|
|
|
|
| |
It feels "shell" is excessive. Lets try without it.
llvm-svn: 338958
|
|
|
|
|
|
|
| |
This change removes the dead code and makes cosmetic change
showing why it was dead.
llvm-svn: 338957
|
|
|
|
|
|
|
| |
rangeToString() takes addres and length,
previously it was called incorrectly.
llvm-svn: 338956
|
|
|
|
|
|
|
|
|
|
|
| |
This simplifies the code a bit.
It is NFC except that it removes early exit for Count == 0
which does not seem to be useful (we have no such tests either).
Differential revision: https://reviews.llvm.org/D49136
llvm-svn: 338953
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This matches the behavior of the ELF linker where -u/--undefined
means symbols will get pulled in from archives but won't result
in link error if they are missing.
Also, don't actually great symbol table entries for the undefined
symbols, again matching more closely the ELF linker.
This also results in simplification of the code.
Differential Revision: https://reviews.llvm.org/D50279
llvm-svn: 338938
|
|
|
|
|
|
|
|
|
| |
No intended behavior change. Not repeating the CRTStartup names makes fixing
PR36523 simpler.
https://reviews.llvm.org/D50253
llvm-svn: 338911
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
entry point inference on 32-bit with /nodefaultlib
LinkerDriver::inferSubsystem() used to do Symtab->findUnderscore("WinMain"),
but WinMain is stdcall in 32-bit and is hence is called _WinMain@16. Instead,
Symtab->findMangle(mangle("WinMain")) needs to be called.
But since LinkerDriver::inferSubsystem() and LinkerDriver::findDefaultEntry()
both need to call this, introduce a common helper function for this and call it
from both places. (Also call it for "main" for consistency, even though
findUnderscore() is enough for main since that's __cdecl on 32-bit).
This also exposed a bug for /nodefaultlib entrypoint inference: The code here
called findMangle(Sym) instead of findMangle(mangle(Sym)), again doing the
wrong thing on 32-bit. Fix that too.
While here, make Driver::mangle() a static free function.
https://reviews.llvm.org/D50184
llvm-svn: 338877
|
|
|
|
|
|
| |
Differential Revision: https://reviews.llvm.org/D49147
llvm-svn: 338767
|
|
|
|
|
|
|
|
|
|
| |
error handling. Add test file for better code-coverage. Update tests to be more complete.
Submitting patch on behalf of saugustine.
Differential Revision: https://reviews.llvm.org/D49926
llvm-svn: 338750
|
|
|
|
|
|
|
| |
In according to the comment, undefined symbol should never reach there.
So, should be able to remove the check. I am assuming this is NFC.
llvm-svn: 338723
|
|
|
|
|
|
|
| |
BB is unhappy :`-(
http://lab.llvm.org:8011/builders/lld-perf-testsuite/builds/5632
llvm-svn: 338722
|
|
|
|
|
|
|
| |
There is no point to explicitly proccess the expressions this patch removes.
We already have a llvm_unreachable for the default case.
llvm-svn: 338718
|
|
|
|
|
|
|
|
|
|
|
| |
It does not seem that this code is alive.
I seems was needed previously but we fixed it.
If it is still needed, it needs new tests,
but for now I do not know how to trigger it,
and so I removed it.
llvm-svn: 338713
|
|
|
|
|
|
|
|
| |
Code was never executed with our test cases,
though it is valid and I think we can always run it.
This improves code coverage.
llvm-svn: 338708
|
|
|
|
|
|
|
|
|
|
|
| |
Some lit tests that call llvm-ar use the 'r' flag. If the target archive
already exists and is in a corrupt state, this can cause the test to fail. We
have added 'rm -f' calls before the llvm-ar calls to increase the
robustness of the tests.
Differential revision: https://reviews.llvm.org/D49184
llvm-svn: 338705
|
|
|
|
|
|
|
|
| |
isHeaderSection can be useful I believe,
but probably not right now and not
for this case.
llvm-svn: 338699
|
|
|
|
|
|
|
|
|
|
|
|
| |
Patch by Konstantin Schwarz!
If more than a single output section is added to a PT_LOAD header,
only the first section should set the LMAOffset of the segment.
Otherwise, we get a load-address overlap error
Differential revision: https://reviews.llvm.org/D50133
llvm-svn: 338697
|