Commit Graph

583 Commits

Author SHA1 Message Date
Rafael Espindola 24e6f363c5 Merge OutputSectionBase and OutputSection. NFC.
Now that all special sections are SyntheticSections, we only need one
OutputSection class.

llvm-svn: 296127
2017-02-24 15:07:30 +00:00
Rafael Espindola a2e3fee072 Remove unnecessary template. NFC.
llvm-svn: 296117
2017-02-24 13:19:33 +00:00
Rafael Espindola 66b4e21534 Convert EhOutputSection to be a synthetic section.
With this we complete the transition out of special output sections,
and with the previous patches it should be possible to merge
OutputSectionBase and OuputSection.

llvm-svn: 296023
2017-02-23 22:06:28 +00:00
Rafael Espindola 774ea7d0a9 Make InputSection a class. NFC.
With the current design an InputSection is basically anything that
goes directly in a OutputSection. That includes plain input section
but also synthetic sections, so this should probably not be a
template.

llvm-svn: 295993
2017-02-23 16:49:07 +00:00
Rafael Espindola c404d50d7c Merge InputSectionData and InputSectionBase.
Now that InputSectionBase is not a template there is no reason to have
the two.

llvm-svn: 295924
2017-02-23 02:32:18 +00:00
Rafael Espindola b4c9b81aad Convert InputSectionBase to a class.
Removing this template is not a big win by itself, but opens the way
for removing more templates.

llvm-svn: 295923
2017-02-23 02:28:28 +00:00
Rafael Espindola a55b86c0e5 Reduce templating a bit. NFC.
llvm-svn: 295909
2017-02-23 00:02:03 +00:00
Rui Ueyama e6e206d4b4 Do not use errs() or outs() directly. Instead use message(), log() or error()
LLD is a multi-threaded program. errs() or outs() are not guaranteed
to be thread-safe (they are actually not).

LLD's message(), log() or error() are thread-safe. We should use them.

llvm-svn: 295787
2017-02-21 23:22:56 +00:00
Rafael Espindola ecbfd871f9 Don't print DISCARD sections as gced.
This is a small difference I noticed to gold and bfd. When given
--print-gc-sections, we print sections a linkerscript marks
DISCARD. The other linkers don't.

llvm-svn: 295467
2017-02-17 17:35:07 +00:00
Rafael Espindola 6386628aae Move specialization to try to fix the bots.
I cannot reproduce the issue locally, but for some reason some bots
want to instantiate this from the header.

llvm-svn: 295365
2017-02-16 19:23:15 +00:00
Rafael Espindola 8290274c13 Share more output section creation code.
We can do this now that the linker script and the writer agree on
which sections should be combined.

llvm-svn: 295341
2017-02-16 17:32:26 +00:00
Rafael Espindola 82f00ec4a2 Fix crash with -emit-relocs -shared.
The code to handle the input SHT_REL/SHT_RELA sections was getting
confused with the linker generated relocation sections.

llvm-svn: 295322
2017-02-16 14:23:43 +00:00
Rafael Espindola f340ca8963 Make lld able to handle gold's -r output.
This is still not sufficient for lld to handle its own output when a
fde points to a discarded section. I am investigating if it is better
to change the -r output or make lld able to read the current version.

llvm-svn: 295141
2017-02-15 01:29:23 +00:00
George Rimar 82bd8be6d8 Recommit r294464 "[ELF] - Added partial support for --emit-relocs (no --gc-section case, no /DISCARD/ support) #3"
with temporarily file name fix in testcase.

Original commit message:

-q, --emit-relocs - Generate relocations in output

Simplest implementation: 
* no GC case, 
* no "/DISCARD/" linkerscript command support.

This patch is extracted from D28612 / D29636,

Relative to PR31579.

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

llvm-svn: 294469
2017-02-08 16:18:10 +00:00
George Rimar 0b2cc8190d Reverted r294464 "[ELF] - Added partial support for --emit-relocs (no --gc-section case, no /DISCARD/ support) #3"
Broked build bot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/5835/steps/test/logs/stdio

