Commit Graph

10286 Commits

Author SHA1 Message Date
Rui Ueyama e89b0ef0a0 [WebAssembly] Simplify createDefined. NFC.
Differential Revision: https://reviews.llvm.org/D43849

llvm-svn: 326615
2018-03-02 21:19:55 +00:00
Nicholas Wilson 36f14f41e6 [WebAssembly] Rename global types to match the notation in the spec
llvm-svn: 326583
2018-03-02 14:54:34 +00:00
Nicholas Wilson f2f6d5e03b [WebAssembly] Export non-hidden defined data symbols via wasm globals
This fixes a TODO introduced in rLLD325861.

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

llvm-svn: 326581
2018-03-02 14:51:36 +00:00
Nicholas Wilson f6dbc2edee [WebAssembly] Pass ownership of body to SyntheticFunction. NFC
This avoids the Writer unnecessarily having a member to retain ownership
of the function body.

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

llvm-svn: 326580
2018-03-02 14:48:50 +00:00
Nicholas Wilson cb81a0c9d9 [WebAssembly] Add validation for init function signature
Differential Revision: https://reviews.llvm.org/D43947

llvm-svn: 326579
2018-03-02 14:46:54 +00:00
George Rimar 97785af464 [ELF] - Report error when memory region is overflowed by data commands.
LLD can not catch a memory area overflow when using a data command.
If we have the script below:

.foo : 
{
  *(.foo)
  BYTE(0x1)
} > ram

where BYTE overflows the ram region, we do not report it currently.
Patch fixes that.

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

llvm-svn: 326545
2018-03-02 08:11:58 +00:00
Ed Maste dfcd846b26 Update man page for long opts that accept = after r326506
Also remove the space between --lto-O and value, as the option with a
space is not accepted at present.

Leave --opt-remarks-filename as it does not currently accept the = form.

llvm.org/pr36563

llvm-svn: 326536
2018-03-02 02:57:12 +00:00
Rui Ueyama dcf6234dad [WebAssembly] Simplify COMDAT handling.
Differential Revision: https://reviews.llvm.org/D43966

llvm-svn: 326509
2018-03-01 23:29:05 +00:00
Rui Ueyama cdd5fb5087 Report an error if you try to link against .dll instead of .lib.
It is a usage error to feed a .dll file instead of a .dll to COFF linker.
Previously, lld failed with a mysterious error message. Now we reject
it at the driver.

Fixes https://bugs.llvm.org/show_bug.cgi?id=36440

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

llvm-svn: 326507
2018-03-01 23:11:30 +00:00
Rui Ueyama 036ed36f0a Accept both `--foo bar` and `--foo=bar` styles options.
GNU linkers by convention supports both `--foo bar` and `--foo=bar` styles
for all long options that take arguments.

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

llvm-svn: 326506
2018-03-01 23:06:10 +00:00
Rui Ueyama b3ee432b6b Rename a test file and fix indentation.
llvm-svn: 326504
2018-03-01 23:01:41 +00:00
Rui Ueyama 7c18abf99a Set DF_TEXTREL to executables that need text relocations.
Summary:
If an executable needs text relocations, it should be marked as such so
that the loader can prepare for text relocations. We currently create a
dummy segment with DT_TEXTREL for that purpose.

Generic ABI as of 2000 [1] mentioned that "Its [DT_TEXTREL's] use
has been superseded by the DF_TEXTREL flag". However, it's actually not
superseded even after 18 years. OpenBSD and musl recognize only DT_TEXTREL.
So we still need to set both.

[1] http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html

Reviewers: rafael

Subscribers: emaste, llvm-commits, arichardson

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

llvm-svn: 326503
2018-03-01 22:56:52 +00:00
Rafael Espindola 2e4bcb0095 Don't ingoned --enable-new-dtags.
llvm-svn: 326498
2018-03-01 22:23:51 +00:00
Rui Ueyama b34bd34fd2 [MinGW] Fix --{start,end}-group.
Currently --start-group=foo is accidentally accepted by the MinGW driver.

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

llvm-svn: 326478
2018-03-01 20:38:38 +00:00
Ed Maste 9a289f7b72 Correct man page description for --section-start
The argument is section=address, not just address.

(For compatibility with GNU linkers we need to, but do not yet, accept
--section-start=section=address.)

llvm-svn: 326463
2018-03-01 19:02:41 +00:00
Ed Maste dde3a9170c Where possible use --long-opt=value in lld man page
We intend to maintain compatibility with GNU ld, and in the GNU world
long options are conventionally specified as --long-option=value. For
whatever reason GNU ld.bfd accepts both --long-option value and
--long-option=value, but documents the former. Follow suit.

