Commit Graph

10446 Commits

Author SHA1 Message Date
Rui Ueyama efe9af9f07 Rename NonLocal -> Global.
NonLocal is technically more accurate, but we already use the term
"Global" to specify the non-local part of the symbol table, and
Local <-> Global is easier to digest.

llvm-svn: 328740
2018-03-28 22:55:40 +00:00
Rui Ueyama 6a1ca2627a Move code so that the code matches with a comment. NFC.
llvm-svn: 328739
2018-03-28 22:47:53 +00:00
Rafael Espindola c8f774b393 Strip @VER suffices from the LTO output.
This fixes pr36623.

The problem is that we have to parse versions out of names before LTO
so that LTO can use that information.

When we get the LTO produced .o files, we replace the previous symbols
with the LTO produced ones, but they still have @ in their names.

We could just trim the name directly, but calling parseSymbolVersion
to do it is simpler.

llvm-svn: 328738
2018-03-28 22:45:39 +00:00
Rui Ueyama 2ce7401505 Unloop a for-loop so that we can comment on each symbol. NFC.
llvm-svn: 328736
2018-03-28 22:09:40 +00:00
Rui Ueyama e86c7956d6 Merge nested "if"s. NFC.
llvm-svn: 328733
2018-03-28 21:53:10 +00:00
Peter Collingbourne cebab4a639 ELF: Make required Thunk methods pure virtual and remove an unused argument. NFC.
Also make certain Thunk methods non-const as this will be required for
an upcoming change.

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

llvm-svn: 328732
2018-03-28 21:33:31 +00:00
Nicholas Wilson fc90b30dc2 [WebAssembly] Name Config members after commandline argument. NFC
This addresses a late review comment from D44427/rLLD328643

llvm-svn: 328700
2018-03-28 12:53:29 +00:00
George Rimar fd11560f6e [ELF] - Linkerscript: support MIN and MAX.
Sample for the OVERLAY command from the spec 
(https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html)
uses MAX command that we do not support currently:

. = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));

This patch implements support for MIN and MAX.

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

llvm-svn: 328696
2018-03-28 11:33:00 +00:00
Rafael Espindola 816127ea17 Initialize OffsetMap in a known location.
This is a small optimization and avoids the need to use call_once.

llvm-svn: 328686
2018-03-28 03:20:18 +00:00
Rafael Espindola 92eba0e14a Define a trivial method inline.
llvm-svn: 328685
2018-03-28 03:14:11 +00:00
Rafael Espindola 5a7ca96e2d Store live offsets as uint32_t.
We don't support input merge sections larger than 4gb, so these can be
uint32_t.

llvm-svn: 328684
2018-03-28 02:32:31 +00:00
Fangrui Song 2458863e28 [ELF] Fix offsets in comment of tls-got.s
llvm-svn: 328679
2018-03-28 00:03:21 +00:00
Nicholas Wilson 874eedd779 [WebAssembly] Add export/import for function pointer table
This enables callback-style programming where the JavaScript environment
can call back into the Wasm environment using a function pointer
received from the module.

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

llvm-svn: 328643
2018-03-27 17:38:51 +00:00
Rafael Espindola 35aad41c1b Force SHF_MERGE optimizations with -r.
Some tools (dwarfdump for example) get confused by the current -O0 -r
output since it has multiple copies of .debug_str.

We cannot just merge sections with the same name as they can have
different sh_entsize.

We could have duplicated logic for merging sections based on name and
sh_entsize, but it seems better to just use the existing logic by
enabling optimizations.

llvm-svn: 328640
2018-03-27 17:09:23 +00:00
Rafael Espindola 22458ea7aa Add a passing test.
I noticed that we were not testing this while working on another patch.

llvm-svn: 328631
2018-03-27 16:10:01 +00:00
Andrew Ng ae0a7735b9 [ELF] Disable ICF for synthetic sections
The Data member of synthetic section's is not valid and empty. The Data
member is required to be valid by ICF as it is used by ICF to determine
the equality of section contents. Therefore, exclude synthetic sections
from ICF.

Fixes bug PR36910.

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

llvm-svn: 328624
2018-03-27 14:10:07 +00:00
Bob Haarman 3ddeb33e00 [lld] fix data race in ICF.cpp
Summary: Fixes PR36823.

Reviewers: ruiu, pcc, rnk

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 328610
2018-03-27 06:08:35 +00:00
Rui Ueyama bc0d3b4e0f Remove extraneous local variable. NFC.
llvm-svn: 328605
2018-03-27 02:53:08 +00:00
Rui Ueyama b3e2f74517 Update comments.
llvm-svn: 328604
2018-03-27 02:52:58 +00:00
David Blaikie ddcd856147 Fix for header rename in LLVM
llvm-svn: 328594
2018-03-26 23:43:29 +00:00
Rui Ueyama b391288af7 Refactor SharedFile::parseRest. NFC.
SharedFile::parseRest function grew organically and got a bit hard to
understand. This patch refactor it. This patch also adds comments.

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