llvm-svn: 294466
2017-02-08 16:10:14 +00:00
George Rimar d6ae624552 [ELF] - Added partial support for --emit-relocs (no --gc-section case, no /DISCARD/ support) #3
-q, --emit-relocs - Generate relocations in output

Simplest implementation: 
* no GC case, 
* no "/DISCARD/" linkerscript command support.

This patch is extracted from D28612 / D29636,

Relative to PR31579.

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

llvm-svn: 294464
2017-02-08 15:53:33 +00:00
Rafael Espindola ea590d91a0 Revert "Simplify symbol computation for non alloc sections."
This reverts commit r294346. Looks like it regressed the build of
magenta.

llvm-svn: 294460
2017-02-08 15:19:03 +00:00
Rafael Espindola 193b158b39 Simplify symbol computation for non alloc sections.
We now just keep the address the section would have if it was
allocatable. Only the writer ignores it at the very end.

llvm-svn: 294346
2017-02-07 20:22:04 +00:00
Rafael Espindola cfe53dff72 Simplify. NFC.
llvm-svn: 294057
2017-02-03 21:59:15 +00:00
Rafael Espindola 2532431332 Stop propagating Entsize.
Now that we combine multiple synthetic merge section into one output
section there is no point in trying to propagate a value.

llvm-svn: 294048
2017-02-03 21:29:51 +00:00
Rafael Espindola 9e9754b520 Replace MergeOutputSection with a synthetic section.
With a synthetic merge section we can have, for example, a single
.rodata section with stings, fixed sized constants and non merge
constants.

I can be simplified further by not setting Entsize, but that is
probably better done is a followup patch.

This should allow some cleanup in the linker script code now that
every output section command maps to just one output section.

llvm-svn: 294005
2017-02-03 13:06:18 +00:00
Eugene Leviant 0c0789bc3f [ELF] Bypass section type check #2
Differential revision: https://reviews.llvm.org/D29278

llvm-svn: 293613
2017-01-31 10:26:52 +00:00
Rafael Espindola fe12450e8e Revert commits r293276 and r293278.
[ELF] Fixed formatting. NFC

and

    [ELF] Bypass section type check

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

They do the opposite of what was asked for in the code review.

llvm-svn: 293320
2017-01-27 18:39:30 +00:00
Eugene Leviant bcff495b85 [ELF] Fixed formatting. NFC
llvm-svn: 293278
2017-01-27 11:06:23 +00:00
Eugene Leviant 8b7cadcf96 [ELF] Bypass section type check
Differential revision: https://reviews.llvm.org/D28761

llvm-svn: 293276
2017-01-27 11:01:43 +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 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
Rafael Espindola bd3ab097f6 Move code to the .cpp file. NFC.
llvm-svn: 291113
2017-01-05 14:52:46 +00:00
Rafael Espindola 7244708fcd Detemplate SectionKey. NFC.
llvm-svn: 291110
2017-01-05 14:35:41 +00:00
Rafael Espindola 337139830e Change which input sections we concatenate
After Mark's patch I was wondering what was the rationale for the ELF
spec requiring us to merge only sections with matching flags and
types. I tried emailing
https://groups.google.com/forum/#!forum/generic-abi, but looks like my
emails are not being posted (the list is probably moderated). I
emailed Cary Coutant instead.

Cary pointed out that the section was a late addition and didn't got
the scrutiny it deserved. Given that and the problems found by
implementing the letter of the standard, I propose changing lld to
merge all sections with the same name and issue errors if the types or
some critical flags are different.

This should allow an unmodified firefox linked with lld to run.

This also merges some code with the linkerscript path.

llvm-svn: 291107
2017-01-05 14:20:35 +00:00
Rui Ueyama 312703116f Simplify type of Config->SymbolOrderingFile.
That variable was of type DenseMap<StringRef, unsigned>, but the
unsigned numbers needed to be monotonicly increasing numbers because
the implementation that used the variable depended on that fact.
That was an implementation detail and shouldn't have leaked into Config.

This patch simplifies its type to std::vector<StringRef>.

llvm-svn: 290151
2016-12-20 01:51:08 +00:00
Rui Ueyama 9381eb1045 Remove lld/Support/Memory.h.
I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

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

