Commit Graph

8897 Commits

Author SHA1 Message Date
Rafael Espindola d21ac10f6d Fix the order of section that are not on an order file.
They were being placed before sections that were listed.

llvm-svn: 309391
2017-07-28 15:36:15 +00:00
George Rimar 7b30dd1c53 [ELF] - Cleanup MapFile.cpp. NFC.
* Removed redundant templating.
* Added missing `static` keyword.

llvm-svn: 309376
2017-07-28 11:13:21 +00:00
George Rimar 60833f6e22 [ELF] - Do not crash when ALIGN/DATA_SEGMENT_ALIGN expression used with zero value.
Previously we would crash when tried to ALIGN(0).
Patch uses value 1 instead in this case, that
looks to be consistent with GNU linkers
and reasonable and simple behavior itself.

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

llvm-svn: 309372
2017-07-28 09:27:49 +00:00
Rafael Espindola 06ad7ed70c Add a test.
This would have found the error in r309252.

llvm-svn: 309329
2017-07-27 22:08:11 +00:00
Rafael Espindola a2df2f09f4 Avoid warnings when asserts are disabled.
llvm-svn: 309326
2017-07-27 21:42:42 +00:00
Rafael Espindola 8c022ca783 Merge OutputSectionCommand and OutputSection.
This is a bit of a hack, but it is *so* convenient.

Now that we create synthetic linker scripts when none is provided, we
always have to handle paired OutputSection and OutputsectionCommand and
keep a mapping from one to the other.

This patch simplifies things by merging them and creating what used to
be OutputSectionCommands really early.

llvm-svn: 309311
2017-07-27 19:22:43 +00:00
Reid Kleckner eacdf04fdd [PDB] Write public symbol records and the publics hash table
Summary:
MSVC link.exe records all external symbol names in the publics stream.
It provides similar functionality to an ELF .symtab.

Reviewers: zturner, ruiu

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 309303
2017-07-27 18:25:59 +00:00
George Rimar 13f7dcdbc3 Revert r309252 "[ELF] - Fix missing relocation when linking executable with --unresolved-symbols=ignore-all"
It broke bot:
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/4231

llvm-svn: 309258
2017-07-27 09:25:16 +00:00
George Rimar 8146773845 [ELD] - Sorted in ASCIIbetical order. NFC.
llvm-svn: 309254
2017-07-27 07:48:36 +00:00
George Rimar aa3541875e [ELF] - Store PhdrEntry values by pointers instead of storing by value.
That is slightly more convinent as allows to store pointer on
program header entry in a more safe way.
 
Change was used in 2 patches currently on review.

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

llvm-svn: 309253
2017-07-27 07:46:50 +00:00
George Rimar 678188d48b [ELF] - Fix missing relocation when linking executable with --unresolved-symbols=ignore-all
This is PR32112. Previously when we linked executable with 
--unresolved-symbols=ignore-all and undefined symbols, like:

_start:
callq und@PLT

we did not create relocations, though it looks in that case
we should delegate handling of such symbols to runtime linker,
hence should emit them. Patch fixes that.

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

llvm-svn: 309252
2017-07-27 07:31:31 +00:00
Rui Ueyama acd632d338 Add {Obj,Import,Bitcode}File::Instances to COFF input files.
We did the same thing for ELF in r309152, and I want to maintain
COFF and ELF as close as possible.

llvm-svn: 309239
2017-07-27 00:45:26 +00:00
Rafael Espindola be28c2e4a5 Add --gc-sections to a test.
This shows that the logic in --gc-sections is a bit more precise than
what can be easily done in LTO.

llvm-svn: 309234
2017-07-26 23:47:24 +00:00
Rafael Espindola 4b075bb218 Make __start_sec __end_sec handling more precise.
With this we only ask LTO to keep a C named section if there is a
__start_ or __end symbol.

This is not as strict as lld's --gc-sections, but is as good as we can
get without having a far more detailed ir summary.

llvm-svn: 309232
2017-07-26 23:39:10 +00:00
Nico Weber 268f89d540 lld: /manifestuac:no shouldn't disable /manifestdependency:
Matches link.exe
https://reviews.llvm.org/D35872

