Commit Graph

8044 Commits

Author SHA1 Message Date
George Rimar 49a47f2a6d [ELF] - Removed unused template #1. NFC
llvm-svn: 297938
2017-03-16 10:29:44 +00:00
George Rimar f98c5c126c [ELF] - Detemplate OutputSection::assignOffsets. NFC.
llvm-svn: 297937
2017-03-16 10:24:54 +00:00
George Rimar 47bed8c9f7 Revert r297813 "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."
I suppose it is the reason of BB fail:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/921

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

llvm-svn: 297933
2017-03-16 08:44:53 +00:00
Zachary Turner 337e884643 Fix lld pdb test.
It was assuming various things about the PDB like file size
which are going to be too high maintenance to maintain in
a test.

llvm-svn: 297908
2017-03-15 22:58:10 +00:00
Zachary Turner ea4e60754e [pdb] Write the module info and symbol record streams.
Previously we did not have support for writing detailed
module information for each module, as well as the symbol
records.  This patch adds support for this, and in doing
so enables the ability to construct minimal PDBs from
just a few lines of YAML.  A test is added to illustrate
this functionality.

llvm-svn: 297900
2017-03-15 22:18:53 +00:00
George Rimar 20055d4cd2 [ELF] - Linkerscript: make Dot public and remove getDot(). NFC.
Suggested by Rui Ueyama,
also groups member variables in a single place, while I am here.

llvm-svn: 297850
2017-03-15 16:07:02 +00:00
George Rimar 503206c567 [ELF] - Move LinkerScript::discard to LinkerScriptBase. NFC.
Became possible after r297844

llvm-svn: 297848
2017-03-15 15:42:44 +00:00
George Rimar 9782ca5b68 [ELF] - Split struct In<ELFT> to have templated and non-templated sections areas.
Patch splits In<ELFT> into 2 classes: one for non-templated sections, 
second contains ELFT templated ones.
That allows to code that was detemplated to access non-templated sections freely,
and should open road for futher detemplation proccess.

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

llvm-svn: 297844
2017-03-15 15:29:29 +00:00
Rafael Espindola 4820060dc6 Use uint32_t for alignment.
llvm-svn: 297831
2017-03-15 12:43:54 +00:00
Rafael Espindola a156555b5e simplify. NFC
llvm-svn: 297829
2017-03-15 12:31:54 +00:00
George Rimar 42886c4b47 [ELF] - Detemplate MipsRldMapSection. NFC.
After introducing Config->is64Bit() and 
recent changes in LinkerScriptBase, some
sections can be detemplated trivially. This 
is one of such cases.

llvm-svn: 297825
2017-03-15 12:02:31 +00:00
George Rimar 49648004ed [ELF] - Detemplate StringTableSection.
StringTableSection was <ELFT> templated previously,

It disallow to de-template code that uses it,
for example LinkerScript<ELFT>::discard uses it as:
if (S == In<ELFT>::ShStrTab)
  error("discarding .shstrtab section is not allowed");

It seems we can try to detemplate some of synthetic sections
and somehow make them available for non-templated calls.
(move out of In<ELFT> struct probably).

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

