Commit Graph

28 Commits

Author SHA1 Message Date
Rui Ueyama 33ab83bc4b ELF: Don't use LayoutPass.
Previously we applied the LayoutPass to order atoms and then
apply elf::ArrayOrderPass to sort them again. The first pass is
basically supposed to sort atoms in the normal fashion (which
is to sort symbols in the same order as the input files).
The second pass sorts atoms in {init,fini}_array.<priority> by
priority.

The problem is that the LayoutPass is overkill. It analyzes
references between atoms to make a decision how to sort them.
It's slow, hard to understand, and above all, it doesn't seem
that we need its feature for ELF in the first place.

This patch remove the LayoutPass from ELF pass list. Now all
reordering is done in elf::OrderPass. That pass sorts atoms by
{init,fini}_array, and if they are not in the special section,
they are ordered as the same order as they appear in the command
line. The new code is far easier to understand, faster, and
still able to create valid executables.

Unlike the previous layout pass, elf::OrderPass doesn't count
any attributes of an atom (e.g. permissions) except its
position. It's OK because the writer takes care of them if we
have to.

This patch changes the order of final output, although that's
benign. Tests are updated.

http://reviews.llvm.org/D7278

llvm-svn: 227666
2015-01-31 02:05:01 +00:00
Filipe Cabecinhas d1787adcec Fix REQUIRES lines added in r226951 and add the x86 feature if the X86 target was compiled in
llvm-svn: 226985
2015-01-24 03:55:22 +00:00
Filipe Cabecinhas d72d29b0b6 [lld] Added REQUIRES lines to tests
llvm-svn: 226951
2015-01-23 22:32:12 +00:00
Shankar Easwaran c37f8af577 [ELF] Dynamic section was not aligned properly.
The dynamic section was not aligned properly. The alignment of the section is
determined by the word size of the architecture.

llvm-svn: 221972
2014-11-14 04:57:21 +00:00
Shankar Easwaran 6e0e1bc859 [ELF] change LayoutBefore Reference to InGroup Reference
This makes it a lot easier for Section Group design.

llvm-svn: 200675
2014-02-03 04:01:14 +00:00
Shankar Easwaran 3d8de47f76 Fix trailing whitespace.
llvm-svn: 200182
2014-01-27 03:09:26 +00:00
Michael J. Spencer 5fbce5bd56 [ELF] Implement minimal support for .eh_frame_hdr.
llvm-svn: 193662
2013-10-30 00:02:04 +00:00
Shankar Easwaran bcf36560fd [ELF] Fix Atoms in the same file had overlapping ordinals.
This also reverts the LayoutPass to use std::sort as all files
have an ordinal now.

llvm-svn: 192409
2013-10-11 01:50:04 +00:00
Shankar Easwaran 5d859e05f2 [test] Ignore failure for now for Darwin.
This is only a step to clean the buildbot.

llvm-svn: 192368
2013-10-10 17:12:50 +00:00
Shankar Easwaran a96f3a3da4 [lld][InputGraph] Change the Resolver to use inputGraph
Changes :-

a) Functionality in InputGraph to insert Input elements at any position
b) Functionality in the Resolver to use nextFile
c) Move the functionality of assigning file ordinals to InputGraph
d) Changes all inputs to MemoryBuffers
e) Remove LinkerInput, InputFiles, ReaderArchive

llvm-svn: 192081
2013-10-07 02:47:09 +00:00
Michael J. Spencer 3b36473007 [ELF] Mark STT_GNU_IFUNC symbols as code.
llvm-svn: 191566
2013-09-27 21:30:04 +00:00
Shankar Easwaran 7915ff34b7 [lld][LinkingContext][ELF] Allow different output file types.
This adds an option --output-filetype that can be set to either
YAML/Native(case insensitive). The linker would create the outputs
associated with the type specified by the user.

Changes all the tests to use the new option.

llvm-svn: 191183
2013-09-23 04:24:15 +00:00
Shankar Easwaran f1b341c80e [lld][LayoutPass] Order the atoms that are in the same chain
We need to order atoms that exist in the same chain. This is to make sure that
the command line order is preserved when we emit the atoms to the output file.

Credits: BigCheese for finding the bug.

Adds a test which otherwise would fail.

llvm-svn: 190608
2013-09-12 15:43:09 +00:00
Rafael Espindola e699c60021 Now that llvm-readobj is fixed, enable this test.
llvm-svn: 183285
2013-06-05 01:38:12 +00:00
Shankar Easwaran d8da989e78 [lld][LayoutPass] An earlier commit moved the functionality so that Atoms would
be laid out by their ordinal overrides first, there was a bug that two atoms may 
get the same override index due to which atoms were not ordered properly. This
commit fixes the problem.