llvm-svn: 309231
2017-07-26 23:38:10 +00:00
Rui Ueyama e1b48e099c Rename ObjectFile ObjFile for COFF as well.
llvm-svn: 309228
2017-07-26 23:05:24 +00:00
Rafael Espindola 6c4f5b41a3 Fix the name of the section end symbol.
It is __stop_<sec>, not __end_<sec>.

llvm-svn: 309225
2017-07-26 22:52:53 +00:00
Rui Ueyama 709fb2bb10 Rename ObjectFile -> ObjFile.
Rename it because it was too easy to conflict with llvm::object::ObjectFile
which broke buildbots several times.

llvm-svn: 309199
2017-07-26 22:13:32 +00:00
Meador Inge b0e6229742 [ELF, LinkerScript] Memory region name parsing fix
This patch fixes a small issue with respect to how memory region names
are parsed on output section descriptions.  For example, consider:

  .text : { *(.text) } > rom

That can also be written like:

  .text : { *(.text) } >rom

The latter form is accepted by GNU LD and is fairly common.

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

llvm-svn: 309191
2017-07-26 21:51:09 +00:00
Rui Ueyama 3e96f1167c Attempt to fix buildbots.
llvm-svn: 309188
2017-07-26 21:37:11 +00:00
Rui Ueyama 23f64d229b Remove unnecessary namespace specifier.
I believe this compiles fine on all platforms, even on Windows.

llvm-svn: 309182
2017-07-26 21:24:01 +00:00
Martin Storsjo 38608c0975 [COFF, ARM64] Handle ADRP immediate offsets in relocations
Also handle overflow correctly in LDR/STR relocations. Even if the
offset range of a 8 byte LDR instruction is 15 bit (even if the immediate
itself is 12 bit) due to a 3 bit shift, only include up to 12 bits of offset
after doing the relocation, by limiting the range of the immediate by the
number of shifted bits.

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

llvm-svn: 309175
2017-07-26 20:51:47 +00:00
Rafael Espindola aaa8e433ad Try to fix the windows build.
llvm-svn: 309162
2017-07-26 19:57:40 +00:00
Rafael Espindola b4b485370c Try to fix the windows build.
llvm-svn: 309161
2017-07-26 19:39:40 +00:00
Rafael Espindola bf991405de Try to fix the windows build.
llvm-svn: 309160
2017-07-26 19:37:58 +00:00
Rafael Espindola a5e8dd35b0 Simplify. NFC.
llvm-svn: 309153
2017-07-26 18:47:49 +00:00
Rafael Espindola 244ef98161 Detemplate SymbolTable.
NFC, just makes it easier to access from non templated code.

llvm-svn: 309152
2017-07-26 18:42:48 +00:00
George Rimar d5948f3a9a [ELF] - Ignore --warn-once option.
Was discussed in D35797 thread.

llvm-svn: 309096
2017-07-26 10:25:49 +00:00
George Rimar 84941ef158 [ELF] - Change way how we handle --noinhibit-exec
Previously we handled this option implicitly, only
for infering unresolved symbols handling policy.

ld man says: "--noinhibit-exec Retain the executable
output file whenever it is still usable",
and we may want to handle other cases too.

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

llvm-svn: 309091
2017-07-26 09:46:59 +00:00
George Rimar 6977ec6899 [ELF] - Print options aliases in --help
This is PR30422,
previously LLD did not render all option aliases in --help.
With this patch it will.

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

llvm-svn: 309089
2017-07-26 09:21:10 +00:00
Rui Ueyama 8109789a33 Simplify ignored options.
Since the flag is ignored anyway, it doesn't matter whether
it is an alias or not.

llvm-svn: 309055
2017-07-25 23:32:05 +00:00
Rafael Espindola cb83c8c85f Simplify. NFC.
llvm-svn: 309053
2017-07-25 23:23:40 +00:00
Rafael Espindola d4fbe4fe82 Reduce templating. NFC.
llvm-svn: 309051
2017-07-25 23:15:35 +00:00
Rafael Espindola affe7209c0 LTO: Handle sections with valid C names.
These can be referenced with __start_/__stop_ symbols. I will try to make
this more precise in a followup patch.