llvm-svn: 328579
2018-03-26 19:57:38 +00:00
Rafael Espindola 9c2c938521 Reduce code duplication a bit.
Thanks to George Rimar for pointing it out.

llvm-svn: 328571
2018-03-26 18:55:33 +00:00
Rafael Espindola f065390f6c Reduce code duplication a bit. NFC
llvm-svn: 328569
2018-03-26 18:49:31 +00:00
Zaara Syeda c65ae14766 [ELF] GotSection increment NumEntries when Target saves GlobalOffsetTable in the .got
When the target saves ElfSym::GlobalOffsetTable in the .got rather than
.got.plt, Target->GotHeaderEntriesNum states the number of extra entries
required in the .got. Rather than having to add Target->GotHeaderEntriesNum to
NumEntries in every function which refers to NumEntries, this patch changes the
initial value of NumEntries in the constructor.

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

llvm-svn: 328559
2018-03-26 17:50:52 +00:00
George Rimar a6ce78ece1 This is PR36799.
Currently, we might have a bug with scripts like below:

.foo : ALIGN(8) 
{
  *(.foo)
} > ram
because do not expand the memory region when doing ALIGN.

This might result in file range overlaps. The patch fixes the issue.

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

llvm-svn: 328479
2018-03-26 08:58:16 +00:00
George Rimar d8281379f9 [ELF] - Do not ignore discarding of .rela.plt/.rela.dyn, allow doing custom layout for them.
Currently when we build input sections list in linker script
we ignore all rel[a] sections. That was done to support
scripts like .rela.dyn : { *(.rela.data) } for emit relocs.

Though as a result following scripts were also silently ignored:

