Commit Graph

7636 Commits

Author SHA1 Message Date
George Rimar 2ddab6d186 [ELF] - Do not create huge garbage files on section offset overflow.
Patch changes behavior to not try open the output 
file if we already know about error.

That is not just cleaner, but also fixes nasty behavior of linker that
could create huge temporarily files under certain conditions.

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

llvm-svn: 292219
2017-01-17 13:50:34 +00:00
Davide Italiano 51aff488e5 [ELF] __cxa_demangle is now called itaniumDemangle. Update.
llvm-svn: 292182
2017-01-17 01:59:13 +00:00
Simon Atanasyan 2bd98af563 [ELF][MIPS] Exclude mips .got from PT_GNU_RELRO segment
On MIPS .got section cannot be included into the PT_GNU_RELRO segment.
Sometimes it might work, but in general it is unsupported. One of the
problem is that all sections marked by SHF_MIPS_GPREL should be grouped
together because data in these sections is addressable with a gp
relative address, but such sections might be writable.

This patch exclude mips .got from PT_GNU_RELRO segment and group
SHF_MIPS_GPREL sections.

llvm-svn: 292161
2017-01-16 21:17:23 +00:00
Simon Atanasyan 97a42ea896 [ELF][MIPS] Remove redundant checkings from test cases. NFC
llvm-svn: 292160
2017-01-16 21:17:09 +00:00
Rafael Espindola 41a93a3edf Give priority to linker scripts over preemption.
LLD exports symbols that are also present in used shared libraries to
make sure they are preempted at runtime. That is a reasonable default,
but we must allow for it to be overwritten with linker script. If we
don't, libraries that expect to be able to hide a c++ delete operator
will fail.

This should fix the firebird build.

llvm-svn: 292146
2017-01-16 17:35:23 +00:00
George Rimar 548adcdec4 [COFF] - Fixed format in writeOutSecLine()
The same as https://reviews.llvm.org/rL292102,
fixes next testcases under msvs2015/win32:

25>  Failing Tests (3):
25>      lld :: COFF/lldmap.test
25>      lld :: COFF/weak-external.test
25>      lld :: COFF/weak-external3.test

llvm-svn: 292104
2017-01-16 11:46:55 +00:00
George Rimar 07d94e3529 [ELF] - Fix format specifiers in writeOutSecLine()
I had a error in map-file.s testcase under MSVS2015/win32:

map-file.s:30:16: error: expected string not found in input
// CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame

<stdin>:2:1: note: scanning from here
0000000000200158 10 30 .eh_frame

Format string '%0*x' requires an argument of type 'unsigned int',
but argument has type 'uint64_t'. Proper format is '%0*llx' then.

This fixes testcase failture for me.

llvm-svn: 292102
2017-01-16 11:35:38 +00:00
Rui Ueyama c9807c3370 Use error() instead of fatal() to handle file open error.
llvm-svn: 292090
2017-01-16 01:07:19 +00:00
Rui Ueyama 71e3e3a5c1 Move a flag definition to the right place as -demangle is not ignored.
llvm-svn: 292049
2017-01-15 03:45:46 +00:00
Rui Ueyama ea3f6c3a7e Add -no-{export-dynamic,fatal-warnings}.
llvm-svn: 292048
2017-01-15 03:38:55 +00:00
Rui Ueyama 1705f99c77 Add -print-map and -M options.
llvm-svn: 292046
2017-01-15 02:52:34 +00:00
Rui Ueyama 9c6cdc2022 Add a help text for -Map.
llvm-svn: 292045
2017-01-15 02:52:14 +00:00
Rui Ueyama c9df172553 Fix typo.
llvm-svn: 292044
2017-01-15 02:34:42 +00:00
Rui Ueyama 483ffa3365 Simplify string output. NFC.
llvm-svn: 292042
2017-01-15 01:11:47 +00:00
Rui Ueyama 543731f96a Directly write to a -Map file.
Previous code had a bug that if the program exits with an assert() or
fail() before the control reaches end of writeMapFile(), it leaves a
temporary file, because FileRemover's dtor isn't called in that case.

