Commit Graph

6687 Commits

Author SHA1 Message Date
Rafael Espindola be94e1b630 Move helper function higher in the file. NFC
This just makes a followup patch easier to read.

llvm-svn: 281482
2016-09-14 14:32:08 +00:00
George Rimar d73ef1738b [ELF] - Implemented --section-start, -Ttext, -Tdata, -Tbss options.
--section-start=sectionname=org
Locate a section in the output file at the absolute address given by org. 
You may use this option as many times as necessary to locate multiple sections in the command line.
 org must be a single hexadecimal integer; for compatibility with other linkers, 
you may omit the leading `0x' usually associated with hexadecimal values. 
Note: there should be no white space between sectionname, the equals sign (“<=>”), and org.

-Tbss=org
-Tdata=org
-Ttext=org
Same as --section-start, with .bss, .data or .text as the sectionname.

Differential revision: https://reviews.llvm.org/D24294

llvm-svn: 281458
2016-09-14 13:07:13 +00:00
Rafael Espindola d88d7166a8 Use murmurhash2 instead of fnv.
It is substantially faster by processing 8 bytes at a time.

llvm-svn: 281454
2016-09-14 11:32:57 +00:00
Eugene Leviant e05336ffa1 [ELF] Replace HasContents with HasSections. NFC
llvm-svn: 281449
2016-09-14 08:32:36 +00:00
Rui Ueyama 2d7fe598f2 Turn a no-op assignment into an assertion.
r279456 guarantees that this condition is always satisfied.

llvm-svn: 281426
2016-09-14 00:09:50 +00:00
Rui Ueyama 38dbd3eea9 Simplify InputFile ownership management.
Previously, all input files were owned by the symbol table.
Files were created at various places, such as the Driver, the lazy
symbols, or the bitcode compiler, and the ownership of new files
was transferred to the symbol table using std::unique_ptr.
All input files were then free'd when the symbol table is freed
which is on program exit.

I think we don't have to transfer ownership just to free all
instance at once on exit.

In this patch, all instances are automatically collected to a
vector and freed on exit. In this way, we no longer have to
use std::unique_ptr.

Differential Revision: https://reviews.llvm.org/D24493

llvm-svn: 281425
2016-09-14 00:05:51 +00:00
George Rimar 84ba4ae11d revert: [ELF] - Versionscript: support mangled symbols with the same name.
Something broked BBots:
281318 failed on step 9:
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/413

r281317 built step 9 green:
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/415

Initial revision commits were:
This is PR30312. Info from bug page:

Both of these symbols demangle to abc::abc():
_ZN3abcC1Ev
_ZN3abcC2Ev
(These would be abc's complete object constructor and base object constructor, respectively.)
however with "abc::abc()" in the version script only one of the two receives the symbol version.

Patch fixes that.
It uses testcase created by Ed Maste (D24306).

Differential revision: https://reviews.llvm.org/D24336

llvm-svn: 281411
2016-09-13 22:26:12 +00:00
Rui Ueyama 1e2e8eae5d [ELF] Set EF_ARM_EABI_VER5 for ARM
Without this flag set, an AArch64 Linux kernel won't try to load the executable
(even if a 32 bit arm kernel will run the binary just fine).

Patch by Martin Storsjö!

Differential revision: https://reviews.llvm.org/D24471

llvm-svn: 281394
2016-09-13 20:51:32 +00:00
Rui Ueyama ea26504c19 Split scanVersionScript. NFC.
llvm-svn: 281393
2016-09-13 20:51:30 +00:00
Rui Ueyama fbde710497 Add comments.
llvm-svn: 281388
2016-09-13 20:41:06 +00:00
Rui Ueyama 3e9037d419 Inline small funciton.
llvm-svn: 281381
2016-09-13 19:56:27 +00:00
Rui Ueyama a75b7a48f1 Fix comments.
llvm-svn: 281380
2016-09-13 19:56:25 +00:00
Rafael Espindola 10897f1807 Enable merging of SHF_MERGE sections with linker scripts.
This also fixes the related problem of non SHF_MERGE sections with
different flags not being merged.

Fixes pr30355.

llvm-svn: 281338
2016-09-13 14:23:14 +00:00
Rafael Espindola 28c1597ad9 Refactor duplicated code. NFC.
llvm-svn: 281329
2016-09-13 13:00:06 +00:00
Rafael Espindola 17c35832a0 Turn createKey into a static helper. NFC.
llvm-svn: 281325
2016-09-13 12:25:30 +00:00
Rafael Espindola 540893a2e2 Delete dead code.
We already handle this is createSections.

llvm-svn: 281320
2016-09-13 11:28:22 +00:00
George Rimar e2051efcbe [ELF] - Versionscript: support mangled symbols with the same name.
This is PR30312. Info from bug page:

Both of these symbols demangle to abc::abc():
_ZN3abcC1Ev
_ZN3abcC2Ev
(These would be abc's complete object constructor and base object constructor, respectively.)
however with "abc::abc()" in the version script only one of the two receives the symbol version.

Patch fixes that.
It uses testcase created by Ed Maste (D24306).

Differential revision: https://reviews.llvm.org/D24336

llvm-svn: 281318
2016-09-13 10:45:39 +00:00
Chris Bieneman 5a805df1a5 [CMake] Fix linker-as-ld to symlink instead of copy lld
Summary: This test fails if you're building with BUILD_SHARED_LIBS because the LLVM libraries are found via @rpath. Symlinking instead of copying should be sufficiently robust for the test case.

Reviewers: llvm-commits

Subscribers: davide

Differential Revision: https://reviews.llvm.org/D24476

llvm-svn: 281271
2016-09-12 22:38:43 +00:00
Rui Ueyama 0eb2a1bd7a Add comments.
llvm-svn: 281265
2016-09-12 21:44:29 +00:00
Davide Italiano f6c1d2c158 [MachO] Factor out a fair amount of duplicated code. NFCI.
llvm-svn: 281260
2016-09-12 21:07:26 +00:00
Davide Italiano 3582242aa3 [Cmake] Use Cmake's default RPATH for unittest.
Similarly to what was done in r280791 for llvm/.
This should fix a bunch of failures I saw while
trying a BUILD_SHARED_LIBS build on MacOS.
Still there are some failures, but this is a step
forward.

Thanks a lot to Chris Bieneman for the suggested
fix (in PR30345)

llvm-svn: 281256
2016-09-12 20:44:53 +00:00
Rafael Espindola 7bd37870bc Simplify handling of /DISCARD/. NFC.
llvm-svn: 281222
2016-09-12 16:05:16 +00:00
Rafael Espindola c7e1e03498 Store an ArrayRef for Data in InputSectionData.
llvm-svn: 281210
2016-09-12 13:13:53 +00:00
Rafael Espindola 54f1614ec1 Revert "Revert "Compact InputSectionData from 64 to 48 bytes. NFC.""
This reverts commit r281096.

The previous link errors should be fixed by r281208.

llvm-svn: 281209
2016-09-12 13:06:10 +00:00
Eugene Leviant 99da752980 [ELF/AArch64] Implement some UABS relocs
Differential revision: https://reviews.llvm.org/D24403

llvm-svn: 281202
2016-09-12 10:02:41 +00:00
Davide Italiano 35065193f1 [MachO] Remove code accidentally cut'n'pasted 3 times.
It wasn't harmful, just goofy. It's weird to see how this has
fallen through the crack without anybody noticing for so long.

llvm-svn: 281148
2016-09-10 20:41:26 +00:00
Michael J. Spencer 0cb8a70adc [ELF] Fix memory leak in BinaryFile handling.
llvm-svn: 281129
2016-09-10 01:42:43 +00:00
Hans Wennborg efcc5c4390 Move the contents of test/elf to test/ELF
Having two directories with the same name modulo case does not work well
on Windows. The new test/elf directory was added in r281108. I assume
the intention was to add the test file to the existing test/ELF dir.

llvm-svn: 281115
2016-09-09 22:46:16 +00:00
Michael J. Spencer a9424f39c4 [ELF] Add support for -b binary
Implemented by building an ELF file in memory.

elf, default, and binary match gold behavior.

Differential Revision: https://reviews.llvm.org/D24060

llvm-svn: 281108
2016-09-09 22:08:04 +00:00
Rui Ueyama 478f8eb6ef Add comments.
llvm-svn: 281098
2016-09-09 21:35:38 +00:00
Rafael Espindola 78fe670994 Revert "Compact InputSectionData from 64 to 48 bytes. NFC."
This reverts commit r281084.

The link was failing on some bots. No idea why. I will try to
reproduce it on Monday.

llvm-svn: 281096
2016-09-09 21:20:30 +00:00
Rafael Espindola 82621dcb10 Compact InputSectionData from 64 to 48 bytes. NFC.
llvm-svn: 281084
2016-09-09 19:42:11 +00:00
Saleem Abdulrasool c1b5f19262 test: adjust the GUID
Although the GUID seems to be stable across test runs now, it seems to be
unstable across hosts.  Lets be a bit more lax about the reading of the RSDS
record.

llvm-svn: 281083
2016-09-09 19:41:46 +00:00
Saleem Abdulrasool 88f6407542 COFF: make builds more reproducible
Change the way we calculate the build id to use MD5 to give reproducible build
ids. Previously we would generate random bytes for the build id GUID.

llvm-svn: 281079
2016-09-09 19:26:03 +00:00
George Rimar cd574a5e46 Recommit [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.
Fixed code that was not checked before on windows for me, because of testcases that are
disabled on that platform atm.

Inital commit message:
"[ELF] - Versionscript: do not treat non-wildcarded names as wildcards."
Previously we incorrectly handled cases when symbol name in extern c++ tag
was enclosed in quotes. Next case was treated as wildcard:

GLIBCXX_3.4 {                                                                   
    extern "C++" {  
    "aaa*"
   }
But it should have not. Quotes around aaa here means that we should have do exact
name matching.
That is PR30268 which has name with pointer is interpreted as wildcard by lld:

extern "C++" {                                                              
    "operator delete[](void*)";

Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D24229

llvm-svn: 281049
2016-09-09 14:35:36 +00:00
George Rimar 6368525eea Revert r281045, it broke BB.
Broken BB:
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/27211

llvm-svn: 281046
2016-09-09 14:16:00 +00:00
George Rimar b5e77c47fb Recommit [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.
Fixed code that was not checked by testcases that are disabled on windows.

Inital commit message:
"[ELF] - Versionscript: do not treat non-wildcarded names as wildcards."
Previously we incorrectly handled cases when symbol name in extern c++ tag
was enclosed in quotes. Next case was treated as wildcard:

GLIBCXX_3.4 {                                                                   
    extern "C++" {  
    "aaa*"
   }
But it should have not. Quotes around aaa here means that we should have do exact
name matching.
That is PR30268 which has name with pointer is interpreted as wildcard by lld:

extern "C++" {                                                              
    "operator delete[](void*)";

Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D24229

llvm-svn: 281045
2016-09-09 13:58:07 +00:00
George Rimar 08b1862caf [ELF] - Revert r281038 to see if that unbreaks build bot.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/19703

llvm-svn: 281041
2016-09-09 12:56:55 +00:00
George Rimar d220384376 [ELF] - Versionscript: do not treat non-wildcarded names as wildcards.
Previously we incorrectly handled cases when symbol name in extern c++ tag
was enclosed in quotes. Next case was treated as wildcard:

GLIBCXX_3.4 {                                                                   
    extern "C++" {  
    "aaa*"
   }
But it should have not. Quotes around aaa here means that we should have do exact
name matching.
That is PR30268 which has name with pointer is interpreted as wildcard by lld:

extern "C++" {                                                              
    "operator delete[](void*)";

Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D24229

llvm-svn: 281038
2016-09-09 12:22:28 +00:00
Eugene Leviant 56b21c869e Linker script: implement AT [ (address) ] for PHDR
Differential revision: https://reviews.llvm.org/D24340

llvm-svn: 281024
2016-09-09 09:46:16 +00:00
Rui Ueyama a60058c8f5 Fix -output option.
Usually, options that are longer than one character can be preceded
either by "-" or "--", but options starting with "o" are exceptions
because they conflict with "-o" option. They have to be preceded by
"--".

llvm-svn: 281004
2016-09-09 00:25:56 +00:00
Rui Ueyama 86c5fb8296 Fix bug in -nostdlib.
We still have to skip a token inside SEARCH_DIR() when -nostdlib is
specified. Previuosly, we didn't skip it, so it caused a parse error.

llvm-svn: 281001
2016-09-08 23:26:54 +00:00
Rui Ueyama c442cff96e Define writeUint and use it. NFC.
llvm-svn: 280994
2016-09-08 21:46:21 +00:00
Davide Italiano e02ba98f8f [ELF] Fix DT_NEEDED value.
Differential Revision: https://reviews.llvm.org/D24363

llvm-svn: 280990
2016-09-08 21:18:38 +00:00
Ed Maste e349b6da2c ELF: clarify error when we don't know the output format
lld differs from GNU ld in that it does not have a built-in default
target emulation. Emulation is always specified via the -m option, or
obtained from the object file(s) being linked. In most cases at least
one ELF object is included in the link, so the emulation is known.

When using lld's (not yet committed) -b binary support with -r, to
convert a binary file into an ELF object we do not have a known
emulation. The error message previously emitted in this case
"-m or at least a .o file required" is accurate but does not offer
much insight. Add text to the error message to give a hint why -m or an
object file is required.

Differential Revision:	https://reviews.llvm.org/D24348

llvm-svn: 280989
2016-09-08 21:06:29 +00:00
Rafael Espindola c0028d3d3b Reduce templating. NFC.
llvm-svn: 280986
2016-09-08 20:47:52 +00:00
Rui Ueyama 881406e787 Define '-undefined foo' as an alias to '-undefined=foo'.
llvm-svn: 280985
2016-09-08 20:35:29 +00:00
Ed Maste 2b68ada188 ELF: Report original emulation name in "unknown emulation" error
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-09-08 19:36:22 +00:00
Ed Maste 21e2be6403 ELF: accept -m elf_amd64 as an alias for -m elf_x86_64
In the FreeBSD world x86_64 still has its original name, amd64. Accept
it as an alias.

Differential Revision:	https://reviews.llvm.org/D24356

llvm-svn: 280982
2016-09-08 19:30:47 +00:00
Rafael Espindola 868fc9279e Handle globs in global symbol names.
Fixes pr28775.

llvm-svn: 280947
2016-09-08 14:50:55 +00:00