Now the atoms are ordered by 

- Section Position hints
- Atom override (Using layout-after/layout-before/in-group)
- Content Permissions
- Content Type
- File Ordinal

This also fixes the problem of running c++ static executables that 
was broken by an earlier patch.

llvm-svn: 182494
2013-05-22 17:41:04 +00:00
Shankar Easwaran 9af77a2cab [lld][ELF][All Archs] Addend is used by dynamic relocations
only if they are relative. This removes the FIXME when the
relocations are being emitted and checks if the relocation
is relative and only then populates the addend information.

I couldnt add a testcase for this as llvm-readobj lacks     
functionality of printing dynamic relocations.              

When the functionality is added, remove the commented lines
from elf/ifunc.test to test functionality.

llvm-svn: 182077
2013-05-17 05:10:30 +00:00
Shankar Easwaran 3c5d2c8a24 [lld][LayoutPass] This commit fixes a problem in the
Layoutpass by ordering atoms if they appear in the override
list first and then looking at the way of ordering atoms in
the default way.

The fix also fixes issues with the sizes of the sections,
that appear in the output properly too.

The commit also adds a testcase(orderatoms-by-override.test)
to test it and fixes all the other relevant testcases.

llvm-svn: 181605
2013-05-10 16:44:02 +00:00
Nick Kledzik c314b46e71 This is my Driver refactoring patch.
The major changes are:
1) LinkerOptions has been merged into TargetInfo
2) LinkerInvocation has been merged into Driver
3) Drivers no longer convert arguments into an intermediate (core) argument 
   list, but instead create a TargetInfo object and call setter methods on 
   it. This is only how in-process linking would work. That is, you can 
   programmatically set up a TargetInfo object which controls the linking.
4) Lots of tweaks to test suite to work with driver changes
5) Add the DarwinDriver
6) I heavily doxygen commented TargetInfo.h

Things to do after this patch is committed:
a) Consider renaming TargetInfo, given its new roll. 
b) Consider pulling the list of input files out of TargetInfo. This will 
   enable in-process clients to create one TargetInfo the re-use it with 
   different input file lists.
c) Work out a way for Drivers to format the warnings and error done in 
   core linking.

llvm-svn: 178776
2013-04-04 18:59:24 +00:00
Michael J. Spencer a26f71c9ed [ELF][x86-64] Separate static and dynamic GOT/PLT generation.
llvm-svn: 176294
2013-02-28 20:04:32 +00:00
Shankar Easwaran 4685069152 [ELF][tests] changes for test cases
llvm-svn: 176280
2013-02-28 18:38:20 +00:00
Michael J. Spencer be03e2a861 [Core,Driver,ELF] Differentiate static and dynamic executables.
This also adds a simple relocation change for dynamic executables to
x86-64 ELF.

llvm-svn: 175208
2013-02-14 20:32:00 +00:00
Shankar Easwaran 710b4c8fa2 fix segment ordering of elf segments
llvm-svn: 174659
2013-02-07 20:33:55 +00:00
Michael J. Spencer 7a0e212f6f [ELF][x86-64] Handle PLT32 relocations to IFUNC.
llvm-svn: 174428
2013-02-05 19:15:03 +00:00
Shankar Easwaran d476528e3d add alignment to .got/.got.plt/.plt sections & fix tests
llvm-svn: 174199
2013-02-01 18:03:32 +00:00
Michael J. Spencer 08b49bf27e [ELF][x86-64] Fix ifunc and add test.
In an previous commit I managed to completely disable the IRELATIVE relocation
writing code. I also used the wrong addend for the static relocation. Fix both
these issues and add a test. This test is quite brittle because there's no way
to do arithmetic on variables in FileCheck.

llvm-svn: 174161
2013-02-01 09:14:21 +00:00
Michael J. Spencer b5d6f5e988 [ELF][x86-64] Implement static relocation model for TLS.
This implements the static relocation model for GOT accesses to TLS.

llvm-svn: 174155
2013-02-01 07:14:14 +00:00
Michael J. Spencer 289dcedea5 [ELF] Add support for IFUNC.
This sadly doesn't have a test for the final
output because llvm-objdump can't dump relocations
that don't belong to a section :(

llvm-svn: 173808
2013-01-29 16:38:03 +00:00
Michael J. Spencer 563d33a6f1 [ELF] Read IFUNC symbols correctly as typeResolver.
llvm-svn: 173299
2013-01-23 22:08:46 +00:00