I could fix that by removeFileOnSignal() and other functions, but
I think we can simply write to the result file directly. I think
that is straightforward and easy to understand.

Additionally, that allows something like `-Map /dev/null` or a bash
hack such as `-Map >(grep symbol-im-looking-for)`. Previously,
that kind of things didn't work.

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

llvm-svn: 292041
2017-01-15 00:41:21 +00:00
Peter Collingbourne 6f24fdb6a0 COFF: Change the /lldmap output format to be more like the ELF linker.
Differential Revision: https://reviews.llvm.org/D28717

llvm-svn: 291990
2017-01-14 03:14:46 +00:00
Rafael Espindola 7c783a49a2 Try to fix the windows bots.
llvm-svn: 291989
2017-01-14 02:45:53 +00:00
Rui Ueyama db540ff057 Split writeMapFile2 to reduce indentation level.
llvm-svn: 291984
2017-01-14 00:37:28 +00:00
Bob Haarman 848c569734 COFF: include relocation type in unsupported relocation message
Summary: When we encouter a relocation type we don't know how to handle, this change causes us to print out the hexadecimal value of the relocation type. This makes troubleshooting a little easier.

Reviewers: ruiu, zturner

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

llvm-svn: 291962
2017-01-13 22:05:22 +00:00
Rafael Espindola 1ebfc59c89 Implement -Map.
The format is not exactly the same as the one in bfd since bfd always
follows a linker script and prints it along.

llvm-svn: 291958
2017-01-13 21:05:46 +00:00
Rafael Espindola 8a59f5c79f Don't add DT_INIT/DT_FINI for undef and shared symbols.
The freebsd dynamic linker doesn't check if the value is null (and it
is reasonable for it to do that). That means that producing a .so with
a null DT_INIT/DT_FINI causes the base address to be called.

This should fix the libreoffice build.

llvm-svn: 291944
2017-01-13 19:18:11 +00:00
George Rimar 1e799942b3 [ELF] - Move the addition of synthetics from addPredefinedSections()
These were 3 last synthetics that were added in addPredefinedSections() instead
of createSyntheticSections(). Now it is possible to move addition to correct common place.

Also patch fixes testcase which discards .shstrtab, by restricting doing that.

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

llvm-svn: 291908
2017-01-13 16:18:15 +00:00
Rui Ueyama c8d3a83fff Remove error(error_code, const Twine &).
Now we have the consistent interface for all log/warn/error/fatal functions.

llvm-svn: 291847
2017-01-12 22:18:04 +00:00
Rui Ueyama cec59f6f3c Remove dead code.
llvm-svn: 291840
2017-01-12 22:03:25 +00:00
Hans Wennborg 1e307707b3 Clear the release notes for 5.0.0
llvm-svn: 291839
2017-01-12 22:00:54 +00:00
Rui Ueyama 7aa90ad65b Do not use the same name for both a class and a variable.
llvm-svn: 291835
2017-01-12 21:44:20 +00:00
Rui Ueyama 52be82590c Improve an error message and remove fatal(Error &, const Twine &)
llvm-svn: 291834
2017-01-12 21:43:58 +00:00
Hans Wennborg 0e978de2a9 Update docs/conf.py version
llvm-svn: 291833
2017-01-12 21:43:32 +00:00
Rui Ueyama 1d8460755e Remove dead code.
llvm-svn: 291812
2017-01-12 21:09:58 +00:00
Rui Ueyama 61fc94e0c1 Simplify. NFC.
llvm-svn: 291811
2017-01-12 21:05:48 +00:00
Rafael Espindola bec58f9034 Allow mixing nobits and progbits.
The effect is that the nobits section gets space allocated on disk.

Both bfd and gold allow this with linker scripts. To try to keep
things simple in lld, always allow it for now.