llvm-svn: 290062
2016-12-18 14:06:06 +00:00
Rui Ueyama 520d9169e6 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
llvm-svn: 289084
2016-12-08 18:31:13 +00:00
Rui Ueyama 244a435ae3 Factor out common code to a header.
llvm-svn: 288599
2016-12-03 21:24:51 +00:00
Eugene Leviant 84569e6caa [ELF] Refactor target error messages
Differential revision: https://reviews.llvm.org/D27097

llvm-svn: 288114
2016-11-29 08:05:44 +00:00
Rui Ueyama 1880bbed39 Split MergeOutputSection::finalize.
llvm-svn: 287977
2016-11-26 15:09:58 +00:00
Eugene Leviant c8c1b7bfae [ELF] EhOutputSection improvements
Differential revision: https://reviews.llvm.org/D27098

llvm-svn: 287914
2016-11-25 08:27:15 +00:00
Peter Smith 719eb8efa5 [ELF] Add terminating sentinel .ARM.exidx table entry
The .ARM.exidx table has an entry for each function with the first entry
giving the start address of the function, the table is sorted in ascending
order of function address. Given a PC value, the unwinder will search the
table for the entry that contains the PC value.
    
If the table entry happens to be the last, the range of the addresses that
the final unwinding table describes will extend to the end of the address
space. To prevent an incorrect address outside the address range of the
program matching the last entry we follow ld.bfd's example and add a
sentinel EXIDX_CANTUNWIND entry at the end of the table. This gives the
final real table entry an upper bound.
    
In addition the llvm libunwind unwinder currently depends on the presence
of a sentinel entry (PR31091).

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

llvm-svn: 287869
2016-11-24 11:43:55 +00:00
Eugene Leviant 531df4fcef [ELF] Print error location in .eh_frame parser
Differential revision: https://reviews.llvm.org/D26914

llvm-svn: 287750
2016-11-23 09:45:17 +00:00
Rui Ueyama b38ddb15dd Move a function definition to SyntheticSections.cpp.
This should have been moved along with r287554.

llvm-svn: 287564
2016-11-21 19:46:04 +00:00
Eugene Leviant e9bab5d857 [ELF] Convert Version*** sections to input sections
Differential revision: https://reviews.llvm.org/D26918

llvm-svn: 287554
2016-11-21 16:59:33 +00:00
Eugene Leviant 952eb4d348 [ELF] Convert EhFrameHeader to input section
Differential revision: https://reviews.llvm.org/D26906

llvm-svn: 287549
2016-11-21 15:52:10 +00:00
Eugene Leviant a113a4194c [ELF] Convert GdbIndexSection to input section
Differential revision: https://reviews.llvm.org/D26854

llvm-svn: 287526
2016-11-21 09:24:43 +00:00
Rui Ueyama 8f47556796 Remove unused #include.
llvm-svn: 287467
2016-11-19 23:18:43 +00:00
Rui Ueyama 16068aeb58 Change filler type from ArrayRef<uint8_t> to uint32_t.
Filler expressions in linker script "=fillexp" are always handled
as 32-bit integers. Thus the new type is more natural.

llvm-svn: 287445
2016-11-19 18:05:56 +00:00
Rui Ueyama 5c851a5a6d Simplify. NFC.
llvm-svn: 287372
2016-11-18 19:45:04 +00:00
Rafael Espindola 4d2d9c07a5 Simplify handling of SHF_LINK_ORDER.
It seems a lot simpler to just sort the sections and let the
relocations do the rest.

llvm-svn: 287365
2016-11-18 19:02:15 +00:00
Eugene Leviant ff23d3e741 [ELF] Convert PltSection to input section
Differential revision: https://reviews.llvm.org/D26842

llvm-svn: 287346
2016-11-18 14:35:03 +00:00
Eugene Leviant b96e809c7f [ELF] Convert HashTableSection to input section
Differential revision: https://reviews.llvm.org/D26834

llvm-svn: 287326
2016-11-18 09:06:47 +00:00
Eugene Leviant be809a7125 [ELF] Convert GnuHashTableSection to input section
Differential revision: https://reviews.llvm.org/D26792

llvm-svn: 287322
2016-11-18 06:44:18 +00:00