Some lld long options do not accept the = form; this is probably a bug
to be fixed (along with a man page update).

Reported by Ingo Schwarze, for --entry.

llvm-svn: 326459
2018-03-01 18:40:11 +00:00
Sam Clegg 8518e7ded5 [WebAssembly] Use uint8_t for single byte values to match the spec
Differential Revision: https://reviews.llvm.org/D43922

llvm-svn: 326455
2018-03-01 18:06:39 +00:00
Zachary Turner c6a75a69f1 [PDB] Defer writing the build id until the rest of the PDB is written.
For now this is NFC, but this small refactor opens the door to
letting us embed a hash of the PDB in the build id field of the
PDB.

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

llvm-svn: 326453
2018-03-01 18:00:29 +00:00
Ed Maste a83e226c2f Correct markup and nits in ld.lld man page
Patch by Ingo Schwarze

llvm-svn: 326446
2018-03-01 16:02:19 +00:00
Rafael Espindola e75b42ee4e Don't allocate a header bellow address 0.
With the current code if the script has a PHDRS we always obey and try
to allocate a header. This can cause Min - HeaderSize to underflow.

It looks like bfd actually prints an error for this case. With this
patch we do the same.

Found while looking at pr36515.

llvm-svn: 326441
2018-03-01 15:25:46 +00:00
George Rimar b068b03793 [ELF] - Don't crash on broken MEMORY declaration.
LLD crashes with broken scripts shown in testcase,
because fails to read memory regon name and accesses
MemoryRegions's element which is nullptr.
Patch fixes it.

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

llvm-svn: 326431
2018-03-01 12:36:01 +00:00
George Rimar c4df670dea [ELF] - Do not remove empty sections that use symbols in expressions.
This is PR36515.

Currenly if we have a script like .debug_info 0 : { *(.debug_info) },
we would not remove this section and keep it in the output.
That does not work, because it is common case for
debug sections to have a zero address expression.
Patch changes behavior so that we remove only sections
that do not use symbols in its expressions.

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

llvm-svn: 326430
2018-03-01 12:27:04 +00:00
George Rimar f3e93b23f7 [ELF] - Fix eh-frame-reloc-out-of-range.test.
Was broken after recent testcases changes.

llvm-svn: 326427
2018-03-01 10:38:51 +00:00
Nicholas Wilson 4cdf5b8fa0 [WebAssembly] Reorder exports to match symbol table order
This fixes a TODO introduced in rLLD325861.

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

llvm-svn: 326424
2018-03-01 09:38:02 +00:00
Rui Ueyama 05660daced Convert more tests as linker scripts instead of assembly.
llvm-svn: 326415
2018-03-01 04:21:42 +00:00
Rui Ueyama 0931e957ff [WebAssembly] Remove unused forward declaration.
llvm-svn: 326411
2018-03-01 02:37:26 +00:00
Rui Ueyama 37ad8161e4 Do not create multiple NOTE segments.
Previously, we didn't try to make effort to put .note sections next
to each other in the output file, so two .note sections were likely
to be stored to two separate NOTE segments. That's undesirable because
we should create as few segments as possible in general.

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

llvm-svn: 326410
2018-03-01 02:31:29 +00:00
Rafael Espindola b4267dfc10 Expand test a bit.
It now includes both linkerscript and non linkerscript variants.

Extracted from a patch by Rui while I was trying to figure out what
exactly was changing.

llvm-svn: 326409
2018-03-01 02:25:40 +00:00
Rui Ueyama dc32dc1770 Convert more .s files to linker script files.
Summary:
This change removes large "echo" commands from the test by writing
tests themselves as linker scripts.

Reviewers: rafael

Subscribers: emaste, javed.absar, llvm-commits, arichardson

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

llvm-svn: 326403
2018-03-01 01:19:12 +00:00
Rafael Espindola 852bd5c062 Simplify removing empty output sections.
With this the meaning of the Live bit in output sections is clear: we
have at some point added a input section into it.

llvm-svn: 326401
2018-03-01 01:08:00 +00:00
Fangrui Song 3816c78490 [ELF] Fix a test comment. NFC
llvm-svn: 326400
2018-03-01 01:05:04 +00:00
Sam Clegg ea397f67e3 [WebAssembly] Use Twine rather than StringRef for logging messages
Also add missing tracing to writeU8.

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