llvm-svn: 291795
2017-01-12 19:16:15 +00:00
Eric Liu b45c0d4ff0 [ELF] avoid 'invalid-noreturn' error.
Summary: elf::fatal is declared "noreturn".

Reviewers: grimar

Subscribers: llvm-commits

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

llvm-svn: 291766
2017-01-12 13:13:32 +00:00
George Rimar f09519c362 [ELF] - Do not crash if user section has name equal to one of synthetic sections.
Previously we just crashed when had user defined
section .shstrtab, for example. Which name equals to synthetic one,
but have different type.

Testcase reveals an issue.

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

llvm-svn: 291765
2017-01-12 13:00:31 +00:00
George Rimar 0d8af3697a [ELF] - Reuse Decompressor class.
Intention of change is to get rid of code duplication.
Decompressor was introduced in D28105.

Change allows to get rid of few methods relative to decompression.

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

llvm-svn: 291758
2017-01-12 10:53:31 +00:00
George Rimar 1743e55e34 [ELF] - Make x86 unknown relocations messages to be consistent with x64 ones
Addded quotes to be consistent with x64 messages,
where quotes were used for nicer reporting 'Unknown' relocations initially.

llvm-svn: 291752
2017-01-12 09:09:15 +00:00
George Rimar 66666360de [ELF] - Explicitly list supported relocations for x64 target.
The same we did for x86 earlier:
list supported relocations explicitly and error out on unknown.

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

llvm-svn: 291751
2017-01-12 09:00:17 +00:00
Rui Ueyama 5289662e4a PDB: Merge type info.
This patch is to merge type info in multiple .debug$T sections.

One mystery that needs to be solved is that it is not clear how
the MSVC linker uses TPI and IPI streams. Both streams contain
type info, and it is not obvious what kind of record should go
which.

dumppdb command in microsoft-pdb repository prints out IPI stream
contents as "IDs" and TPI stream as "TYPES", but looks like the tool
don't really care about which stream type recrods were read from.

For now, in this patch, I emit all type records to TPI stream.
It might just work with other tools. If not, we need to investigate
it more.

llvm-svn: 291739
2017-01-12 03:09:25 +00:00
Zachary Turner 629cb7d8cc [CodeView] Finish decoupling TypeDatabase from TypeDumper.
Previously the type dumper itself was passed around to a lot of different
places and manipulated in ways that were more appropriate on the type
database. For example, the entire TypeDumper was passed into the symbol
dumper, when all the symbol dumper wanted to do was lookup the name of a
TypeIndex so it could print it. That's what the TypeDatabase is for --
mapping type indices to names.

Another example is how if the user runs llvm-pdbdump with the option to
dump symbols but not types, we still have to visit all types so that we
can print minimal information about the type of a symbol, but just without
dumping full symbol records. The way we did this before is by hacking it
up so that we run everything through the type dumper with a null printer,
so that the output goes to /dev/null. But really, we don't need to dump
anything, all we want to do is build the type database. Since
TypeDatabaseVisitor now exists independently of TypeDumper, we can do
this. We just build a custom visitor callback pipeline that includes a
database visitor but not a dumper.

All the hackery around printers etc goes away. After this patch, we could
probably even delete the entire CVTypeDumper class since really all it is
at this point is a thin wrapper that hides the details of how to build a
useful visitation pipeline. It's not a priority though, so CVTypeDumper
remains for now.

After this patch we will be able to easily plug in a different style of
type dumper by only implementing the proper visitation methods to dump
one-line output and then sticking it on the pipeline.

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

llvm-svn: 291724
2017-01-11 23:24:22 +00:00
Rafael Espindola 79114a673e Make the -b binary .data section rw.
This matches what bfd and gold do. It also matches the common flags of
other .data sections.

llvm-svn: 291674
2017-01-11 15:13:05 +00:00
George Rimar 7fa220f5f1 [ELF] - Ignore R_386_NONE.
We had an error when met this relocation
after latest changes aboult listing
x86 relocations explicitly.