llvm-svn: 297815
2017-03-15 09:32:36 +00:00
George Rimar 22e3e7d165 [ELF] - Make Bss and BssRelRo sections to be synthetic (#3).
That removes CopyRelSection class completely, making
Bss/BssRelRo to be just regular synthetics.

This is splitted from D30541 and polished.
Difference from D30541 that all logic of SharedSymbol
converting to DefinedRegular was removed for now and
probably will be posted as separate patch.

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

llvm-svn: 297814
2017-03-15 09:21:29 +00:00
George Rimar 10f74fc10b [ELF] - Detemplate GotPltSection and IgotPltSection sections.
Patch introduces Config->is64Bit() and with help of that detemplates
GotPltSection and IgotPltSection sections

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

llvm-svn: 297813
2017-03-15 09:12:56 +00:00
Petr Hosek 3b4e29ba68 [ELF] Update tests to work even with modified defaults
D30229 changes the defaults based on section names to match the
GAS behavior, which breaks some of the tests that rely on the old
defaults.

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

llvm-svn: 297803
2017-03-15 03:38:48 +00:00
Petr Hosek 02ad516b2e Support ABSOLUTE on the right hand side in linker scripts
This also requires postponing the assignment the assignment of
symbols defined in input linker scripts since those can refer to
output sections and in case we don't have a SECTIONS command, we
need to wait until all output sections have been created and
assigned addresses.

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

llvm-svn: 297802
2017-03-15 03:33:23 +00:00
Rafael Espindola d3c22f08b3 Don't create copy relocs or dummy plt's if given -z notext.
Being passed -z notext is a pretty strong indication that the user is
OK with text relocations. This is not the same behavior as bfd, but
bfd defaults to -z notext, so it has to try to avoid text relocations
and use them as a last resort.

llvm-svn: 297789
2017-03-14 22:50:07 +00:00
George Rimar a2a1ef1abc [ELF] - Move members of LinkerScript to LinkerScriptBase. NFC.
That moves all members that s possible to move for now (all which
does not depend on ELFT templating).

After that change LinkerScript contains only 8 methods in total,
and I believe it is possible to move them all after tweaking other
parts of linker. And we will be able to have single class for 
linkerscript at the end.

llvm-svn: 297735
2017-03-14 12:03:34 +00:00
George Rimar 23e6a02450 [ELF] - Remove unnecessary template #6. NFC.
llvm-svn: 297734
2017-03-14 11:31:28 +00:00
George Rimar f7f0d08827 [ELF] - Remove unnecessary template #5. NFC.
llvm-svn: 297732
2017-03-14 11:23:33 +00:00
George Rimar d83ce1b49d [ELF] - Devirtualize LinkerScriptBase::getOutputSectionSize. NFC.
It does not use ELFT templates so can be non-virtual.

llvm-svn: 297727
2017-03-14 10:24:47 +00:00
George Rimar 851dc1e84d [ELF] - Devirtualize LinkerScriptBase::getOutputSection
It does not use ELFT templates so can be non-virtual.

llvm-svn: 297725
2017-03-14 10:15:53 +00:00
George Rimar d0bee506a0 [ELF] - Simplify LinkerScriptBase::getDot(). NFC.
That makes it not dependent on virtual call,
keeping logic the same.

llvm-svn: 297723
2017-03-14 10:05:43 +00:00
George Rimar 0c1c8085bc [ELF] - Move ThreadBssOffset and Dot to LinkerScriptBase. NFC.
One more step to combine LinkerScript and LinkerScriptBase.

llvm-svn: 297722
2017-03-14 10:00:19 +00:00
George Rimar e21c3af7e9 [ELF] - Remove unnecessary template #4. NFC.
OutputSectionFactory has no ELFT templates anymore.

llvm-svn: 297720
2017-03-14 09:30:25 +00:00
George Rimar 09268b7b1e [ELF] - Remove unnecessary template #3. NFC.
llvm-svn: 297719
2017-03-14 09:25:03 +00:00
George Rimar f08b592390 [ELF] - Remove unnecessary template #2. NFC.
llvm-svn: 297718
2017-03-14 09:19:34 +00:00
George Rimar 788fe38f99 [ELF] - Remove unnecessary template. NFC.
llvm-svn: 297717
2017-03-14 09:14:28 +00:00
George Rimar 2d2621090d [ELF] - Step to combine LinkerScript and LinkerScriptBase
We can move all not templated functionality to LinkerScriptBase.
Patch do that for hasPhdrsCommands() and shows how it helps to detemplate
things in other places.

Probably we should be able to merge these 2 classes into single one after such steps.
Even if not, it still looks as reasonable cleanup for me.

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

llvm-svn: 297714
2017-03-14 09:03:53 +00:00
Eugene Leviant 5784e96f5c [ELF] Fix LMA offset calculation
Differential revision: https://reviews.llvm.org/D30832

llvm-svn: 297713
2017-03-14 08:57:09 +00:00
Eugene Leviant 30c1b436ad [ELF] Fix crash when .eh_frame(_hdr) is discarded
lld crashes when .eh_frame or .eh_frame_hdr section is discarded
in linker script and there is no PHDRS directive.

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

llvm-svn: 297712
2017-03-14 08:49:09 +00:00
Eugene Leviant 2968547997 [ELF] Fix error reporting for synthetic sections
Synthetic sections don't belong to any input file, but still they
are input sections. Whenever problem occurs with relocations in
these sections lld crashes in error reporting, trying to print
input file name.

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

llvm-svn: 297711
2017-03-14 08:33:45 +00:00
Rui Ueyama 034a33a942 Remove a useless temporary variable.
llvm-svn: 297687
2017-03-13 23:26:37 +00:00
Rui Ueyama f327999a45 Simplify and add comments. NFC.
llvm-svn: 297686
2017-03-13 23:23:40 +00:00
Rui Ueyama fed8b570b7 Make FileOutputBuffer fail early if you pass a directory.
Previously, it created a temporary directory and then failed when
FileOutputBuffer tried to rename that file to the destination file
(which is actually a directory name).

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

llvm-svn: 297679
2017-03-13 22:19:05 +00:00
Rui Ueyama 8ebf6588a5 Add a comment to say that -build-id=sha1 is a synonym for tree.
llvm-svn: 297677
2017-03-13 21:48:38 +00:00
Rui Ueyama eaeca5ed79 [ELF] Fail the link early if an output path is invalid
Patch from James Henderson.

If a user has a long link, e.g. due to a large LTO link, they do not
wish to run it and find that it failed because there was a mistake in
their command-line, after they waited for some significant amount of
time. This change adds some basic checking of the linker output file
path, which is run shortly after parsing the command-line and linker
script. An error is emitted if LLD cannot write to the specified path.

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

llvm-svn: 297645
2017-03-13 17:24:52 +00:00
Peter Collingbourne f8435a9bda ELF: Resolve _end symbols correctly.
Fix a bug introduced in r297313 which caused them to resolve to the end
of the ELF header in PIEs and DSOs.

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

llvm-svn: 297638
2017-03-13 16:40:20 +00:00
George Rimar 78aa270041 [ELF] - Remove unnecessary template. NFC.
llvm-svn: 297622
2017-03-13 14:40:58 +00:00
Petr Hosek c970acf29f [ELF] Handle NONE relocations on AArch64
Differential Revision: https://reviews.llvm.org/D30628

llvm-svn: 297525
2017-03-10 22:42:22 +00:00
Rui Ueyama 62d547441d Options such as -omagic or -opt-remarks-* should be interpreted as -o.
Options can start with `-` or `--` unless they start with "o".
Any option that starts with `-o` should be interpreted as an output
file name. This is a quote from the GNU ld man page.

  Note -- there is one exception to this rule.  Multiple letter
  options that start with a lower case 'o' can only be preceded by
  two dashes.  This is to reduce confusion with the -o option.
  So for example -omagic sets the output file name to magic whereas
  --omagic sets the NMAGIC flag on the output.

We didn't handle that properly before.

llvm-svn: 297508
2017-03-10 21:22:28 +00:00
Petr Hosek 7b79321e88 [ELF] Propely handle .eh_frame in linker scripts
Using .eh_frame input section pattern in linker script currently
causes a crash; this is because .eh_frame input sections require
special handling since they're all combined into a synthetic
section rather than regular output section.

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

llvm-svn: 297501
2017-03-10 20:00:42 +00:00
Rafael Espindola 4595df94bb Don't pass Dot to every callback.
It is available from ScriptBase.

llvm-svn: 297472
2017-03-10 16:04:26 +00:00
Rafael Espindola 9bd4566dac Use SectionBase for linker script expressions.
This is a small step for fixing pr32031, which needs expressions that
point to input sections.

llvm-svn: 297431
2017-03-10 00:47:33 +00:00
Rui Ueyama f5fce48679 Handle ":" as a regular token character in linker scripts.
This is an alternative to https://reviews.llvm.org/D30500 to simplify the
version definition parser and allow ":" in symbol names.

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

llvm-svn: 297402
2017-03-09 19:23:00 +00:00
George Rimar 0a7412f00b [ELF] - Implemented -znotext
gold linker manual describes them as:

-z text	Do not permit relocations in read-only segments
-z notext Permit relocations in read-only segments (default)

In LLD default is to not permit them. Patch implements -z notext.

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

llvm-svn: 297366
2017-03-09 08:48:34 +00:00
George Rimar 1c74c2f2a8 [ELF] - Do not try to create .eh_frame_hdr for relocatable output.
.eh_frame_hdr is a header constructed for .eh_frame sections.
We do not proccess .eh_frame when doing relocatable output,
so should not try to create .eh_frame_hdr too.
Previous behavior without this patch is segfault.

Fixes PR32118.

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

llvm-svn: 297365
2017-03-09 08:45:25 +00:00
Rui Ueyama 7d271ae21d Fix wrong assertion failure.
Previously, if you have foo=bar in a definition file, this assertion
could fire because when symbols are read from file they could be mangled.
It seems that due to historical reasons underscore mangling scheme is
really ad-hoc, and I cannot find a clean way to handle this. I had
to just de-mangle symbols to search again.

llvm-svn: 297357
2017-03-09 04:47:33 +00:00
Rui Ueyama bf84c18cc1 Print an error message instead of an assertion failure.
This assertion is failing on a Chromium builder and I cannot figure out why.
This patch let it print out more info.

llvm-svn: 297353
2017-03-09 01:28:50 +00:00
Rafael Espindola 5616adf655 Remove DefinedSynthetic.
With this we have a single section hierarchy. It is a bit less code,
but the main advantage will be in a future patch being able to handle

foo = symbol_in_obj;

in a linker script. Currently that fails since we try to find the
output section of symbol_in_obj.  With this we should be able to just
return an InputSection from the expression.

llvm-svn: 297313
2017-03-08 22:36:28 +00:00