summaryrefslogtreecommitdiff
path: root/lld/test/ELF/basic.s
AgeCommit message (Collapse)Author
2025-01-25[ELF,test] Add env LLD_IN_TEST=1 to make some tests work if RUN_LLD_MAIN_TWICEFangrui Song
2022-11-07[lld] Check errors from expanding response filesHans Wennborg
Previously the response file expansion code would print the error, but lld would not exit, which was odd. lld does response file expansion in the different drivers, but it's also done in main() first, so it's enough to check there. By checking for these errors we would have caught when D136090 introduced a bug that made lld print errors for response files which contained "-rpath @foo". Differental revision: https://reviews.llvm.org/D137477
2022-11-07Use double hashes for non-run/check lines in lld/test/ELF/basic.sHans Wennborg
2021-01-29[test] Use host platform specific error message substitution in lit testsAbhina Sreeskantharajan
On z/OS, the following error message is not matched correctly in lit tests. ``` EDC5129I No such file or directory. ``` This patch uses a lit config substitution to check for platform specific error messages. Reviewed By: muiez, jhenderson Differential Revision: https://reviews.llvm.org/D95246
2021-01-25Revert "[SystemZ][z/OS] Fix No such file or directory expression error"Abhina Sreeskantharajan
This reverts commit 06f8a49693957bc27b83e0ab5f429ff874941a07.
2021-01-18[SystemZ][z/OS] Fix No such file or directory expression error matching in ↵Abhina Sreeskantharajan
lit tests On z/OS, the following error message is not matched correctly in lit tests. This patch updates the CHECK expression to match successfully. ``` EDC5129I No such file or directory. ``` Reviewed By: muiez Differential Revision: https://reviews.llvm.org/D94239
2020-03-27[ELF][test] Split basic.sFangrui Song
2020-03-27[ThinLTO] Allow usage of all hardware threads in the systemAlexandre Ganea
Before this patch, it wasn't possible to extend the ThinLTO threads to all SMT/CMT threads in the system. Only one thread per core was allowed, instructed by usage of llvm::heavyweight_hardware_concurrency() in the ThinLTO code. Any number passed to the LLD flag /opt:lldltojobs=..., or any other ThinLTO-specific flag, was previously interpreted in the context of llvm::heavyweight_hardware_concurrency(), which means SMT disabled. One can now say in LLD: /opt:lldltojobs=0 -- Use one std::thread / hardware core in the system (no SMT). Default value if flag not specified. /opt:lldltojobs=N -- Limit usage to N threads, regardless of usage of heavyweight_hardware_concurrency(). /opt:lldltojobs=all -- Use all hardware threads in the system. Equivalent to /opt:lldltojobs=$(nproc) on Linux and /opt:lldltojobs=%NUMBER_OF_PROCESSORS% on Windows. When an affinity mask is set for the process, threads will be created only for the cores selected by the mask. When N > number-of-hardware-threads-in-the-system, the threads in the thread pool will be dispatched equally on all CPU sockets (tested only on Windows). When N <= number-of-hardware-threads-on-a-CPU-socket, the threads will remain on the CPU socket where the process started (only on Windows). Differential Revision: https://reviews.llvm.org/D75153
2020-03-04[llvm-readelf] Make --all output order closer to GNU readelfFangrui Song
https://bugs.llvm.org/show_bug.cgi?id=43403 The new order makes it easy to compare the two tools' --all. Reviewed By: grimar, rupprecht Differential Revision: https://reviews.llvm.org/D75592
2020-02-12[ELF][test] Change -o %t to -o /dev/null if the output is not neededFangrui Song
2019-09-16[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64Fangrui Song
Port the D64906 technique to EM_X86_64. Differential Revision: https://reviews.llvm.org/D67482 llvm-svn: 371958
2019-08-01[ELF] Add -z separate-code and pad the last page of last PF_X PT_LOAD with ↵Fangrui Song
traps only if -z separate-code is specified This patch 1) adds -z separate-code and -z noseparate-code (default). 2) changes the condition that the last page of last PF_X PT_LOAD is padded with trap instructions. Current condition (after D33630): if there is no `SECTIONS` commands. After this change: if -z separate-code is specified. -z separate-code was introduced to ld.bfd in 2018, to place the text segment in its own pages. There is no overlap in pages between an executable segment and a non-executable segment: 1) RX cannot load initial contents from R or RW(or non-SHF_ALLOC). 2) R and RW(or non-SHF_ALLOC) cannot load initial contents from RX. lld's current status: - Between R and RX: in `Writer<ELFT>::fixSectionAlignments()`, the start of a segment is always aligned to maxPageSize, so the initial contents loaded by R and RX do not overlap. I plan to allow overlaps in D64906 if -z noseparate-code is in effect. - Between RX and RW(or non-SHF_ALLOC if RW doesn't exist): we currently unconditionally pad the last page to commonPageSize (defaults to 4096 on all targets we support). This patch will make it effective only if -z separate-code is specified. -z separate-code is a dubious feature that intends to reduce the number of ROP gadgets (which is actually ineffective because attackers can find plenty of gadgets in the text segment, no need to find gadgets in non-code regions). With the overlapping PT_LOAD technique D64906, -z noseparate-code removes two more alignments at segment boundaries than -z separate-code. This saves at most defaultCommonPageSize*2 bytes, which are significant on targets with large defaultCommonPageSize (AArch64/MIPS/PPC: 65536). Issues/feedback on alignment at segment boundaries to help understand the implication: * binutils PR24490 (the situation on ld.bfd is worse because they have two R-- on both sides of R-E so more alignments.) * In binutils, the 2018-02-27 commit "ld: Add --enable-separate-code" made -z separate-code the default on Linux. https://github.com/richfelker/musl-cross-make/commit/d969dea983a2cc54a1e0308a0cdeb6c3307e4bfa In musl-cross-make, binutils is configured with --disable-separate-code to address size regressions caused by -z separate-code. (lld actually has the same issue, which I plan to fix in a future patch. The ld.bfd x86 status is worse because they default to max-page-size=0x200000). * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237676 people want smaller code size. This patch will remove one alignment boundary. * Stef O'Rear: I'm opposed to any kind of page alignment at the text/rodata line (having a partial page of text aliased as rodata and vice versa has no demonstrable harm, and I actually care about small systems). So, make -z noseparate-code the default. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64903 llvm-svn: 367537
2019-05-14[LLD][ELF] Add the -z ifunc-noplt optionFangrui Song
Patch by Mark Johnston! Summary: When the option is configured, ifunc calls do not go through the PLT; rather, they appear as regular function calls with relocations referencing the ifunc symbol, and the resolver is invoked when applying the relocation. This is intended for use in freestanding environments where text relocations are permissible and is incompatible with the -z text option. The option is motivated by ifunc usage in the FreeBSD kernel, where ifuncs are used to elide CPU feature flag bit checks in hot paths. Instead of replacing the cost of a branch with that of an indirect function call, the -z ifunc-noplt option is used to ensure that ifunc calls carry no hidden overhead relative to normal function calls. Test Plan: I added a couple of regression tests and tested the FreeBSD kernel build using the latest lld sources. To demonstrate the effects of the change, I used a micro-benchmark which results in frequent invocations of a FreeBSD kernel ifunc. The benchmark was run with and without IBRS enabled, and with and without -zifunc-noplt configured. The observed speedup is small and consistent, and is significantly larger with IBRS enabled: https://people.freebsd.org/~markj/ifunc-noplt/noibrs.txt https://people.freebsd.org/~markj/ifunc-noplt/ibrs.txt Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D61613 llvm-svn: 360685
2019-05-07Add typo correction for command-line flags to ELF and COFF lld driversNico Weber
For lld-link, unknown '/'-style flags are treated as filenames on POSIX systems, so only '-'-style flags get typo correction for now. This matches clang-cl. PR37006. Differential Revision: https://reviews.llvm.org/D61443 llvm-svn: 360145
2019-05-01[test] Change llvm-readobj -long-option to --long-option or well-known short ↵Fangrui Song
options. NFC Also change some options that have different semantics (cause confusion) in llvm-readelf mode: -s => -S -t => --symbols -sd => --section-data llvm-svn: 359651
2017-11-15Propagate sh_entsize out.Rafael Espindola
No difference in practice other than having sh_entsize in the output. This should simplify the patch for handling SHF_MERGE in -r. Based on a patch by George Rimar. llvm-svn: 318306
2017-09-01[ELF] Set p_memsz to p_filesz when aligning the last segment to page boundaryPetr Hosek
Having p_filesz different from p_memsz is confusing some tools. Differential Revision: https://reviews.llvm.org/D37369 llvm-svn: 312384
2017-08-14[ELF] - LTO: Try to be option compatible with the gold plugin.George Rimar
This is relative to PR30720. Previously we ignored all --plugin-opt arguments. Patch adds support for them. Patch does not add any new LTO options, and just implements mapping from --plugin-opt to existent ones. Differential revision: https://reviews.llvm.org/D36227 llvm-svn: 310826
2017-08-02[ELF] When the code segment is the last, align it to the page boundaryPetr Hosek
When the data segment is the last segment, it is correct to leave it unaligned. However, when the code segment is the last segment, it should be aligned to the page boundary to avoid loading the non-segment parts of the ELF file at the end of the file. Differential Revision: https://reviews.llvm.org/D33630 llvm-svn: 309829
2017-03-31Change the error message format for duplicate symbols.Rui Ueyama
This patch is intended to improve readability of "duplicate symbol" error messages. Without this patch: /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Relocations.cpp:1054: duplicate symbol 'lld::elf::demangle(llvm::StringRef)' /ssd/clang/bin/ld.lld: error: /ssd/llvm-project/lld/ELF/Strings.cpp:93: previous definition was here With this patch: /ssd/clang/bin/ld.lld: error: duplicate symbol: lld::elf::demangle(llvm::StringRef) >>> defined at Strings.cpp:93 (/ssd/llvm-project/lld/ELF/Strings.cpp:93) >>> Strings.cpp.o:(lld::elf::demangle(llvm::StringRef)) in archive lib/liblldELF.a >>> defined at Relocations.cpp:1054 (/ssd/llvm-project/lld/ELF/Relocations.cpp:1054) >>> Relocations.cpp.o:(.text+0x4C30) in archive lib/liblldELF.a Discussion thread: http://lists.llvm.org/pipermail/llvm-dev/2017-March/111459.html Differential Revision: https://reviews.llvm.org/D31507 llvm-svn: 299280
2017-02-03Stop propagating Entsize.Rafael Espindola
Now that we combine multiple synthetic merge section into one output section there is no point in trying to propagate a value. llvm-svn: 294048
2017-01-09Support non-regular output files.Rui Ueyama
This patch enables something like "-o /dev/null". Previouly, it failed because such files cannot be renamed. Differential Revision: https://reviews.llvm.org/D28010 llvm-svn: 291496
2016-11-23lld: Default image base address to 0x200000 on x86-64Ed Maste
Align to the large page size (known as a superpage or huge page). FreeBSD automatically promotes large, superpage-aligned allocations. Differential Revision: https://reviews.llvm.org/D27042 llvm-svn: 287782
2016-11-21Change the way how we print out line numbers.Rui Ueyama
LLD's error messages contain line numbers, function names or section names. Currently they are formatter as follows. foo.c (32): symbol 'foo' not found foo.c (function bar): symbol 'foo' not found foo.c (.text+0x1234): symbol 'foo' not found This patch changes them so that they are consistent with Clang's output. foo.c:32: symbol 'foo' not found foo.c:(function bar): symbol 'foo' not found foo.c:(.text+0x1234): symbol 'foo' not found Differential Revision: https://reviews.llvm.org/D26901 llvm-svn: 287537
2016-11-19Simplify "missing argument" error message.Rui Ueyama
We do not have an option taking more than one arguments, so we can just say "missing argument" instead of "missing argument(s)". llvm-svn: 287454
2016-11-10Include version string into ".comment" section.Rui Ueyama
Summary: This patch adds a ".comment" section to an output. The comment section contains the linker's version string. You can now find out whether a binary is created by LLD or not using objdump command like this. $ objdump -s -j .comment foo foo: file format elf64-x86-64 Contents of section .comment: 0000 00474343 3a202855 62756e74 7520342e .GCC: (Ubuntu 4. 0010 382e342d 32756275 6e747531 7e31342e 8.4-2ubuntu1~14. ... 00c0 766d2f74 72756e6b 20323835 38343629 vm/trunk 285846) 00d0 004c696e 6b65723a 204c4c44 20342e30 .Linker: LLD 4.0 00e0 2e302028 7472756e 6b203238 36343036 .0 (trunk 286406 00f0 2900 ). Compilers emits .comment section as well, so the output contains both compiler and linker information. Alternative considered: I first tried to add a SHT_NOTE section because GNU gold does that. A NOTE section starts with a header which contains content type. It turned out that ld.gold sets type NT_GNU_GOLD_VERSION to their NOTE section. So the NOTE type is only for GNU gold (surprise!) Next, I tried to create ".linker-version" section. However, it seems that reusing the existing ".comment" section is better because 1) other tools already know about .comment section and is able to strip it and 2) the result contans not only linker info but also compiler info. Differential Revision: https://reviews.llvm.org/D26487 llvm-svn: 286496
2016-11-08[ELF] Better error reporting for duplicate symbolEugene Leviant
Differential revision: https://reviews.llvm.org/D26397 llvm-svn: 286244
2016-11-01Remove string table offsets from tests.Rui Ueyama
<N> where "foo (<N>)" is the offset of string "foo" in the string table. llvm-svn: 285751
2016-10-19Include ARGV[0] in error messages.Rui Ueyama
This is what other linkers and clang driver do. Differential Revision: https://reviews.llvm.org/D25780 llvm-svn: 284634
2016-10-19Remove ending "." from an error message.Rui Ueyama
Other error messages don't end with ".". llvm-svn: 284625
2016-10-10[LTO] Split the options for ThinLTO jobs and Regular LTO partitionsDavide Italiano
Differential Revision: https://reviews.llvm.org/D25452 llvm-svn: 283817
2016-09-08ELF: Report original emulation name in "unknown emulation" errorEd Maste
A trailing _fbsd is stripped from emulation names, but if the result was still not a valid emulation the error was somewhat confusing. For example, % ld.lld -m elf_amd64_fbsd unknown emulation: elf_amd64 Use the original emulation name in error messages. Differential Revision: https://reviews.llvm.org/D24357 llvm-svn: 280983
2016-07-06[ELF] Introduce a flag to parse response files according to windows rules.Davide Italiano
Differential Revision: http://reviews.llvm/org/D22015 llvm-svn: 274684
2016-04-27Remove unnecessary trailing semicolons.Rui Ueyama
Since this semicolon existed in an early test file, it has spread to many files. llvm-svn: 267659
2016-04-15[LTO] Implement parallel Codegen for LTO using splitCodeGen.Davide Italiano
Parallelism level can be chosen using the new --lto-jobs=K option where K is the number of threads used for CodeGen. It currently defaults to 1. llvm-svn: 266484
2016-03-12Recommit of r263252, [ELF] - Change all messages to lowercase to be consistent.George Rimar
which was reverted because included unrelative changes by mistake. Original commit message: [ELF] - Change all messages to lowercase to be consistent. That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263337
2016-03-11Revert r263252: "[ELF] - Change all messages to lowercase to be consistent."Rui Ueyama
This reverts commit r263252 because the change contained unrelated changes. llvm-svn: 263272
2016-03-11[ELF] - Change all messages to lowercase to be consistent.George Rimar
That is directly opposite to http://reviews.llvm.org/D18045, which was reverted. This patch changes all messages to start from lowercase letter if they were not before. That is done to be consistent with clang. Differential revision: http://reviews.llvm.org/D18085 llvm-svn: 263252
2016-03-11This reverts the r263125George Rimar
It was discussed to make all messages be lowercase to be consistent with clang. (also reverts the r263128 which fixed build bot fail after r263125) Original commit message: [ELF] - Consistent spelling for error/warning messages Previously error and warnings were not consistent in lld. Some of them started from lowercase letter, others from uppercase. Also there was one or two which had a dot at the end. This patch changes all messages to start from uppercase letter if they were not before. Differential revision: http://reviews.llvm.org/D18045 llvm-svn: 263240
2016-03-10[ELF] - Consistent spelling for error/warning messagesGeorge Rimar
Previously error and warnings were not consistent in lld. Some of them started from lowercase letter, others from uppercase. Also there was one or two which had a dot at the end. This patch changes all messages to start from uppercase letter if they were not before. Differential revision: http://reviews.llvm.org/D18045 llvm-svn: 263125
2016-01-07ELF: Improve performance of string table construction.Rui Ueyama
String tables in unstripped executable files are fairly large in size. For example, lld's executable file is about 34.4 MB in my environment, and of which 3.5 MB is the string table. Efficiency of string table construction matters. Previously, the string table was built in an inefficient way. We used StringTableBuilder to build that and enabled string tail merging, although tail merging is not effective for the symbol table (you can only make the string table 0.3% smaller for lld.) Tail merging is computation intensive task and slow. This patch eliminates string tail merging. I changed the way of adding strings to the string table in this patch too. Previously, strings were added using add() and the same strings were then passed to getOffset() to get their offsets in the string table. In this way, getOffset() needs to look up a hash table to get offsets for given strings. This is a violation of "we look up the symbol table (or a hash table) only once for each symbol" dogma of the new LLD's design. Hash table lookup for long C++ mangled names is slow. I eliminated that lookup in this patch. In total, this patch improves link time of lld itself about 12% (3.50 seconds -> 3.08 seconds.) llvm-svn: 257017
2015-11-24Revert "ELF: Make .note.GNU-stack more compatible with traditional linkers."Rui Ueyama
This reverts commit r253797 because it was based on a misunderstanding that lld wouldn't work on NetBSD without this change. llvm-svn: 254003
2015-11-21ELF: Make .note.GNU-stack more compatible with traditional linkers.Rui Ueyama
With this patch, lld creates PT_GNU_STACK segments only when all input files have .note.GNU-stack sections. This is in line with other linkers with a minor difference (we don't care about .note.GNU-stack rwx bits as you can always remove .note.GNU-stack sections instead of setting x bit.) At least, NetBSD loader does not understand PT_GNU_STACK segments and reject any executables that have the section. This patch makes lld compatible with such operating systems. llvm-svn: 253797
2015-11-18Rename ld.lld2 to ld.lld since it is the default.Rafael Espindola
llvm-svn: 253437
2015-11-17Rename test/elf2 to test/ELF.Rafael Espindola
llvm-svn: 253313