Since we support R_X86_64_NONE,
and GNU ld supports R_386_NONE,
it seems reasonable to have.

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

llvm-svn: 291672
2017-01-11 14:20:13 +00:00
George Rimar 57b0e6a5c9 [ELF] - Explicitly list supported relocations for x86 target.
Previously some value was returned by default for relocations by getRelExpr(),
even if relocation actually was not supported.

This is orthogonal alternative to D28094.
Instead of implementing probably useless R_386_PC8/R_386_8 relocations,
this patch uses them in a testcase to demonstrate what happens
when LLD mets unsupported relocations.

Patch passes all testcases and changes logic only for x86.

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

llvm-svn: 291658
2017-01-11 08:29:52 +00:00
Zachary Turner a9054ddd9c [CodeView/PDB] Rename a bunch of files.
We were starting to get some name clashes between llvm-pdbdump
and the common CodeView framework, so I took this opportunity
to rename a bunch of files to more accurately describe their
usage.  This also helps in llvm-pdbdump to distinguish
between different files and whether they are used for pretty
dump mode or raw dump mode.

llvm-svn: 291627
2017-01-11 00:35:43 +00:00
Rui Ueyama 9f0f8b82f7 Inline a simple accessor function.
llvm-svn: 291602
2017-01-10 21:52:56 +00:00
Rafael Espindola b7e2ee2aba Give local binding to VER_NDX_LOCAL symbols.
We were already dropping them from the dynamic symbol table, but the
regular symbol table was still listing them as globals.

llvm-svn: 291573
2017-01-10 17:08:13 +00:00
Rafael Espindola e999ddb8de Add support for anonymous local symbols.
This actually simplifies the code a bit as now all local symbols are
handled uniformly.

This should fix the build of www/webkit2-gtk3.

llvm-svn: 291569
2017-01-10 16:37:24 +00:00
Rui Ueyama 0697ae2ad9 Revert r291526: Re-enable /linkrepro test on Windows.
This broke the following two bots:

lld-x86_64-win7: the test failed because a diff command is not available
on that bot. That's a configuration error of the bot and will be fixed soon.

llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast: "tar xf" failed on that
bot. I suspect that it is due to the maximum path limitation on Windows.
A build directory contains a buildbot name, so it's longer than usual on
that machine. On Windows, many filesystem operations fail if a path is
longer than 255 characters. I'll try to address that in another patch.

llvm-svn: 291527
2017-01-10 02:08:37 +00:00
Rui Ueyama e98516ff99 Re-enable /linkrepro test on Windows.
I think generated tar files are more compatible with old tar commands
because of r291494 and r291340, so I want to enable this test on buildbots.

llvm-svn: 291526
2017-01-10 01:37:37 +00:00
Peter Collingbourne feb6629d6d ELF: Reserve space for copy relocations of read-only symbols in relro.
When reserving copy relocation space for a shared symbol, scan the DSO's
program headers to see if the symbol is in a read-only segment. If so,
reserve space for that symbol in a new synthetic section named .bss.rel.ro
which will be covered by the relro program header.

This fixes the security issue disclosed on the binutils mailing list at:
https://sourceware.org/ml/libc-alpha/2016-12/msg00914.html

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

llvm-svn: 291524
2017-01-10 01:21:50 +00:00
Peter Collingbourne 628ec9f193 ELF: Place relro sections after non-relro sections in r/w segment.
This is in preparation for my next change, which will introduce a relro
nobits section. That requires that relro sections appear at the end of the
progbits part of the r/w segment so that the relro nobits section can appear
contiguously.

Because of the amount of churn required in the test suite, I'm making this
change separately.

llvm-svn: 291523
2017-01-10 01:21:30 +00:00
Michal Gorny 47132e5cab [cmake] Obtain LLVM_CMAKE_PATH from llvm-config
Use the new --cmakedir option to obtain LLVM_CMAKE_PATH straight from
llvm-config instead of reconstructing it locally.

llvm-svn: 291502
2017-01-09 23:17:10 +00:00