/DISCARD/ : { *(.rela.plt)
/DISCARD/ : { *(.rela.dyn)

and we produced output with this sections. That is not ideal.
The solution this patch suggests is simple: do not ignore synthetic
rel[a] sections. That way we can enable common discarding logic
for them and report a proper error.

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

llvm-svn: 328419
2018-03-24 13:10:19 +00:00
Rafael Espindola 4f058a2c6b Add a SectionBase::getVA helper. NFC.
There were a few too many places duplicating this.

llvm-svn: 328402
2018-03-24 00:35:11 +00:00
Rui Ueyama d37c33aff2 Do not add a dummy entry to SharedFile::Verdefs. NFC.
Previously, we used 0 as an alias for VER_NDX_GLOBAL and had a dummy
entry in SharedFile::Verdefs so that the access to the array is within
its boundary. But that's not straightforwad. We can just stop doing both.

llvm-svn: 328401
2018-03-24 00:25:24 +00:00
Rafael Espindola 4bb482eeac Move a Repl access.
Since SectionBase::getOutputSection handles ICF replaces and
SectionBase::getOffset was handling it in some cases, it is more
consistent to have getOffset always handle it.

llvm-svn: 328391
2018-03-23 23:55:49 +00:00
Rafael Espindola 4e82a9e2fa Drop redundant ->Repl.
SectionBase::getOutputSection handles replacement sections, so this
code doesn't have to.

llvm-svn: 328390
2018-03-23 23:53:01 +00:00
Rui Ueyama bd63adcb26 Remove "FIXME" from a comment.
A bug in BFD linker is not our FIXME item.

llvm-svn: 328381
2018-03-23 22:48:17 +00:00
Zachary Turner f228276262 [PDB] Resubmit "Support embedding natvis files in PDBs."
This was reverted several times due to what ultimately turned out
to be incompatibilities in our serialized hash table format.

Several changes went in prior to this to fix those issues since
they were more fundamental and independent of supporting injected
sources, so now that those are fixed this change should hopefully
pass.

llvm-svn: 328363
2018-03-23 19:57:25 +00:00
Zachary Turner a6fb536e5b [PDB] Make our PDBs look more like MS PDBs.
When investigating bugs in PDB generation, the first step is
often to do the same link with link.exe and then compare PDBs.

But comparing PDBs is hard because two completely different byte
sequences can both be correct, so it hampers the investigation when
you also have to spend time figuring out not just which bytes are
different, but also if the difference is meaningful.

This patch fixes a couple of cases related to string table emission,
hash table emission, and the order in which we emit strings that
makes more of our bytes the same as the bytes generated by MS PDBs.

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

llvm-svn: 328348
2018-03-23 18:43:39 +00:00
Rafael Espindola 4376cffb57 Add a minimal fix for PR36878.
When looking for the output section and the output offset the
expectation was that the caller had looked at Repl. That works fine
for InputSections, but in the case of MergeInputSections the caller
doesn't have the section that is actually replaced.

The original testcase was failing because getOutputSection was
returning null. The slightly extended testcase also checks that
getOffset also checks Repl.

I will send a refactoring separetelly.

llvm-svn: 328332
2018-03-23 17:19:18 +00:00
George Rimar 16f11462ce [ELF] - Simplify. NFC.
llvm-svn: 328319
2018-03-23 14:43:51 +00:00
George Rimar 54634f1990 [ELF] - Another fix for "LLD crashes with --emit-relocs when trying to proccess .eh_frame"
This fixes PR36367 which is about segfault when --emit-relocs is
used together with .eh_frame sections which happens because
of reordering of regular and .rel[a] sections.

Path changes loop that iterates over input sections to create
relocation target sections first.

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

llvm-svn: 328299
2018-03-23 09:18:31 +00:00
Rafael Espindola 85e77b26be Fix the MSVC build.
llvm-svn: 328285
2018-03-23 00:42:47 +00:00
Rafael Espindola 3c3ebcc5f4 Fix PR36793.
With this patch lld will iterate over compile units to find the line
tables instead of assuming there is only one at offset 0.

llvm-svn: 328284
2018-03-23 00:35:27 +00:00
Rafael Espindola 0164d11b04 Fix Address Size in test.
This is an i386 test, so it should be 4.

llvm-svn: 328223
2018-03-22 17:46:57 +00:00
Rafael Espindola 78fad32d83 Make the debug info in some tests more realistic.
Currently lld just parses the .debug_line section assuming that there
is only one compile unit. That assumption is false (PR36793).

I have a patch that changes lld to iterate over the compile units and
parse the portions of the .debug_line they point to (which fixes
PR36793).

A problem is that we will then need a compiler unit pointing to
.debug_line for lld to see it.

It seems like bfd has the same restriction.

This patch updates existing tests to add a minimal compile unit so
that they still work with PR36793 fixed.

llvm-svn: 328215
2018-03-22 17:14:41 +00:00
George Rimar 42c939c6c1 [ELF] - Apply clang-format. NFC.
llvm-svn: 328195
2018-03-22 13:47:56 +00:00
Rafael Espindola 116e2141f8 Make test a bit less strict. NFC.
llvm-svn: 328168
2018-03-21 23:01:10 +00:00
Rafael Espindola c08e5afb7c Replace a std::pair with a struct.
This is more readable and should reduce the noise in a followup patch.

llvm-svn: 328164
2018-03-21 22:32:17 +00:00
Zaara Syeda 5dd6bd9631 [ELF][PPC64] Fix getRelExpr for R_PPC64_REL16_LO and R_PPC64_REL16_HA
The relocations R_PPC64_REL16_LO and R_PPC64_REL16_HA should return R_PC
for getRelExpr since they compute #lo(S + A – P) and #ha(S + A – P).

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

llvm-svn: 328103
2018-03-21 15:04:04 +00:00
George Rimar 89481f363a [ELF] - Teach LLD to hint about -fdebug-types-section.
Patch teaches LLD to hint user about -fdebug-types-section flag
if relocation overflow happens in debug section.

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

llvm-svn: 328081
2018-03-21 09:19:34 +00:00
Zachary Turner fced530650 Revert "Resubmit "Support embedding natvis files in PDBs.""
This is still failing on a different bot this time due to some
issue related to hashing absolute paths.  Reverting until I can
figure it out.

llvm-svn: 328014
2018-03-20 18:37:03 +00:00
Eric Christopher 7baac21bce Fix consitent -> consistent.
llvm-svn: 328010
2018-03-20 18:10:30 +00:00
Fangrui Song 0e30731a6a [ELF] Simplify compCtors and writeInt.
Reviewers: ruiu

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 328009
2018-03-20 18:07:25 +00:00
Zachary Turner 132d7a134f Resubmit "Support embedding natvis files in PDBs."
The issue causing this to fail in certain configurations
should be fixed.

It was due to the fact that DIA apparently expects there to be
a null string at ID 1 in the string table.  I'm not sure why this
is important but it seems to make a difference, so set it.

llvm-svn: 328002
2018-03-20 17:06:39 +00:00
George Rimar 8ee7947fb4 [ELF] - Make __start_/__stop_<section_name> symbols STV_PROTECTED
There are no reasons for them to be STV_DEFAULT,
recently bfd did the same change.

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

llvm-svn: 327983
2018-03-20 14:22:10 +00:00