llvm-svn: 309048
2017-07-25 22:51:05 +00:00
Martin Storsjo 82eaf6cb50 [COFF] Add support for delay loading DLLs on ARM
Differential Revision: https://reviews.llvm.org/D35768

llvm-svn: 309017
2017-07-25 20:00:37 +00:00
Nico Weber 578363ac08 Attempt to fix lld tests on Windows after 308998.
The test used /manifestinput: without /manifest:embed, which isn't actually
supported.  Just remove this part of the test for now; if it's important to
check this the llvm-readobj part should be extended to check this.

llvm-svn: 309002
2017-07-25 18:39:38 +00:00
Nico Weber a7a2c44e70 lld: only write .manifest files if /manifest is passed, PR33925
Also emit an error if /manifestinput: is used without /manifest:embed.
Increases compatibility with link.exe

https://reviews.llvm.org/D35842

llvm-svn: 308998
2017-07-25 18:08:03 +00:00
George Rimar 4c351c6540 [ELF] - Fix init_fini_priority.s test.
Previously .init_array/.fini_array sections
were not unique and we had 3 .init_array sections +
3 .fini_array input sections passed to linker,
instead of 5 + 5.

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

llvm-svn: 308958
2017-07-25 09:26:35 +00:00
George Rimar f694d33f4c [ELF] - Fix calculation of memory region offset.
This is PR33714.

Previously for each input section offset of memory region
was incremented on a size of output section.

That resulted in a wrong error message saying about
overflow. Patch fixes that.

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

llvm-svn: 308955
2017-07-25 08:29:29 +00:00
Martin Storsjo 405b5bcc36 [COFF] Correctly set the thumb bit in DLL export addresses
The same adjustment is already done for the entry point in
Writer.cpp and for relocations that point to executable code
in Chunks.cpp.

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

llvm-svn: 308953
2017-07-25 06:10:44 +00:00
Martin Storsjo 25712667cb [COFF] Add a test for producing DLLs and import libraries for ARM64
This is a test for LLVM SVN r308951.

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

llvm-svn: 308952
2017-07-25 06:08:25 +00:00
Rafael Espindola dc49af9d32 Make a function static. NFC.
llvm-svn: 308939
2017-07-24 23:55:33 +00:00
Tom Stellard 1d70d75f46 Fix ObjCPass on big-endian host
Summary:
This fixes test/mach-o/objc-image-info-pass-output.yaml on
big-endian hosts.

Reviewers: lhames, kledzik, ruiu

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 308935
2017-07-24 23:13:31 +00:00
Dmitry Mikulin 97d6a80895 If user requested section alignment is greater than MaxPageSize, propagate it to segment headers correctly.
Differential Revision: https://reviews.llvm.org/D35813

llvm-svn: 308930
2017-07-24 21:27:02 +00:00
Davide Italiano 0a26c5738d [ELF] Fix a typo introduced in r308915.
Thanks to Rafael for finding it in a post-commit review.

llvm-svn: 308921
2017-07-24 20:18:16 +00:00
Davide Italiano 957f1206e9 [LTO] Make sure symbol ordering is honoured also for data.
Follow-up to r308915 suggested by Rafael and Peter.

llvm-svn: 308920
2017-07-24 20:15:07 +00:00
Davide Italiano 4deb97c377 [ELF] Fix a couple of typos in a test.
llvm-svn: 308916
2017-07-24 19:42:13 +00:00
Davide Italiano 1f4e29c71d [LTO] Make sure symbol ordering is honoured.
We do this emitting a section for every function when LTO is used.
Fixes PR33888.

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

llvm-svn: 308915
2017-07-24 19:38:13 +00:00
Rafael Espindola fae04ae44c Handle a section being more aligned than a page size.
llvm-svn: 308812
2017-07-22 00:17:57 +00:00
Rafael Espindola ca5740d95a Don't crash on an empty section with an ALIGN.
llvm-svn: 308809
2017-07-22 00:00:51 +00:00