llvm-svn: 326398
2018-03-01 00:42:57 +00:00
Rui Ueyama 67d6908f59 Use DenseMap::lookup() instead of find() and a hand-written null check.
llvm-svn: 326382
2018-02-28 23:03:06 +00:00
Rui Ueyama b961abc886 [WebAssembly] Reduce code repetition. NFC.
Differential Revision: https://reviews.llvm.org/D43910

llvm-svn: 326379
2018-02-28 22:51:51 +00:00
Rui Ueyama 3fffe1f02d Make sure that clang-format doesn't reorder include files.
clang-format won't reorder include files if there is a blank line.
Thanks to Nico for the tips.

llvm-svn: 326371
2018-02-28 21:32:24 +00:00
Rui Ueyama 2dfe49a441 Write some tests as linker scripts instead of assembly files.
Some linker script test cases contain only a few lines of assembly
and a long linker script. Such tests are easier to maintain if we
write the main test file as a linkier script instead of assembly.

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

llvm-svn: 326363
2018-02-28 20:22:42 +00:00
Rui Ueyama 7440135e62 Attempt to build breakage caused by r326339.
clang-format automatically sorted the #include lines, but I believe
Windows.h needs to be included before Dbghelp.h.

llvm-svn: 326360
2018-02-28 20:11:33 +00:00
Sam Clegg 45f984e625 [WebAssembly] Remove unneeded --no-gc-sections flag from tests. NFC.
Differential Revision: https://reviews.llvm.org/D43889

llvm-svn: 326356
2018-02-28 19:40:03 +00:00
Rui Ueyama 39ba31ff50 Add "%" operator to the linker script.
This patch improves compatibility with GNU linkers.

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

llvm-svn: 326348
2018-02-28 18:38:13 +00:00
Rui Ueyama 1d20222a48 Inline a trivial function. NFC.
llvm-svn: 326347
2018-02-28 18:25:00 +00:00
Zachary Turner 3868cfd503 Fix use after free in PDB linker.
When merging in types from a type server PDB, we would use a
pointer into the type server PDB's mapped file buffer directly
to avoid copying data.  However, we would close the type server
PDB after we finished merging in its types, which would unmap
all of its memory.  This would lead to a use after free.

We fix this by making a strong reference in the PDBLinker class
to all referenced type server PDBs, thereby making it safe to
hold pointers into its memory mapped contents.

This fixes llvm.org/pr36455

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

llvm-svn: 326345
2018-02-28 18:09:18 +00:00
Rafael Espindola 367bfce611 Simplify. NFC.
llvm-svn: 326344
2018-02-28 18:05:37 +00:00
Rui Ueyama 29abfe4a8f [WebAssembly] Use toArrayRef. NFC.
Differential Revision: https://reviews.llvm.org/D43855

llvm-svn: 326340
2018-02-28 17:43:15 +00:00
Rui Ueyama ee17371897 Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.
This should resolve the issue that lld build fails in some hosts
that uses case-insensitive file system.

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

llvm-svn: 326339
2018-02-28 17:38:19 +00:00
Rui Ueyama 22c8f33a9b [WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.
Differential Revision: https://reviews.llvm.org/D43854

llvm-svn: 326337
2018-02-28 17:33:04 +00:00
Rui Ueyama ba16baccf1 [WebAssembly] Improve WasmSignatureDenseMapInfo.
Let X and Y be types. Previously, functions F(X, Y) and G(Y, X) had
the same hash value because their hash values are computed as follows:

  hash(F) = hash(X) + hash(Y)
  hash(G) = hash(Y) + hash(X)

This patch fixes the issue by using hash_combine.

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

llvm-svn: 326336
2018-02-28 17:32:50 +00:00
Nicholas Wilson 280f872bb2 [WebAssembly] Reorder symbol table to match MC order
Update LLD test expectations for new symbol ordering introduced by
Differential D43685.

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

llvm-svn: 326335
2018-02-28 17:20:51 +00:00
Igor Kudrin c844524e46 [ELF] Process linker scripts deeper when declaring symbols.
We should process symbols inside output section declarations the same way as top-level ones.

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

llvm-svn: 326305
2018-02-28 05:55:56 +00:00
Rui Ueyama 26a84fc84f [WebAssembly] Fix variable name.
llvm-svn: 326301
2018-02-28 03:43:38 +00:00
Rui Ueyama 67769100ce [WebAssembly] Remove unnecessary namespace specifiers. NFC.
llvm-svn: 326300
2018-02-28 03:38:14 +00:00